From 581245ed35bde63a8691c5f5a059cc647b2e88ec Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 28 Mar 2022 18:04:24 +0200 Subject: ma gum.r: move smartd monitor to hw-specific config --- makefu/1systems/gum/config.nix | 2 - makefu/1systems/gum/hardware-config.nix | 113 ------------------------------- makefu/1systems/gum/hetzner/default.nix | 116 ++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 115 deletions(-) delete mode 100644 makefu/1systems/gum/hardware-config.nix create mode 100644 makefu/1systems/gum/hetzner/default.nix diff --git a/makefu/1systems/gum/config.nix b/makefu/1systems/gum/config.nix index 540106004..0cdfcda4b 100644 --- a/makefu/1systems/gum/config.nix +++ b/makefu/1systems/gum/config.nix @@ -32,8 +32,6 @@ in { # - - { services.smartd.devices = builtins.map (x: { device = x; }) allDisks; } # Security diff --git a/makefu/1systems/gum/hardware-config.nix b/makefu/1systems/gum/hardware-config.nix deleted file mode 100644 index 1881329ce..000000000 --- a/makefu/1systems/gum/hardware-config.nix +++ /dev/null @@ -1,113 +0,0 @@ -{ config, ... }: -let - external-mac = "50:46:5d:9f:63:6b"; - main-disk = "/dev/disk/by-id/ata-TOSHIBA_DT01ACA300_13H8863AS"; - sec-disk = "/dev/disk/by-id/ata-TOSHIBA_DT01ACA300_23OJ2GJAS"; - external-gw = "144.76.26.225"; - # single partition, label "nixos" - # cd /var/src; curl https://github.com/nixos/nixpkgs/tarball/809cf38 -L | tar zx ; mv * nixpkgs && touch .populate - - - # static - external-ip = "144.76.26.247"; - external-ip6 = "2a01:4f8:191:12f6::2"; - external-gw6 = "fe80::1"; - external-netmask = 27; - external-netmask6 = 64; - internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr; - ext-if = "et0"; # gets renamed on the fly -in { - imports = [ - ]; - makefu.server.primary-itf = ext-if; - services.udev.extraRules = '' - SUBSYSTEM=="net", ATTR{address}=="${external-mac}", NAME="${ext-if}" - ''; - networking = { - interfaces."${ext-if}" = { - ipv4.addresses = [{ - address = external-ip; - prefixLength = external-netmask; - }]; - ipv6.addresses = [{ - address = external-ip6; - prefixLength = external-netmask6; - }]; - }; - defaultGateway6 = { address = external-gw6; interface = ext-if; }; - defaultGateway = external-gw; - }; - boot.kernelParams = [ ]; - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.devices = [ main-disk ]; - boot.initrd.kernelModules = [ "dm-raid" "dm_cache" "dm-thin-pool" ]; - boot.initrd.availableKernelModules = [ - "ata_piix" "vmw_pvscsi" "virtio_pci" "sd_mod" "ahci" - "xhci_pci" "ehci_pci" "ahci" "sd_mod" - ]; - boot.kernelModules = [ "dm-raid" "dm_cache" "dm-thin-pool" "kvm-intel" ]; - hardware.enableRedistributableFirmware = true; - fileSystems."/" = { - device = "/dev/nixos/root"; - fsType = "ext4"; - }; - fileSystems."/var/lib" = { - device = "/dev/nixos/lib"; - fsType = "ext4"; - }; - fileSystems."/var/log" = { - device = "/dev/nixos/log"; - fsType = "ext4"; - }; - fileSystems."/var/download" = { - device = "/dev/nixos/download"; - fsType = "ext4"; - }; - fileSystems."/var/www/binaergewitter" = { - device = "/dev/nixos/binaergewitter"; - fsType = "ext4"; - options = [ "nofail" ]; - }; - fileSystems."/var/lib/nextcloud/data" = { - device = "/dev/nixos/nextcloud"; - fsType = "ext4"; - options = [ "nofail" ]; - }; - fileSystems."/var/lib/borgbackup" = { - device = "/dev/nixos/backup"; - fsType = "ext4"; - }; - fileSystems."/boot" = { - device = "/dev/sda2"; - fsType = "vfat"; - }; - # parted -s -a optimal "$disk" \ - # mklabel gpt \ - # mkpart no-fs 0 1024KiB \ - # set 1 bios_grub on \ - # mkpart ESP fat32 1025KiB 1024MiB set 2 boot on \ - # mkpart primary 1025MiB 100% - # parted -s -a optimal "/dev/sdb" \ - # mklabel gpt \ - # mkpart primary 1M 100% - - #mkfs.vfat /dev/sda2 - #pvcreate /dev/sda3 - #pvcreate /dev/sdb1 - #vgcreate nixos /dev/sda3 /dev/sdb1 - #lvcreate -L 120G -m 1 -n root nixos - #lvcreate -L 50G -m 1 -n lib nixos - #lvcreate -L 100G -n download nixos - #lvcreate -L 100G -n backup nixos - #mkfs.ext4 /dev/mapper/nixos-root - #mkfs.ext4 /dev/mapper/nixos-lib - #mkfs.ext4 /dev/mapper/nixos-download - #mkfs.ext4 /dev/mapper/nixos-borgbackup - #mount /dev/mapper/nixos-root /mnt - #mkdir /mnt/boot - #mount /dev/sda2 /mnt/boot - #mkdir -p /mnt/var/src - #touch /mnt/var/src/.populate - -} diff --git a/makefu/1systems/gum/hetzner/default.nix b/makefu/1systems/gum/hetzner/default.nix new file mode 100644 index 000000000..7d445879a --- /dev/null +++ b/makefu/1systems/gum/hetzner/default.nix @@ -0,0 +1,116 @@ +{ config, ... }: +let + external-mac = "50:46:5d:9f:63:6b"; + main-disk = "/dev/disk/by-id/ata-TOSHIBA_DT01ACA300_13H8863AS"; + sec-disk = "/dev/disk/by-id/ata-TOSHIBA_DT01ACA300_23OJ2GJAS"; + external-gw = "144.76.26.225"; + # single partition, label "nixos" + # cd /var/src; curl https://github.com/nixos/nixpkgs/tarball/809cf38 -L | tar zx ; mv * nixpkgs && touch .populate + + + # static + external-ip = "144.76.26.247"; + external-ip6 = "2a01:4f8:191:12f6::2"; + external-gw6 = "fe80::1"; + external-netmask = 27; + external-netmask6 = 64; + internal-ip = config.krebs.build.host.nets.retiolum.ip4.addr; + ext-if = "et0"; # gets renamed on the fly +in { + imports = [ + + { services.smartd.devices = builtins.map (x: { device = x; }) allDisks; } + + ]; + makefu.server.primary-itf = ext-if; + services.udev.extraRules = '' + SUBSYSTEM=="net", ATTR{address}=="${external-mac}", NAME="${ext-if}" + ''; + networking = { + interfaces."${ext-if}" = { + ipv4.addresses = [{ + address = external-ip; + prefixLength = external-netmask; + }]; + ipv6.addresses = [{ + address = external-ip6; + prefixLength = external-netmask6; + }]; + }; + defaultGateway6 = { address = external-gw6; interface = ext-if; }; + defaultGateway = external-gw; + }; + boot.kernelParams = [ ]; + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.devices = [ main-disk ]; + boot.initrd.kernelModules = [ "dm-raid" "dm_cache" "dm-thin-pool" ]; + boot.initrd.availableKernelModules = [ + "ata_piix" "vmw_pvscsi" "virtio_pci" "sd_mod" "ahci" + "xhci_pci" "ehci_pci" "ahci" "sd_mod" + ]; + boot.kernelModules = [ "dm-raid" "dm_cache" "dm-thin-pool" "kvm-intel" ]; + hardware.enableRedistributableFirmware = true; + fileSystems."/" = { + device = "/dev/nixos/root"; + fsType = "ext4"; + }; + fileSystems."/var/lib" = { + device = "/dev/nixos/lib"; + fsType = "ext4"; + }; + fileSystems."/var/log" = { + device = "/dev/nixos/log"; + fsType = "ext4"; + }; + fileSystems."/var/download" = { + device = "/dev/nixos/download"; + fsType = "ext4"; + }; + fileSystems."/var/www/binaergewitter" = { + device = "/dev/nixos/binaergewitter"; + fsType = "ext4"; + options = [ "nofail" ]; + }; + fileSystems."/var/lib/nextcloud/data" = { + device = "/dev/nixos/nextcloud"; + fsType = "ext4"; + options = [ "nofail" ]; + }; + fileSystems."/var/lib/borgbackup" = { + device = "/dev/nixos/backup"; + fsType = "ext4"; + }; + fileSystems."/boot" = { + device = "/dev/sda2"; + fsType = "vfat"; + }; + # parted -s -a optimal "$disk" \ + # mklabel gpt \ + # mkpart no-fs 0 1024KiB \ + # set 1 bios_grub on \ + # mkpart ESP fat32 1025KiB 1024MiB set 2 boot on \ + # mkpart primary 1025MiB 100% + # parted -s -a optimal "/dev/sdb" \ + # mklabel gpt \ + # mkpart primary 1M 100% + + #mkfs.vfat /dev/sda2 + #pvcreate /dev/sda3 + #pvcreate /dev/sdb1 + #vgcreate nixos /dev/sda3 /dev/sdb1 + #lvcreate -L 120G -m 1 -n root nixos + #lvcreate -L 50G -m 1 -n lib nixos + #lvcreate -L 100G -n download nixos + #lvcreate -L 100G -n backup nixos + #mkfs.ext4 /dev/mapper/nixos-root + #mkfs.ext4 /dev/mapper/nixos-lib + #mkfs.ext4 /dev/mapper/nixos-download + #mkfs.ext4 /dev/mapper/nixos-borgbackup + #mount /dev/mapper/nixos-root /mnt + #mkdir /mnt/boot + #mount /dev/sda2 /mnt/boot + #mkdir -p /mnt/var/src + #touch /mnt/var/src/.populate + +} -- cgit v1.2.3 From 4156d2ed156f1b8304aba7888337173c53998499 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 28 Mar 2022 18:04:33 +0200 Subject: ma pkgs.ns-usbloader: init --- makefu/2configs/tools/consoles.nix | 1 + makefu/5pkgs/ns-usbloader/default.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 makefu/5pkgs/ns-usbloader/default.nix diff --git a/makefu/2configs/tools/consoles.nix b/makefu/2configs/tools/consoles.nix index 7d58daa3f..f213a9b0e 100644 --- a/makefu/2configs/tools/consoles.nix +++ b/makefu/2configs/tools/consoles.nix @@ -15,6 +15,7 @@ nx_game_info hactool nsrenamer + ns-usbloader sfo exfatprogs exfat-utils exfat ]; diff --git a/makefu/5pkgs/ns-usbloader/default.nix b/makefu/5pkgs/ns-usbloader/default.nix new file mode 100644 index 000000000..42e12e38e --- /dev/null +++ b/makefu/5pkgs/ns-usbloader/default.nix @@ -0,0 +1,35 @@ +{ lib, stdenv, fetchurl, makeWrapper, jre }: + +stdenv.mkDerivation rec { + name = "ns-usbloader-${version}"; + version = "5.2"; + + src = fetchurl { + url = "https://github.com/developersu/ns-usbloader/releases/download/v${version}/ns-usbloader-${version}.jar"; + sha256 = "06kzshlvqfwcjjddzqqgq13pqa5qjlajpyn6ksqxy5p5hgarj6i6"; + }; + + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ jre ]; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + install -D $src $out/ns-usbloader/ns-usbloader.jar + makeWrapper ${jre}/bin/java $out/bin/ns-usbloader \ + --add-flags "-jar $out/ns-usbloader/ns-usbloader.jar" + runHook postInstall + ''; + + + meta = with lib; { + description = "Awoo Installer and GoldLeaf uploader of the NSPs (and other files), RCM payload injector, application for split/merge files"; + homepage = https://github.com/developersu/ns-usbloader; + maintainers = [ maintainers.makefu ]; + platforms = platforms.linux; + license = with licenses; [ gpl3 ]; + }; + +} -- cgit v1.2.3 From c3adb252afa29f0140f29c935201cfbb100b5697 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 8 Apr 2022 19:49:07 +0200 Subject: ma pkgs.ns-usbloader: use wrapGappsHook --- makefu/1systems/x/config.nix | 3 ++- makefu/5pkgs/ns-usbloader/default.nix | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/makefu/1systems/x/config.nix b/makefu/1systems/x/config.nix index 3edfcecc1..4f5fe44b5 100644 --- a/makefu/1systems/x/config.nix +++ b/makefu/1systems/x/config.nix @@ -13,7 +13,7 @@ # ./x230 # Common Hardware Components - + # # @@ -26,6 +26,7 @@ + # # base diff --git a/makefu/5pkgs/ns-usbloader/default.nix b/makefu/5pkgs/ns-usbloader/default.nix index 42e12e38e..b3890d11b 100644 --- a/makefu/5pkgs/ns-usbloader/default.nix +++ b/makefu/5pkgs/ns-usbloader/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, makeWrapper, jre }: +{ lib, stdenv, fetchurl, makeWrapper, wrapGAppsHook, glib , jre }: stdenv.mkDerivation rec { name = "ns-usbloader-${version}"; @@ -10,7 +10,6 @@ stdenv.mkDerivation rec { }; - nativeBuildInputs = [ makeWrapper ]; buildInputs = [ jre ]; dontUnpack = true; @@ -22,6 +21,7 @@ stdenv.mkDerivation rec { --add-flags "-jar $out/ns-usbloader/ns-usbloader.jar" runHook postInstall ''; + nativeBuildInputs = [ glib wrapGAppsHook makeWrapper ]; meta = with lib; { -- cgit v1.2.3 From 5187d0ac208deb06eff3bafb7ffd2fc32286b46a Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 2 May 2022 22:25:19 +0200 Subject: ma rss: deploy ratt job --- makefu/2configs/deployment/rss.euer.krebsco.de.nix | 24 --------- makefu/2configs/deployment/rss/ebk.yml | 59 ++++++++++++++++++++++ makefu/2configs/deployment/rss/ratt-hourly.sh | 28 ++++++++++ makefu/2configs/deployment/rss/ratt.nix | 26 ++++++++++ .../deployment/rss/rss.euer.krebsco.de.nix | 30 +++++++++++ makefu/2configs/deployment/rss/urls | 5 ++ 6 files changed, 148 insertions(+), 24 deletions(-) delete mode 100644 makefu/2configs/deployment/rss.euer.krebsco.de.nix create mode 100644 makefu/2configs/deployment/rss/ebk.yml create mode 100755 makefu/2configs/deployment/rss/ratt-hourly.sh create mode 100644 makefu/2configs/deployment/rss/ratt.nix create mode 100644 makefu/2configs/deployment/rss/rss.euer.krebsco.de.nix create mode 100644 makefu/2configs/deployment/rss/urls diff --git a/makefu/2configs/deployment/rss.euer.krebsco.de.nix b/makefu/2configs/deployment/rss.euer.krebsco.de.nix deleted file mode 100644 index 19f20f50f..000000000 --- a/makefu/2configs/deployment/rss.euer.krebsco.de.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, lib, config, ... }: -let - fqdn = "rss.euer.krebsco.de"; -in { - services.tt-rss = { - enable = true; - virtualHost = fqdn; - selfUrlPath = "https://${fqdn}"; - }; - - services.postgresql.package = pkgs.postgresql_9_6; - state = [ config.services.postgresqlBackup.location ]; - - services.postgresqlBackup = { - enable = true; - databases = [ config.services.tt-rss.database.name ]; - }; - - services.nginx.virtualHosts."${fqdn}" = { - enableACME = true; - forceSSL = true; - }; -} - diff --git a/makefu/2configs/deployment/rss/ebk.yml b/makefu/2configs/deployment/rss/ebk.yml new file mode 100644 index 000000000..3248f5c4e --- /dev/null +++ b/makefu/2configs/deployment/rss/ebk.yml @@ -0,0 +1,59 @@ +regex: https://www.ebay\-kleinanzeigen.de/s\-.* +selectors: + httpsettings: + cookie: {} + header: {} + useragent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) + Chrome/90.0.4430.72 Safari/537.36 + insecure: false + feed: + title: title + authorname: "" + authoremail: "" + item: + container: ul[id='srchrslt-adtable'] li[class='ad-listitem lazyload-item '] + title: | + title = sel:find("h2.text-module-begin"):first():text():gsub("^%s*(.-)%s*$", "%1") + print(title) + link: | + link = sel:find("a"):first():attr("href") + print("https://www.ebay-kleinanzeigen.de" .. link) + created: |- + created = "" + sel:find("div.aditem-main--top--right"):each(function(i, s) + created = s:text():gsub("^%s*(.-)%s*$", "%1") + end) + if created:match("Heute") then + time = created:gsub("^.*,", "") + print(os.date("%d.%m.%Y") .. time .. " CET") + return + end + if created:match("Gestern") then + time = created:gsub("^.*,", "") + print(os.date("%d.%m.%Y", os.time()-24*60*60) .. time .. " CET") + return + end + if created:match("\.") then + print(created .. " 00:00 CET") + return + end + createdformat: 02.01.2006 15:04 MST + description: |- + description = sel:find(".aditem-main--middle"):html() + place = sel:find(".aditem-main--top--left"):html() + print(description .. place) + content: "" + image: | + img = sel:find("div.imagebox"):first():attr("data-imgsrc") + if img ~= "" then + -- prepend host if needed + if not(img:match("https*:\/\/.*")) then + img = "https://www.ebay-kleinanzeigen.de" .. img + end + print(img) + end + nextpage: | + nextpage = sel:find("link[rel=next]"):attr("href") + print("https://www.ebay-kleinanzeigen.de" .. nextpage) + nextpagecount: 5 + sort: "" diff --git a/makefu/2configs/deployment/rss/ratt-hourly.sh b/makefu/2configs/deployment/rss/ratt-hourly.sh new file mode 100755 index 000000000..67f2529bd --- /dev/null +++ b/makefu/2configs/deployment/rss/ratt-hourly.sh @@ -0,0 +1,28 @@ +#!/bin/sh +set -eu +URLS=${1?must provide URLS file} +OUTFILE=${2:-all.xml} + +echo "init, writing to $OUTFILE" + +cat > "$OUTFILE" < + + + makefu Ebay Kleinanzeigen + https://www.ebay-kleinanzeigen.de/ + Feed for all kleinanzeigen + $(date '+%a, %d %b %Y %H:%M:%S %z') +EOF +echo "looping through $URLS" +cat "$URLS" | while read line;do + echo "fetching $line" + ratt auto "$line" | \ + xmlstarlet sel -t -c "//item" >> "$OUTFILE" || : +done + +echo "close" +cat >> "$OUTFILE" < + +EOF diff --git a/makefu/2configs/deployment/rss/ratt.nix b/makefu/2configs/deployment/rss/ratt.nix new file mode 100644 index 000000000..b794d9201 --- /dev/null +++ b/makefu/2configs/deployment/rss/ratt.nix @@ -0,0 +1,26 @@ +{ pkgs, lib, config, ... }: +let + fqdn = "rss.euer.krebsco.de"; + ratt-path = "/var/lib/ratt/"; + out-path = "${ratt-path}/all.xml"; +in { + systemd.tmpfiles.rules = ["d ${ratt-path} 0750 nginx nginx - -" ]; + systemd.services.run-ratt = { + enable = true; + path = with pkgs; [ "/nix/store/vhmzblnaav2lp4lwqdgm13l55qlm79mk-ratt-unstable-2022-01-11" xmlstarlet ]; + script = builtins.readFile ./ratt-hourly.sh; + scriptArgs = "${./urls} ${out-path}"; + + preStart = "install -v -m750 ${./ebk.yml} ${ratt-path}/ebk.yml"; # ratt requires the config file in the cwd + serviceConfig.User = "nginx"; + serviceConfig.WorkingDirectory= ratt-path; + startAt = "00/3:07"; # every 3 hours, fetch latest + }; + + services.nginx.virtualHosts."${fqdn}" = { + locations."=/ratt/all.xml" = { + alias = out-path; + }; + }; +} + diff --git a/makefu/2configs/deployment/rss/rss.euer.krebsco.de.nix b/makefu/2configs/deployment/rss/rss.euer.krebsco.de.nix new file mode 100644 index 000000000..e64a69d9c --- /dev/null +++ b/makefu/2configs/deployment/rss/rss.euer.krebsco.de.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, ... }: +let + fqdn = "rss.euer.krebsco.de"; + ratt-path = "/var/lib/ratt/"; +in { + systemd.tmpfiles.rules = ["d ${ratt-path} 0750 nginx nginx - -" ]; + services.tt-rss = { + enable = true; + virtualHost = fqdn; + selfUrlPath = "https://${fqdn}"; + }; + + services.postgresql.package = pkgs.postgresql_9_6; + state = [ config.services.postgresqlBackup.location ]; + + services.postgresqlBackup = { + enable = true; + databases = [ config.services.tt-rss.database.name ]; + }; + + services.nginx.virtualHosts."${fqdn}" = { + enableACME = true; + forceSSL = true; + locations."/ratt/" = { + alias = ratt-path; + extraConfig = "autoindex on;"; + }; + }; +} + diff --git a/makefu/2configs/deployment/rss/urls b/makefu/2configs/deployment/rss/urls new file mode 100644 index 000000000..12d4c092a --- /dev/null +++ b/makefu/2configs/deployment/rss/urls @@ -0,0 +1,5 @@ +https://www.ebay-kleinanzeigen.de/s-muehlhausen/preis:0:45/duplo-eisenbahn/k0l9313r5 +https://www.ebay-kleinanzeigen.de/s-heimwerken/nein/muehlhausen/bohrmaschine/k0c84l9313r5+heimwerken.versand_s:nein +https://www.ebay-kleinanzeigen.de/s-stuttgart/zigbee/k0l9280 +https://www.ebay-kleinanzeigen.de/s-stuttgart/ikea-tradfri-fernbedienung/k0l9280 +https://www.ebay-kleinanzeigen.de/s-70378/d%C3%B6rrautomat/k0l9334r5 -- cgit v1.2.3 From 7e89bf587256e6148b2ed46e4da0ac818a1dd012 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 May 2022 12:56:29 +0200 Subject: ma gum.r: bind nextcloud data --- makefu/1systems/gum/config.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/makefu/1systems/gum/config.nix b/makefu/1systems/gum/config.nix index 0cdfcda4b..f47289e06 100644 --- a/makefu/1systems/gum/config.nix +++ b/makefu/1systems/gum/config.nix @@ -133,6 +133,23 @@ in { # # Removed until move: avoid letsencrypt ban ### Web + + # postgres backend + # postgres backend + + + #postgres backend + ### Moving owncloud data dir to /media/cloud/nextcloud-data + { + users.users.nextcloud.extraGroups = [ "download" ]; + # nextcloud-setup fails as it cannot set permissions for nextcloud + systemd.services.nextcloud-setup.serviceConfig.SuccessExitStatus = "0 1"; + fileSystems."/var/lib/nextcloud/data" = { + device = "/media/cloud/nextcloud-data"; + options = [ "bind" ]; + }; + } + # @@ -148,7 +165,7 @@ in { # # - + # # -- cgit v1.2.3 From 12436ad8beefeb818954076432e469f34e831ad2 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 May 2022 12:56:43 +0200 Subject: ma omo.r: enable vaapi --- makefu/1systems/omo/config.nix | 3 ++- makefu/1systems/omo/hw/omo.nix | 4 +++- makefu/1systems/omo/hw/vaapi.nix | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 makefu/1systems/omo/hw/vaapi.nix diff --git a/makefu/1systems/omo/config.nix b/makefu/1systems/omo/config.nix index 42f335264..ee29c03d2 100644 --- a/makefu/1systems/omo/config.nix +++ b/makefu/1systems/omo/config.nix @@ -28,7 +28,7 @@ in { - + # @@ -98,6 +98,7 @@ in { + diff --git a/makefu/1systems/omo/hw/omo.nix b/makefu/1systems/omo/hw/omo.nix index ae5b778bf..eaedbb779 100644 --- a/makefu/1systems/omo/hw/omo.nix +++ b/makefu/1systems/omo/hw/omo.nix @@ -39,7 +39,9 @@ let in { imports = [ # TODO: unlock home partition via ssh - ]; + ./vaapi.nix + ]; + makefu.server.primary-itf = primaryInterface; system.activationScripts.createCryptFolders = '' ${lib.concatMapStringsSep "\n" diff --git a/makefu/1systems/omo/hw/vaapi.nix b/makefu/1systems/omo/hw/vaapi.nix new file mode 100644 index 000000000..8250d4110 --- /dev/null +++ b/makefu/1systems/omo/hw/vaapi.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: +{ + nixpkgs.config.packageOverrides = pkgs: { + vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; + }; + hardware.opengl = { + enable = true; + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) + vaapiVdpau + libvdpau-va-gl + ]; + }; + hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ vaapiIntel ]; + environment.systemPackages = [ pkgs.libva-utils ]; +} -- cgit v1.2.3 From cdc73d611ea140a7ba75a0e6ebc51860a8fad9a8 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 May 2022 12:57:12 +0200 Subject: ma iso.r: cleanup --- makefu/1systems/iso/config.nix | 18 +++++++++++------- makefu/1systems/iso/justdoit.nix | 18 +++++------------- makefu/1systems/iso/target-config.nix | 14 ++++++++++---- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/makefu/1systems/iso/config.nix b/makefu/1systems/iso/config.nix index 6c4f62310..207121236 100644 --- a/makefu/1systems/iso/config.nix +++ b/makefu/1systems/iso/config.nix @@ -9,17 +9,22 @@ with import ; # ./justdoit.nix { + environment.systemPackages = [ (pkgs.writeScriptBin "network-setup" '' + #!/bin/sh + ip addr add 178.254.30.202/255.255.252.0 dev ens3 + ip route add default via 178.254.28.1 + echo nameserver 1.1.1.1 > /etc/resolv.conf + '')]; kexec.justdoit = { - # bootSize = 512; - rootDevice = "/dev/sdb"; - swapSize = 1024; + bootSize = 512; + rootDevice = "/dev/vda"; bootType = "vfat"; - luksEncrypt = true; - uefi = true; + luksEncrypt = false; + uefi = false; }; } ]; - boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + # boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; # TODO: NIX_PATH and nix.nixPath are being set by default.nix right now # cd ~/stockholm ; nix-build -A config.system.build.isoImage -I nixos-config=makefu/1systems/iso/config.nix -I secrets=/home/makefu/secrets/iso /var/src/nixpkgs/nixos #krebs.build.host = { cores = 0; }; @@ -33,7 +38,6 @@ with import ; EDITOR=vim ''; # iso-specific - boot.kernelParams = [ "copytoram" ]; services.openssh = { enable = true; hostKeys = [ diff --git a/makefu/1systems/iso/justdoit.nix b/makefu/1systems/iso/justdoit.nix index 7947953f9..0ce90494b 100644 --- a/makefu/1systems/iso/justdoit.nix +++ b/makefu/1systems/iso/justdoit.nix @@ -67,29 +67,22 @@ in { unit: sectors ${lib.optionalString (cfg.bootType != "zfs") "1 : size=${toString (2048 * cfg.bootSize)}, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"} ${lib.optionalString (! cfg.uefi) "4 : size=4096, type=21686148-6449-6E6F-744E-656564454649"} - 2 : size=${toString (2048 * cfg.swapSize)}, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F - 3 : type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 + 2 : type=0FC63DAF-8483-4772-8E79-3D69D8477DE4 EOF ${if cfg.luksEncrypt then '' cryptsetup luksFormat ${cfg.rootDevice}${x}2 - cryptsetup open --type luks ${cfg.rootDevice}${x}2 swap - cryptsetup luksFormat ${cfg.rootDevice}${x}3 - cryptsetup open --type luks ${cfg.rootDevice}${x}3 root + cryptsetup open --type luks ${cfg.rootDevice}${x}2 root export ROOT_DEVICE=/dev/mapper/root - export SWAP_DEVICE=/dev/mapper/swap '' else '' - export ROOT_DEVICE=${cfg.rootDevice}${x}3 - export SWAP_DEVICE=${cfg.rootDevice}${x}2 + export ROOT_DEVICE=${cfg.rootDevice}${x}2 ''} ${lib.optionalString (cfg.bootType != "zfs") "export NIXOS_BOOT=${cfg.rootDevice}${x}1"} mkdir -p /mnt ${mkBootTable.${cfg.bootType}} - mkswap $SWAP_DEVICE -L NIXOS_SWAP zpool create -o ashift=12 -o altroot=/mnt ${cfg.poolName} $ROOT_DEVICE zfs create -o mountpoint=legacy ${cfg.poolName}/root zfs create -o mountpoint=legacy ${cfg.poolName}/home zfs create -o mountpoint=legacy ${cfg.poolName}/nix - swapon $SWAP_DEVICE mount -t zfs ${cfg.poolName}/root /mnt/ mkdir /mnt/{home,nix,boot} mount -t zfs ${cfg.poolName}/home /mnt/home/ @@ -111,8 +104,7 @@ in { networking.hostId = "$hostId"; # required for zfs use ${lib.optionalString cfg.luksEncrypt '' boot.initrd.luks.devices = [ - { name = "swap"; device = "${cfg.rootDevice}${x}2"; preLVM = true; } - { name = "root"; device = "${cfg.rootDevice}${x}3"; preLVM = true; } + { name = "root"; device = "${cfg.rootDevice}${x}2"; preLVM = true; } ]; ''} } @@ -120,9 +112,9 @@ in { nixos-install umount /mnt/home /mnt/nix ${lib.optionalString (cfg.bootType != "zfs") "/mnt/boot"} /mnt zpool export ${cfg.poolName} - swapoff $SWAP_DEVICE ''; environment.systemPackages = [ config.system.build.justdoit ]; boot.supportedFilesystems = [ "zfs" ]; + users.users.root.openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCl3RTOHd5DLiVeUbUr/GSiKoRWknXQnbkIf+uNiFO+XxiqZVojPlumQUVhasY8UzDzj9tSDruUKXpjut50FhIO5UFAgsBeMJyoZbgY/+R+QKU00Q19+IiUtxeFol/9dCO+F4o937MC0OpAC10LbOXN/9SYIXueYk3pJxIycXwUqhYmyEqtDdVh9Rx32LBVqlBoXRHpNGPLiswV2qNe0b5p919IGcslzf1XoUzfE3a3yjk/XbWh/59xnl4V7Oe7+iQheFxOT6rFA30WYwEygs5As//ZYtxvnn0gA02gOnXJsNjOW9irlxOUeP7IOU6Ye3WRKFRR0+7PS+w8IJLag2xb" ]; }; } diff --git a/makefu/1systems/iso/target-config.nix b/makefu/1systems/iso/target-config.nix index 6915e4137..59d2960bc 100644 --- a/makefu/1systems/iso/target-config.nix +++ b/makefu/1systems/iso/target-config.nix @@ -1,12 +1,12 @@ -{ lib, ... }: +{ pkgs, lib, ... }: { imports = [ ./hardware-configuration.nix ./generated.nix ]; boot.loader.grub.enable = true; boot.loader.grub.version = 2; boot.zfs.devNodes = "/dev"; # fixes some virtualmachine issues - boot.zfs.forceImportRoot = false; - boot.zfs.forceImportAll = false; + #boot.zfs.forceImportRoot = false; + #boot.zfs.forceImportAll = false; boot.kernelParams = [ "boot.shell_on_fail" "panic=30" "boot.panic_on_fail" # reboot the machine upon fatal boot issues @@ -18,8 +18,15 @@ SystemMaxUse=1G RuntimeMaxUse=128M ''; + environment.systemPackages = [ (pkgs.writeScriptBin "network-setup" '' + #!/bin/sh + ip addr add 178.254.30.202/255.255.252.0 dev ens3 + ip route add default via 178.254.28.1 + echo nameserver 1.1.1.1 > /etc/resolv.conf + '')]; # minimal + boot.supportedFilesystems = [ "zfs" ]; programs.command-not-found.enable = false; time.timeZone = "Europe/Berlin"; programs.ssh.startAgent = false; @@ -36,5 +43,4 @@ "net.ipv6.conf.all.use_tempaddr" = lib.mkDefault "2"; "net.ipv6.conf.default.use_tempaddr" = lib.mkDefault "2"; }; - services.nscd.enable = false; } -- cgit v1.2.3 From 4218846220e75b7e3905d151f52e545743e4d7a9 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 May 2022 12:57:33 +0200 Subject: ma latte: move owncloud to hetzner --- makefu/1systems/latte/config.nix | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/makefu/1systems/latte/config.nix b/makefu/1systems/latte/config.nix index 2828aea08..69e401d97 100644 --- a/makefu/1systems/latte/config.nix +++ b/makefu/1systems/latte/config.nix @@ -34,20 +34,11 @@ in { # Services: - + + # torrent is managed by gum + # + ## Web - - - ### Moving owncloud data dir to /media/cloud/nextcloud-data - { - users.users.nextcloud.extraGroups = [ "download" ]; - # nextcloud-setup fails as it cannot set permissions for nextcloud - systemd.services.nextcloud-setup.serviceConfig.SuccessExitStatus = "0 1"; - fileSystems."/var/lib/nextcloud/data" = { - device = "/media/cloud/nextcloud-data"; - options = [ "bind" ]; - }; - } # local usage: -- cgit v1.2.3 From 2ec9de5aba1afc57f3ff7600316e9fc1c4b151f3 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 30 May 2022 12:57:52 +0200 Subject: ma x.r: enable zfs crub --- makefu/1systems/x/config.nix | 1 - makefu/1systems/x/source.nix | 1 + makefu/1systems/x/x13/default.nix | 1 + makefu/1systems/x/x13/zfs.nix | 3 ++- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/makefu/1systems/x/config.nix b/makefu/1systems/x/config.nix index 4f5fe44b5..a4aa0cbab 100644 --- a/makefu/1systems/x/config.nix +++ b/makefu/1systems/x/config.nix @@ -26,7 +26,6 @@ - # # base diff --git a/makefu/1systems/x/source.nix b/makefu/1systems/x/source.nix index 050fd39f7..05b74a014 100644 --- a/makefu/1systems/x/source.nix +++ b/makefu/1systems/x/source.nix @@ -7,5 +7,6 @@ mic92 = true; clever_kexec = true; home-manager = true; + nix-ld = true; # torrent = true; } diff --git a/makefu/1systems/x/x13/default.nix b/makefu/1systems/x/x13/default.nix index 9a407a575..7e9f4a6ac 100644 --- a/makefu/1systems/x/x13/default.nix +++ b/makefu/1systems/x/x13/default.nix @@ -28,6 +28,7 @@ environment.variables.VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/amd_icd64.json"; + services.fwupd.enable = true; programs.light.enable = true; diff --git a/makefu/1systems/x/x13/zfs.nix b/makefu/1systems/x/x13/zfs.nix index d6b99df41..ba341ef50 100644 --- a/makefu/1systems/x/x13/zfs.nix +++ b/makefu/1systems/x/x13/zfs.nix @@ -29,5 +29,6 @@ fsType = "zfs"; }; - swapDevices = [ ]; + swapDevices = [ ]; + services.zfs.autoScrub.enable = true; } -- cgit v1.2.3 From 54869b752d3f5724679f84ed6f0896a03c578ab5 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:06:43 +0200 Subject: ma tools: youtube-dl -> ty-dlp, add more dev --- makefu/2configs/tools/dev.nix | 4 ++++ makefu/2configs/tools/media.nix | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index 918d950f2..66bc9a0e6 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -38,6 +38,10 @@ ovh-zone gen-oath-safe cdrtools + unrar + ffmpeg + dnsutils + # network related sshuttle pciutils diff --git a/makefu/2configs/tools/media.nix b/makefu/2configs/tools/media.nix index 14e782e3f..255d1c51a 100644 --- a/makefu/2configs/tools/media.nix +++ b/makefu/2configs/tools/media.nix @@ -13,7 +13,7 @@ plowshare streamripper - youtube-dl + yt-dlp pulseeffects-legacy # for pulse ]; -- cgit v1.2.3 From 2047429a2e858c438c5b81508910ae9d195e0301 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:07:52 +0200 Subject: ma ham: reenabel giesskanne --- makefu/2configs/home/ham/automation/check-in.nix | 13 ++- makefu/2configs/home/ham/automation/flurlicht.nix | 85 ++++++++-------- makefu/2configs/home/ham/automation/giesskanne.nix | 45 ++++----- makefu/2configs/home/ham/automation/urlaub.nix | 26 +++-- makefu/2configs/home/ham/default.nix | 17 ++-- makefu/2configs/home/ham/light/tint_wohnzimmer.nix | 15 +-- .../home/ham/media/remote_sound_arbeitszimmer.nix | 107 +++++++++++++++++++++ makefu/2configs/home/ham/media/sonos.nix | 1 + makefu/2configs/home/ham/person/default.nix | 20 ++++ 9 files changed, 240 insertions(+), 89 deletions(-) create mode 100644 makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix create mode 100644 makefu/2configs/home/ham/person/default.nix diff --git a/makefu/2configs/home/ham/automation/check-in.nix b/makefu/2configs/home/ham/automation/check-in.nix index 21040b409..3a7ebe9ac 100644 --- a/makefu/2configs/home/ham/automation/check-in.nix +++ b/makefu/2configs/home/ham/automation/check-in.nix @@ -3,7 +3,7 @@ let light = "light.arbeitszimmer_onebutton_led"; at_work = "input_boolean.felix_at_work"; lib = import ../lib; - say = lib.say.living_room; + say = lib.say.office; in { services.home-assistant.config.input_boolean.felix_at_work.name = "Felix auf Arbeit"; @@ -37,7 +37,16 @@ in { service = "homeassistant.turn_on"; entity_id = at_work; } - ] ++ (say "Willkommen auf Arbeit"); + ] ++ (say "Willkommen auf Arbeit") ++ + [ + { service = "media_player.play_media"; + data = { + media_content_id = "https://radio.lassul.us/radio.mp3"; + media_content_type = "music"; + }; + target.entity_id = "media_player.office"; + } + ]; } { conditions = { diff --git a/makefu/2configs/home/ham/automation/flurlicht.nix b/makefu/2configs/home/ham/automation/flurlicht.nix index c26f7e3e0..aa62ab9e4 100644 --- a/makefu/2configs/home/ham/automation/flurlicht.nix +++ b/makefu/2configs/home/ham/automation/flurlicht.nix @@ -1,56 +1,57 @@ let - licht = [ "light.flur_statuslight" "light.wohnzimmer_status_led" ]; - kehrwoche_color = [ 204 0 255 ]; # pink - nachtlicht_color = [ 255 190 0 ]; # ein dunkles rot + nachtlicht = [ "light.flur_statuslight" "light.wohnzimmer_status_led" ]; + + # flurlicht an + lightcond = name: conditions: rgb_color: brightness: + { + inherit conditions; + sequence = { + service = "light.turn_on"; + target.entity_id = nachtlicht; + data = { + inherit rgb_color brightness; + }; + }; + }; in { services.home-assistant.config.automation = [ - { alias = "Nachtlicht im Flur an"; - trigger = { - platform = "sun"; - event = "sunset"; - }; - action = - [ - { - service = "light.turn_on"; - target.entity_id = licht; - data = { - brightness = 87; - rgb_color = nachtlicht_color; - #effect = "None"; - }; + { alias = "Nachtlicht trigger"; + trigger = [ + { platform = "sun"; event = "sunset"; } + { platform = "sun"; event = "sunrise"; } + { platform = "state"; entity_id = [ + "calendar.kehrwoche_kehrwoche" + "binary_sensor.badezimmer_fenster_contact" + "binary_sensor.dusche_fenster_contact" + ]; } ]; - } - { alias = "Nachtlicht in Flur aus, Kehrwoche an"; - trigger = { - platform = "sun"; - event = "sunrise"; - }; action = [ { choose = [ - { - conditions = { - condition = "state"; - entity_id = "calendar.kehrwoche_kehrwoche"; - state = "on"; - }; - sequence = { - service = "light.turn_on"; - target.entity_id = licht; - data = { - brightness = 190; - rgb_color = kehrwoche_color; # pink - }; - }; - }]; + (lightcond "Badezimmer Fenster Auf" + { condition = "state"; entity_id = "binary_sensor.badezimmer_fenster_contact"; state = "on"; } + [ 64 207 255 ] 255 # helblau + ) + (lightcond "Duschenster auf" + { condition = "state"; entity_id = "binary_sensor.dusche_fenster_contact"; state = "on"; } + [ 64 207 255 ] 255 # helblau + ) + (lightcond "Nachtlicht" + { condition = "state"; entity_id = "sun.sun"; state = "below_horizon"; } + [ 255 190 0 ] 90 # red + ) + (lightcond "Kehrwoche" + { condition = "state"; entity_id = "calendar.kehrwoche_kehrwoche"; state = "on"; } + [ 204 0 255 ] 128 # pink + ) + ]; default = { - service = "light.turn_off"; - entity_id = licht; - }; + service = "light.turn_off"; + entity_id = nachtlicht; + }; } ]; } diff --git a/makefu/2configs/home/ham/automation/giesskanne.nix b/makefu/2configs/home/ham/automation/giesskanne.nix index b11fd9d52..400e553e8 100644 --- a/makefu/2configs/home/ham/automation/giesskanne.nix +++ b/makefu/2configs/home/ham/automation/giesskanne.nix @@ -7,8 +7,10 @@ let light = "light.espcam_02_light"; seconds = 90; # default shutoff to protect the LED from burning out }; - seconds = 70; # time for giesskanne + seconds = 60*5; # time for giesskanne - 5 minutes pump = "switch.arbeitszimmer_giesskanne_relay"; + light = "switch.terrasse_plug_relay"; + # sensor = "sensor.statistics_for_sensor_crafting_brotbox_soil_moisture"; in { @@ -26,56 +28,51 @@ in [ ##### brotbox - { alias = "Water the plant for ${toString seconds} seconds"; + { alias = "Water the plant for ${toString seconds} seconds and turn on the light"; trigger = [ { # trigger at 23:15 no matter what # TODO: retry or run only if switch.wasser is available - platform = "time"; - at = "23:15:00"; + platform = "sun"; + event = "sunrise"; } ]; action = [ - { # take a snapshot before watering - service = "homeassistant.turn_on"; - entity_id = [ cam.light ]; - } - { # TODO: we could also create a recording with camera.record - service = "camera.snapshot"; - data = { - entity_id = cam.camera; - # TODO: create /var/lib/hass/cam/ - now being done manually - filename = "/var/lib/hass/cam/${cam.name}_{{ now().strftime('%Y%m%d-%H%M%S') }}.jpg"; - }; - } { # now turn on the pumping services # i do not start hte pump and light before the snapshot because i do # not know how long it takes (do not want to water the plants for too long) service = "homeassistant.turn_on"; - entity_id = [ pump ]; + entity_id = [ pump light ]; } { delay.seconds = seconds; } { service = "homeassistant.turn_off"; entity_id = [ pump cam.light ]; } + { # TODO: we could also create a recording with camera.record + service = "camera.snapshot"; + data = { + entity_id = cam.camera; + # TODO: create /var/lib/hass/cam/ - now being done manually + filename = "/var/lib/hass/cam/${cam.name}_{{ now().strftime('%Y%m%d-%H%M%S') }}.jpg"; + }; + } ]; } - { alias = "Always turn off the light after ${toString (cam.seconds)}s"; + { alias = "Turn off the light at sunset"; trigger = [ { - platform = "state"; - entity_id = cam.light; - to = "on"; - for.seconds = cam.seconds; + platform = "sun"; + event = "sunset"; + # offset = "+02:00:00"; } ]; action = [ { service = "homeassistant.turn_off"; - entity_id = [ pump cam.light ]; + entity_id = [ light ]; } ]; } @@ -93,7 +90,7 @@ in [ { service = "homeassistant.turn_off"; - entity_id = [ pump cam.light ]; + entity_id = [ pump ]; } ]; } diff --git a/makefu/2configs/home/ham/automation/urlaub.nix b/makefu/2configs/home/ham/automation/urlaub.nix index 50294514c..c11c589cf 100644 --- a/makefu/2configs/home/ham/automation/urlaub.nix +++ b/makefu/2configs/home/ham/automation/urlaub.nix @@ -7,12 +7,26 @@ let schranklicht = "light.wohnzimmer_schrank_osram"; weihnachtslicht = "light.wohnzimmer_fenster_lichterkette_licht"; fernsehlicht = "light.wled"; + + all_lights = [ + schranklicht weihnachtslicht fernsehlicht + # extra lights to also turn off + # wohnzimmer + "light.wohnzimmer_komode_osram" + "light.wohnzimmer_stehlampe_osram" + # arbeitszimmer + "light.wled_4" + "light.arbeitszimmer_schrank_dimmer" + "light.arbeitszimmer_pflanzenlicht" + ]; + final_off = "00:37"; - turn_on = entity_id: at: - { alias = "Turn on ${entity_id} at ${at}"; + turn_on = entity_id: offset: + # negative offset => before sunset + { alias = "Turn on ${entity_id} at sunset ${offset}"; trigger = [ - { platform = "time"; inherit at; } + { platform = "sun"; event = "sunset"; inherit offset; } ]; action = [ @@ -25,9 +39,9 @@ in { automation = [ - (turn_on schranklicht "17:30") - (turn_on weihnachtslicht "17:30") - (turn_on fernsehlicht "19:00") + (turn_on schranklicht "-00:30:00") + #(turn_on weihnachtslicht "-00:30:00") + (turn_on fernsehlicht "-00:00:00") { alias = "Always turn off the urlaub lights at ${final_off}"; trigger = [ diff --git a/makefu/2configs/home/ham/default.nix b/makefu/2configs/home/ham/default.nix index b9701f129..31e7ba419 100644 --- a/makefu/2configs/home/ham/default.nix +++ b/makefu/2configs/home/ham/default.nix @@ -31,15 +31,16 @@ in { ./media/firetv.nix ./media/sonos.nix ./media/remote_sound_wohnzimmer.nix + ./media/remote_sound_arbeitszimmer.nix ./automation/check-in.nix ./automation/fenster_auf.nix ./automation/firetv_restart.nix ./automation/light_buttons.nix ./automation/wohnzimmer_rf_fernbedienung.nix - ./automation/ladestecker_timer.nix + # ./automation/ladestecker_timer.nix ./automation/flurlicht.nix - #./automation/giesskanne.nix + ./automation/giesskanne.nix ./automation/pflanzen_giessen_erinnerung.nix ./automation/urlaub.nix ./automation/moodlight.nix @@ -59,7 +60,7 @@ in { extraPackages = p: [ (p.callPackage ./deps/dwdwfsapi.nix {}) (p.callPackage ./signal-rest/pkg.nix {}) - #(p.callPackage ./deps/pykodi.nix {}) + (p.callPackage ./deps/pykodi.nix {}) ]; }; @@ -141,11 +142,11 @@ in { retain = true; }; }; - luftdaten = { - show_on_map = true; - sensor_id = 10529; - sensors.monitored_conditions = [ "P1" "P2" ]; - }; + #luftdaten = { + # show_on_map = true; + # sensor_id = 10529; + # sensors.monitored_conditions = [ "P1" "P2" ]; + #}; #binary_sensor = # flurlicht.binary_sensor; diff --git a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix index fd87cf064..474bf5c99 100644 --- a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix +++ b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix @@ -25,19 +25,20 @@ let default_scene_1 = "Solid"; default_color_1 = "Default"; main_color_select_1 = "select.wled_color_palette"; - light_group_1.entity_id = [ - main_light_1 - ]; + light_group_1.entity_id = [ + main_light_1 + ]; # contains only the actually changeable lights - light_group_2.entity_id = [ + light_group_2 = { entity_id = [ "light.wohnzimmer_komode_osram" "light.wohnzimmer_schrank_osram" "light.wohnzimmer_fenster_lichterkette_licht" - ]; - light_group_3.entity_id = [ + ]; + }; + light_group_3 = { entity_id = [ "light.wohnzimmer_stehlampe_osram" - ]; + ]; }; statecond = cond: { # cond must be a list condition = "template"; diff --git a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix new file mode 100644 index 000000000..f59f022f4 --- /dev/null +++ b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix @@ -0,0 +1,107 @@ +{ lib, ...}: +let + statecond = cond: { # cond must be a list + condition = "template"; + value_template = "{{ trigger.to_state.state in ( " + + (lib.concatMapStringsSep "," (x: "'${x}'") cond) + ") }}"; + }; + vol_change = 0.030; + + max_repeat = "30"; # max loops to repeat before bailing out + remote = "sensor.arbeitszimmer_sound1_action"; + player = "media_player.office"; + last_state_sensor_name = "last_rotation_action_arbeitszimmer"; + last_state_sensor = "input_text.${last_state_sensor_name}"; + # - service: media_player.volume_set + # target: + # entity_id: media_player.kitchen + # data: + # volume_level: {{ state_attr('media_player.kitchen', 'volume_level') + 0.02 }} + rotate_stop = "brightness_stop"; + rotate_right = "brightness_move_up"; + rotate_left = "brightness_move_down" ; + + single_click = "toggle"; + double_click = "brightness_step_up"; + triple_click = "brightness_step_down"; +in { + services.home-assistant.config.input_text."${last_state_sensor_name}".name = "Last action of the arbeitszimmer"; + services.home-assistant.config.automation = [ + { + trigger = { + platform = "state"; + entity_id = remote; + to = [ rotate_stop ]; + }; + action = [ + { service = "input_text.set_value"; + target.entity_id = last_state_sensor; + data.value = "stop"; + } + ]; + } + { + alias = "Perform Actions with ${remote}"; + trigger = { + platform = "state"; + entity_id = remote; + to = [ single_click double_click triple_click rotate_left rotate_right ]; + }; + #mode = "queued"; + #max = 5; + mode = "single"; + #max_exceeded = "silent"; + action = [ + { + choose = [ + { + conditions = statecond [ single_click ]; + sequence = [ + { service = "media_player.media_play_pause"; + target.entity_id = player; + } + ]; + } + { + conditions = statecond [ rotate_left rotate_right ]; + sequence = let + vol_up = toString vol_change; + vol_down = toString (-1 * vol_change); + in [ + { + variables.nextvol = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} ${vol_down} {% else -%} ${vol_up} {% endif -%}''; + variables.state = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} left {% else -%} right {% endif -%}''; + } + { service = "input_text.set_value"; + target.entity_id = last_state_sensor; + data.value = ''{{ state }}''; + } + { + repeat = { + sequence = [ + { service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") + (nextvol|float) }}''; + } + { delay.milliseconds = "150"; } + ]; + while = [ + { + condition = "template"; + value_template = ''{{ states("${last_state_sensor}") == state }}''; + } + { + condition = "template"; + value_template = "{{ repeat.index <= ${max_repeat}}}"; + } + ]; + }; + } + ]; + } + ]; + } + ]; + } + ]; +} diff --git a/makefu/2configs/home/ham/media/sonos.nix b/makefu/2configs/home/ham/media/sonos.nix index 5b9694512..40dcfc3ca 100644 --- a/makefu/2configs/home/ham/media/sonos.nix +++ b/makefu/2configs/home/ham/media/sonos.nix @@ -2,6 +2,7 @@ services.home-assistant.config.sonos.media_player.hosts = [ "192.168.111.30" "192.168.111.31" + "192.168.111.32" ]; } diff --git a/makefu/2configs/home/ham/person/default.nix b/makefu/2configs/home/ham/person/default.nix new file mode 100644 index 000000000..a72f610e8 --- /dev/null +++ b/makefu/2configs/home/ham/person/default.nix @@ -0,0 +1,20 @@ +{config, ... }: +{ + services.home-assistant.config.person = [ + { + name = "Felix"; + id = 1; + device_trackers = [ + "device_tracker.felix_phone" + "device_tracker.x" + ]; + } + { + name = "Misa"; + id = 2; + device_trackers = [ + "device_tracker.misa_phone" + ]; + } + ]; +} -- cgit v1.2.3 From 08732ec608af2f6e0c07d1fd33ed70caff488470 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:08:21 +0200 Subject: ma ham/music: move folders --- makefu/2configs/home/music.nix | 2 +- makefu/2configs/home/tonie.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/makefu/2configs/home/music.nix b/makefu/2configs/home/music.nix index 59f6d9170..7f5a425d2 100644 --- a/makefu/2configs/home/music.nix +++ b/makefu/2configs/home/music.nix @@ -6,7 +6,7 @@ in { services.navidrome.enable = true; services.navidrome.settings = { - MusicFolder = "/media/cryptX/music"; + MusicFolder = "/media/cryptX/music/kinder"; Address = "0.0.0.0"; }; diff --git a/makefu/2configs/home/tonie.nix b/makefu/2configs/home/tonie.nix index 959e48e8b..bc3633a88 100644 --- a/makefu/2configs/home/tonie.nix +++ b/makefu/2configs/home/tonie.nix @@ -4,8 +4,8 @@ let #host = config.networking.hostName; ident = 998; user = "${toString ident}:${toString ident}"; - #backend_host = "tonie.lan"; - backend_host = "tonie.omo.r"; + backend_host = "tonie.lan"; + #backend_host = "tonie.omo.r"; frontend_port = 30006; homedir = "/var/lib/tonies"; albumdir = "${homedir}/albumart/"; -- cgit v1.2.3 From b0fcf41a824695a8d91f8355f94cba0523991837 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:08:36 +0200 Subject: ma home: init jellyfin --- makefu/2configs/home/jellyfin.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 makefu/2configs/home/jellyfin.nix diff --git a/makefu/2configs/home/jellyfin.nix b/makefu/2configs/home/jellyfin.nix new file mode 100644 index 000000000..672a483e5 --- /dev/null +++ b/makefu/2configs/home/jellyfin.nix @@ -0,0 +1,10 @@ +{ lib, config, ... }: +{ + services.jellyfin.enable = true; + services.jellyfin.openFirewall = true; + #users.users.${config.services.jellyfin.user}.extraGroups = [ "download" "video" "render" ]; + state = [ "/var/lib/jellyfin" ]; + systemd.services.jellyfin.serviceConfig.PrivateDevices = lib.mkForce false; + systemd.services.jellyfin.serviceConfig.DeviceAllow = lib.mkForce ["char-drm rwm" "char-nvidia-frontend" "char-nvidia-uvm"]; + systemd.services.jellyfin.serviceConfig.SupplementaryGroups = [ "video" "render" "download" ]; +} -- cgit v1.2.3 From 67693d4eb4d492811069c32e6ed4e57854163beb Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:12:52 +0200 Subject: ma bgt: move storedir to hetzner cloud, fix for old ssh client --- makefu/2configs/bgt/download.binaergewitter.de.nix | 15 +++++++++++++++ makefu/2configs/bgt/template.md | 14 ++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index 6ce0606a8..1cf21f213 100644 --- a/makefu/2configs/bgt/download.binaergewitter.de.nix +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -5,22 +5,37 @@ let ident = (builtins.readFile ./auphonic.pub); bgtaccess = "/var/spool/nginx/logs/binaergewitter.access.log"; bgterror = "/var/spool/nginx/logs/binaergewitter.error.log"; + + # TODO: only when the data is stored somewhere else + wwwdir = "/var/www/binaergewitter"; + storedir = "/media/cloud/www/binaergewitter"; in { + fileSystems."${wwwdir}" = { + device = storedir; + options = [ "bind" ]; + }; + services.openssh = { allowSFTP = true; sftpFlags = [ "-l VERBOSE" ]; extraConfig = '' + HostkeyAlgorithms +ssh-rsa + Match User auphonic ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no PasswordAuthentication no + PubkeyAcceptedAlgorithms +ssh-rsa + ''; }; users.users.auphonic = { uid = genid "auphonic"; group = "nginx"; + # for storedir + extraGroups = [ "download" ]; useDefaultShell = true; isSystemUser = true; openssh.authorizedKeys.keys = [ ident config.krebs.users.makefu.pubkey ]; diff --git a/makefu/2configs/bgt/template.md b/makefu/2configs/bgt/template.md index fdc0e2585..8413e0b8b 100644 --- a/makefu/2configs/bgt/template.md +++ b/makefu/2configs/bgt/template.md @@ -1,31 +1,25 @@ # -0. Sendung twittern und mastodieren (eine Woche + eine Stunde vorher) (wichtig) +0. Sendung twittern und mastodieren (eine Woche + eine Stunde vorher) von Ingo/l33tname (wichtig) 1. `eine` Person anrufen (den Host): - markus 162dcbf89f@studio.link - Felix1 makefu@studio.link - L33tFelix l33tname@studio.link - Ingo ingo@studio.link -2. Jitis an machen! https://meet.jit.cloud/bgt (mittel) -3. studio-link aufnehmen drücken, schauen ob file local.flac größer wird (wichtig) +2. Jitis an machen https://meet.ffmuc.net/bgt (mittel) +3. studio-link aufnehmen drücken (wichtig) 4. audiocity starten, 48000Hz einstellen, Audio-Device checken und aufnehmen drücken (wichtig) 4. alternative parecord: `$ pacmd list-sources | grep -e device.string -e 'name:' # keins der "monitor" devices` `$ parecord --channels=1 -d alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo bgt.wav` 5. darkice starten (wichtig) -5. chapter-marker starten (wichtig) +6. Ingo daran erinnern, dass er die Überschriften richtig aussprechen muss 7. klatschen 8. Hallihallo und Herzlich Willkommen -9. ctrl-u auf "H" von "Halli" Felix auf jeden fall erinnern (wichtig) -10. Ctrl-j drücken für neuen Eintrag - ggf. Felix erinnern (wichtig) ## Vorschläge ### Backlog von Picks und Lesefoo aus der letzten Woche -die Nachfolgenden 3 Striche sind sehr wichtig, bitte nicht löschen. Nachdem -chapter-marker gestartet wurde kann die reihenfolge nicht mer angepasst werden, -das ist der preis, den man zahlt - --- ## Blast from the Past -- cgit v1.2.3 From 37006c21985e64e8835084c7a6792ed39c2e6661 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:15:49 +0200 Subject: ma services: ensure state is backed up --- makefu/2configs/bitlbee.nix | 3 ++- makefu/2configs/bitwarden.nix | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/makefu/2configs/bitlbee.nix b/makefu/2configs/bitlbee.nix index e955384d6..52b5d68a5 100644 --- a/makefu/2configs/bitlbee.nix +++ b/makefu/2configs/bitlbee.nix @@ -1,8 +1,9 @@ {pkgs, ... }: -# state: /var/lib/bitlbee { services.bitlbee = { enable = true; libpurple_plugins = [ pkgs.telegram-purple pkgs.pidgin-skypeweb]; }; + users.users.makefu.packages = with pkgs; [ weechat tmux ]; + state = [ "/var/lib/bitlbee" ]; } diff --git a/makefu/2configs/bitwarden.nix b/makefu/2configs/bitwarden.nix index 92c1c4e0e..cc742511c 100644 --- a/makefu/2configs/bitwarden.nix +++ b/makefu/2configs/bitwarden.nix @@ -23,6 +23,11 @@ in { { name = "vaultwarden"; ensurePermissions."DATABASE bitwarden" = "ALL PRIVILEGES"; } ]; }; + services.postgresqlBackup = { + enable = true; + databases = [ "bitwarden" "vaultwarden" ]; + }; + services.nginx.virtualHosts."bw.euer.krebsco.de" ={ forceSSL = true; -- cgit v1.2.3 From 43486ea6d8f2784a36616313675bd06ce433ccc1 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 6 Jun 2022 21:16:30 +0200 Subject: ma bureautomation: home-assistant is now user-controlled --- makefu/2configs/bureautomation/comic-updater.nix | 5 +- makefu/2configs/bureautomation/default.nix | 320 ++++++++++++----------- makefu/2configs/gui/wbob-kiosk.nix | 12 +- 3 files changed, 181 insertions(+), 156 deletions(-) diff --git a/makefu/2configs/bureautomation/comic-updater.nix b/makefu/2configs/bureautomation/comic-updater.nix index 1e2440939..5804d66d2 100644 --- a/makefu/2configs/bureautomation/comic-updater.nix +++ b/makefu/2configs/bureautomation/comic-updater.nix @@ -11,8 +11,9 @@ in { path = with pkgs; [ wget xmlstarlet ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { - User = "hass"; - WorkingDirectory = config.services.home-assistant.configDir; + # User = "hass"; + #WorkingDirectory = config.services.home-assistant.configDir; + WorkingDirectory = "/var/lib/homeassistant-docker"; ExecStart = pkgs.writeDash "update-comics" '' set -euf mkdir -p www/ diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix index 46bf05963..44690271d 100644 --- a/makefu/2configs/bureautomation/default.nix +++ b/makefu/2configs/bureautomation/default.nix @@ -2,6 +2,7 @@ let kodi-host = "192.168.8.11"; unstable = import {}; + confdir = "/var/lib/homeassistant-docker"; in { imports = [ ./ota.nix @@ -13,169 +14,188 @@ in { # hass config ## complex configs # ./multi/daily-standup.nix - ./multi/aramark.nix - ./multi/matrix.nix - ./multi/frosch.nix - ./multi/mittagessen.nix - ./multi/10h_timers.nix + #./multi/aramark.nix + #./multi/matrix.nix + #./multi/frosch.nix + #./multi/mittagessen.nix + #./multi/10h_timers.nix - ./switch/tasmota_switch.nix - ./switch/rfbridge.nix + #./switch/tasmota_switch.nix + #./switch/rfbridge.nix - ./light/statuslight.nix - ./light/buzzer.nix + #./light/statuslight.nix + #./light/buzzer.nix - ./script/multi_blink.nix + #./script/multi_blink.nix - ./binary_sensor/buttons.nix - ./binary_sensor/motion.nix + #./binary_sensor/buttons.nix + #./binary_sensor/motion.nix - # ./sensor/pollen.nix requires dwd_pollen - ./sensor/espeasy.nix - ./sensor/airquality.nix - ./sensor/outside.nix - ./sensor/tasmota_firmware.nix + ## ./sensor/pollen.nix requires dwd_pollen + #./sensor/espeasy.nix + #./sensor/airquality.nix + #./sensor/outside.nix + #./sensor/tasmota_firmware.nix - ./camera/verkehrskamera.nix - ./camera/comic.nix - ./camera/stuttgart.nix - ./automation/bureau-shutdown.nix - ./automation/nachtlicht.nix - ./automation/schlechteluft.nix - ./automation/philosophische-tuer.nix - ./automation/hass-restart.nix - ./device_tracker/openwrt.nix - ./person/team.nix + #./camera/verkehrskamera.nix + #./camera/comic.nix + #./camera/stuttgart.nix + #./automation/bureau-shutdown.nix + #./automation/nachtlicht.nix + #./automation/schlechteluft.nix + #./automation/philosophische-tuer.nix + #./automation/hass-restart.nix + #./device_tracker/openwrt.nix + #./person/team.nix ]; networking.firewall.allowedTCPPorts = [ 8123 ]; state = [ "/var/lib/hass/known_devices.yaml" ]; - - services.home-assistant = { - enable = true; - package = (unstable.home-assistant.overrideAttrs (old: { - doInstallCheck = false; - })).override { - extraPackages = p: [ - # TODO: put somewhere else - (p.callPackage {}) - # (p.c