From c51db2b53ca9098bc800d24a909641c6c024bf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Thu, 23 Feb 2023 16:53:53 +0100 Subject: [PATCH] feat: convert inputs to flakes --- configs/default.nix | 2 +- configs/packages.nix | 24 +++- configs/traadfri.nix | 9 +- flake.lock | 206 ++++++++++++++++++++++++------ flake.nix | 17 +-- modules/traadfri.nix | 14 +- packages/rusty-jeep.nix | 31 ----- packages/scripts/default.nix | 19 --- secrets | 2 +- systems/makanek/configuration.nix | 10 +- systems/makanek/names.nix | 4 +- systems/makanek/urlwatch.nix | 19 ++- 12 files changed, 217 insertions(+), 140 deletions(-) delete mode 100644 packages/rusty-jeep.nix diff --git a/configs/default.nix b/configs/default.nix index bf9002e..4614ae8 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -265,7 +265,7 @@ in { ./sudo.nix ./themes.nix ./tmux.nix - # ./traadfri.nix + ./traadfri.nix ./unclutter.nix ./vscode.nix ./watson.nix diff --git a/configs/packages.nix b/configs/packages.nix index 66c7368..c529864 100644 --- a/configs/packages.nix +++ b/configs/packages.nix @@ -60,8 +60,6 @@ ' $out/astrolog/astrolog.as ''; }); - - recht = pkgs.callPackage inputs.recht.outPath {}; in { home-manager.users.me.home.file = { ".csl".source = cslDirectory; @@ -168,7 +166,6 @@ in { scripts.betacode # ancient greek betacode to unicode converter scripts.meteo scripts.mahlzeit - recht scripts.vimv scripts.swallow # window swallowing scripts.literature-quote @@ -190,7 +187,6 @@ in { scripts.mpv-radio # kmein.slide termdown - scripts.alarm scripts.tolino-screensaver scripts.rfc scripts.tag @@ -203,7 +199,8 @@ in { par qrencode - inputs.menstruation-backend + inputs.menstruation-backend.defaultPackage.x86_64-linux + inputs.recht.defaultPackage.x86_64-linux (pkgs.writers.writeDashBin "worldradio" '' shuf ${worldradio} | ${pkgs.findutils}/bin/xargs ${pkgs.mpv}/bin/mpv --no-video @@ -216,6 +213,23 @@ in { (pkgs.writers.writeDashBin "ncmpcpp-zaatar" ''MPD_HOST=${(import ../lib/local-network.nix).zaatar} exec ${pkgs.ncmpcpp}/bin/ncmpcpp "$@"'') (pkgs.writers.writeDashBin "mpc-zaatar" ''MPD_HOST=${(import ../lib/local-network.nix).zaatar} exec ${pkgs.mpc_cli}/bin/mpc "$@"'') + (pkgs.writers.writeDashBin "alarm" '' + set -efu + export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.bc inputs.scripts.packages.x86_64-linux.rusty-jeep]} + for i in `seq 8000 1000 10000`; do + echo $i 100 + done | rusty-jeep + echo 'if you heard that sound, then goto sleep..^_^' + + echo sleep "$@" + sleep "$@" + + echo 'wake up!' + while :; do + echo $(echo "($(od -tu -An -N 2 /dev/urandom)%1000)+500"|bc) $(echo "($(od -tu -An -N 2 /dev/urandom)%500)+100"|bc) + done | rusty-jeep 1 + '') + spotify ncspot playerctl diff --git a/configs/traadfri.nix b/configs/traadfri.nix index 0fcd71e..09c8fc1 100644 --- a/configs/traadfri.nix +++ b/configs/traadfri.nix @@ -1,12 +1,13 @@ { + config, pkgs, lib, ... }: let - inherit (import ) localAddresses; + inherit (import ../lib) localAddresses; living-room-id = 131090; in { - imports = []; + imports = [../modules/traadfri.nix]; environment.systemPackages = [ (pkgs.writers.writeDashBin "traadfri-party" '' @@ -20,11 +21,13 @@ in { '') ]; + age.secrets.traadfri-key.file = ../secrets/traadfri-key.age; + niveum.traadfri = { enable = true; user = "kmein"; host = localAddresses.tradfri; - key = lib.strings.fileContents ; + keyFile = config.age.secrets.traadfri-key.path; rooms = { corridor = 131080; kitchen = 131081; diff --git a/flake.lock b/flake.lock index 216ba88..bd3ccd9 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,22 @@ "type": "github" } }, + "blessings": { + "flake": false, + "locked": { + "lastModified": 1549397368, + "narHash": "sha256-YVIGRG+/ey4nFEZl1ZPHj7Hx/Of3rsUGnkLK4V4zZd0=", + "ref": "refs/heads/master", + "rev": "d94712a015636efe7ec79bc0a2eec6739d0be779", + "revCount": 18, + "type": "git", + "url": "https://cgit.krebsco.de/blessings" + }, + "original": { + "type": "git", + "url": "https://cgit.krebsco.de/blessings" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -133,6 +149,51 @@ "type": "github" } }, + "flake-utils_7": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_8": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_9": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -181,8 +242,6 @@ "menstruation-backend": { "inputs": { "flake-utils": [ - "menstruation-backend", - "rust-overlay", "flake-utils" ], "nixpkgs": [ @@ -256,7 +315,9 @@ }, "nixinate": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1671116920, @@ -321,22 +382,6 @@ } }, "nixpkgs_4": { - "locked": { - "lastModified": 1653060744, - "narHash": "sha256-kfRusllRumpt33J1hPV+CeCCylCXEU7e0gn2/cIM7cY=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "dfd82985c273aac6eced03625f454b334daae2e8", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_5": { "locked": { "lastModified": 1676895851, "narHash": "sha256-xdhBKw2el790G+88tZYpRWlP9VjQC9OLR5Jx84VPe08=", @@ -352,7 +397,38 @@ "type": "github" } }, + "nixpkgs_5": { + "locked": { + "lastModified": 1677158633, + "narHash": "sha256-t7za78oRkDIjdFQF0PCilfCziFyhfowCgs9Ry+sEvE4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "129b6f78121802d18d215c9f9e04d7971c58ea0c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_6": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { "locked": { "lastModified": 1659446231, "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", @@ -368,7 +444,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1665296151, "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", @@ -384,6 +460,22 @@ "type": "github" } }, + "nixpkgs_9": { + "locked": { + "lastModified": 1669418739, + "narHash": "sha256-T86oFvcUIRwHWBWUt7WjaP4BP/3lDGbv5AppQSI1FkI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "695b3515251873e0a7e2021add4bba643c56cde3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "695b3515251873e0a7e2021add4bba643c56cde3", + "type": "github" + } + }, "nur": { "locked": { "lastModified": 1677062856, @@ -400,13 +492,17 @@ } }, "recht": { - "flake": false, + "inputs": { + "blessings": "blessings", + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_5" + }, "locked": { - "lastModified": 1677161248, - "narHash": "sha256-/yEG92y5ukwjoGrw++VEnis8Qw/tW/CkcE+mA8ufjGM=", + "lastModified": 1677165419, + "narHash": "sha256-pjYpXg+09rayon6uhSNd30ryrT2zYLOlDLBHQ9pnGZg=", "owner": "kmein", "repo": "recht", - "rev": "a8a2f2a2c244ef052f54cc45149895a591da3231", + "rev": "5fa158ce21de797bd95a934dab8d4403b7531d20", "type": "github" }, "original": { @@ -439,7 +535,7 @@ "menstruation-backend": "menstruation-backend", "menstruation-telegram": "menstruation-telegram", "nixinate": "nixinate", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_4", "nur": "nur", "recht": "recht", "retiolum": "retiolum", @@ -490,7 +586,26 @@ "rust-overlay_3": { "inputs": { "flake-utils": "flake-utils_6", - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1677119371, + "narHash": "sha256-L0Da4eKzDZrsy8ysOS1lhgDjAgEqGvYGf/lXaRd5/YQ=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c67c79ea25664d66e74ae91a6fa0d6c65d12d3a7", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_4": { + "inputs": { + "flake-utils": "flake-utils_8", + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1677119371, @@ -507,13 +622,25 @@ } }, "scripts": { - "flake": false, + "inputs": { + "flake-utils": [ + "scripts", + "rust-overlay", + "flake-utils" + ], + "nixpkgs": [ + "scripts", + "rust-overlay", + "nixpkgs" + ], + "rust-overlay": "rust-overlay_3" + }, "locked": { - "lastModified": 1675238486, - "narHash": "sha256-Hs9NKK0UFaNqrui2VauBnMnV/14U3eNWaI12EmVYXWY=", + "lastModified": 1677166498, + "narHash": "sha256-az31wr2tF98+2l3SgCrIy0AcoJdN+qkTCHe2vMmBWnk=", "owner": "kmein", "repo": "scripts", - "rev": "5cefa5f112e7fe54e0302b7bc33bc06e1f762002", + "rev": "bdc2ccb7081f5b09dedccba4f8875cc1b938ef04", "type": "github" }, "original": { @@ -524,8 +651,8 @@ }, "telebots": { "inputs": { - "flake-utils": "flake-utils_5", - "nixpkgs": "nixpkgs_6" + "flake-utils": "flake-utils_7", + "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1677156381, @@ -544,14 +671,12 @@ "tinc-graph": { "inputs": { "flake-utils": [ - "tinc-graph", - "rust-overlay", "flake-utils" ], "nixpkgs": [ "nixpkgs" ], - "rust-overlay": "rust-overlay_3" + "rust-overlay": "rust-overlay_4" }, "locked": { "lastModified": 1677154877, @@ -568,13 +693,16 @@ } }, "traadfri": { - "flake": false, + "inputs": { + "flake-utils": "flake-utils_9", + "nixpkgs": "nixpkgs_9" + }, "locked": { - "lastModified": 1640451803, - "narHash": "sha256-zS/b93uFpPM9basNP7ngmm+YjYV0IUQAmNghetHA6Ss=", + "lastModified": 1677165914, + "narHash": "sha256-3N08NabgDwTUy1n5wxpT27iddFrgXW35E1x2UgAKkDQ=", "owner": "kmein", "repo": "traadfri", - "rev": "cf46bd09cd3263b90a09b0ca979aa705a4c3671c", + "rev": "11571116ed5d2c6478c615d663d1f96f57a97ba9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 85f8cb3..6e387e5 100644 --- a/flake.nix +++ b/flake.nix @@ -12,9 +12,11 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; nur.url = "github:nix-community/NUR"; recht.url = "github:kmein/recht"; + scripts.url = "github:kmein/scripts"; retiolum.url = "git+https://git.thalheim.io/Mic92/retiolum"; telebots.url = "github:kmein/telebots"; tinc-graph.url = "github:kmein/tinc-graph"; + traadfri.url = "github:kmein/traadfri"; agenix.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -22,24 +24,9 @@ krops.inputs.nixpkgs.follows = "nixpkgs"; menstruation-backend.inputs.flake-utils.follows = "flake-utils"; menstruation-backend.inputs.nixpkgs.follows = "nixpkgs"; - menstruation-telegram.inputs.flake-utils.follows = "flake-utils"; - menstruation-telegram.inputs.nixpkgs.follows = "nixpkgs"; nixinate.inputs.nixpkgs.follows = "nixpkgs"; - recht.inputs.flake-utils.follows = "flake-utils"; - recht.inputs.nixpkgs.follows = "nixpkgs"; - retiolum.inputs.nixpkgs.follows = "nixpkgs"; tinc-graph.inputs.flake-utils.follows = "flake-utils"; tinc-graph.inputs.nixpkgs.follows = "nixpkgs"; - - # legacy - scripts = { - url = "github:kmein/scripts"; - flake = false; - }; - traadfri = { - url = "github:kmein/traadfri"; - flake = false; - }; }; outputs = inputs @ { diff --git a/modules/traadfri.nix b/modules/traadfri.nix index 715ed32..3f4697f 100644 --- a/modules/traadfri.nix +++ b/modules/traadfri.nix @@ -2,19 +2,17 @@ pkgs, lib, config, + inputs, ... }: with lib; let cfg = config.niveum.traadfri; - traadfri = pkgs.callPackage { - libcoap = pkgs.callPackage {tls = true;}; - }; in { options.niveum.traadfri = { enable = mkEnableOption "Trådfri CLI"; user = mkOption {type = types.str;}; host = mkOption {type = types.str;}; - key = mkOption {type = types.str;}; + keyFile = mkOption {type = types.path;}; rooms = mkOption { type = types.attrsOf types.int; default = {}; @@ -29,10 +27,10 @@ in { environment.systemPackages = [ (pkgs.writers.writeDashBin "traadfri" '' - TRAADFRI_USER="${cfg.user}" \ - TRAADFRI_KEY="${cfg.key}" \ - TRAADFRI_HUB="${cfg.host}" \ - ${traadfri}/bin/traadfri $@ + export TRAADFRI_USER="${cfg.user}" + export TRAADFRI_KEY="$(cat ${lib.escapeShellArg cfg.keyFile})" + export TRAADFRI_HUB="${cfg.host}" + ${inputs.traadfri.defaultPackage.x86_64-linux}/bin/traadfri $@ '') ] ++ lib.mapAttrsToList (name: value: diff --git a/packages/rusty-jeep.nix b/packages/rusty-jeep.nix deleted file mode 100644 index 2cfeaa3..0000000 --- a/packages/rusty-jeep.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - lib, - fetchFromGitHub, - rustPlatform, - pkg-config, - alsa-lib, -}: -rustPlatform.buildRustPackage { - pname = "rusty-jeep"; - version = "1.0.0"; - - src = let - repo = fetchFromGitHub { - owner = "kmein"; - repo = "scripts"; - rev = "c8e80b34c08e427f83b6af19a361e8c0711a4e6c"; - sha256 = "18jlf9zkhni4jsvzrlkkllqvv5dkhjmilggcchbs32hr1km51q84"; - }; - in "${repo}/rusty-jeep"; - - nativeBuildInputs = [pkg-config]; - buildInputs = [alsa-lib]; - - cargoHash = "sha256-8qbYTqRk+4InJNX6xK95VxISamDb5KID+wbmUDJYJ94="; - - meta = with lib; { - description = "A beeping program inspired by K_belwagen"; - license = licenses.wtfpl; - maintainers = [maintainers.kmein]; - }; -} diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix index a2ccd8a..3ed102e 100644 --- a/packages/scripts/default.nix +++ b/packages/scripts/default.nix @@ -34,25 +34,6 @@ in name = "instaget"; }; - alarm = let - rusty-jeep = pkgs.callPackage ../rusty-jeep.nix {}; - in - pkgs.writers.writeDashBin "alarm" '' - export PATH=${lib.makeBinPath [pkgs.coreutils pkgs.bc rusty-jeep]} - for i in `seq 8000 1000 10000`; do - echo $i 100 - done | rusty-jeep - echo 'if you heard that sound, then goto sleep..^_^' - - echo sleep "$@" - sleep "$@" - - echo 'wake up!' - while :; do - echo $(echo "($(od -tu -An -N 2 /dev/urandom)%1000)+500"|bc) $(echo "($(od -tu -An -N 2 /dev/urandom)%500)+100"|bc) - done | rusty-jeep 1 - ''; - infschmv = pkgs.writers.writeDashBin "InfSchMV" '' ${pkgs.curl}/bin/curl -sSL https://www.berlin.de/corona/massnahmen/verordnung/ \ | ${pkgs.pup}/bin/pup .textile \ diff --git a/secrets b/secrets index c7d15a9..3221233 160000 --- a/secrets +++ b/secrets @@ -1 +1 @@ -Subproject commit c7d15a91747815e2ca9e89e8a9d52007059e2ee3 +Subproject commit 32212338c0e70bc6157634982eee7887cb0984a0 diff --git a/systems/makanek/configuration.nix b/systems/makanek/configuration.nix index d2bbe45..eee1de4 100644 --- a/systems/makanek/configuration.nix +++ b/systems/makanek/configuration.nix @@ -41,13 +41,13 @@ in { }; passwordFile = config.age.secrets.restic.path; paths = [ - "/var/lib/codimd" config.services.postgresqlBackup.location + config.services.nextcloud.home + config.services.grafana.dataDir + config.services.gitea.stateDir + config.services.weechat.root "/var/lib/weechat" - "/var/lib/nextcloud" - "/var/lib/grafana" - "/var/lib/gitea" - "/var/lib/redis" + "/var/lib/codimd" ]; }; diff --git a/systems/makanek/names.nix b/systems/makanek/names.nix index 5db9293..8c75ad6 100644 --- a/systems/makanek/names.nix +++ b/systems/makanek/names.nix @@ -5,8 +5,6 @@ ... }: let port = 5703; - onomap-src = inputs.scripts.outPath + "/onomastics-ng"; - onomap = pkgs.haskellPackages.callCabal2nix "onomap" onomap-src {}; in { systemd.services.names = { wants = ["network-online.target"]; @@ -14,7 +12,7 @@ in { description = "Better clone of geogen.stoepel.net"; serviceConfig = { DynamicUser = true; - ExecStart = "${onomap}/bin/onomap-web"; + ExecStart = "${inputs.scripts.packages.x86_64-linux.onomap}/bin/onomap-web"; Restart = "on-failure"; RestartSec = "15s"; }; diff --git a/systems/makanek/urlwatch.nix b/systems/makanek/urlwatch.nix index 094e563..a7bd736 100644 --- a/systems/makanek/urlwatch.nix +++ b/systems/makanek/urlwatch.nix @@ -10,6 +10,8 @@ urlsFile = pkgs.writeText "urls" (builtins.concatStringsSep "\n---\n" (map builtins.toJSON urls)); + tokensFile = config.age.secrets.urlwatch-tokens.path; + urls = [ { name = "Corona-Verordnung"; @@ -124,7 +126,7 @@ } ]; - configFile = (pkgs.formats.yaml {}).generate "urlwatch.yaml" { + configFile = (pkgs.formats.json {}).generate "urlwatch.json" { display = { error = true; new = true; @@ -141,14 +143,12 @@ port = 587; starttls = true; auth = true; - # insecure_password = lib.strings.fileContents ; TODO how? }; subject = "{count} changes: {jobs}"; to = kieran.email; }; telegram = { - enabled = false; - # bot_token = lib.strings.fileContents ; TODO how? + enabled = true; chat_id = "-1001504043752"; }; html.diff = "unified"; @@ -157,11 +157,6 @@ enabled = true; }; text.footer = false; - # telegram = { - # enabled = false; - # bot_token = lib.strings.fileContents ; - # chat_id = [ "18980945" ]; - # }; }; }; urlwatch = pkgs.urlwatch.overrideAttrs (attrs: { @@ -175,6 +170,8 @@ in { group = "urlwatch"; }; + age.secrets.urlwatch-tokens.file = ../../secrets/urlwatch-tokens.json.age; + users.groups.urlwatch = {}; systemd.services.urlwatch = { @@ -182,7 +179,9 @@ in { startAt = "12:00"; script = '' ${urlwatch}/bin/urlwatch \ - --config=${lib.escapeShellArg configFile} \ + --config=<( + ${pkgs.jq}/bin/jq -s '.[0] * .[1]' ${toString configFile} ${toString tokensFile} + ) \ --urls=${lib.escapeShellArg urlsFile} ''; serviceConfig = {