From 3bdfb4c2975a75d76d1f3b2531755427297ba859 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 17 Nov 2024 00:08:02 +0100 Subject: [PATCH] Add function to make paths from flake root No more ../../../../../../ --- base/default.nix | 6 ++-- flake.lock | 30 +++++++++---------- flake.nix | 1 + hosts/bekkalokk/configuration.nix | 8 ++--- hosts/bekkalokk/services/gitea/default.nix | 6 ++-- .../bekkalokk/services/mediawiki/default.nix | 8 ++--- .../bekkalokk/services/webmail/snappymail.nix | 4 +-- hosts/bicep/configuration.nix | 8 ++--- hosts/bicep/services/calendar-bot.nix | 6 ++-- hosts/bicep/services/matrix/coturn.nix | 6 ++-- hosts/bicep/services/matrix/discord.nix | 6 ++-- .../services/matrix/hookshot/default.nix | 6 ++-- hosts/bicep/services/matrix/mjolnir.nix | 4 +-- hosts/bicep/services/matrix/synapse.nix | 6 ++-- hosts/bob/configuration.nix | 10 +++---- hosts/brzeczyszczykiewicz/configuration.nix | 6 ++-- .../brzeczyszczykiewicz/services/grzegorz.nix | 4 +-- hosts/georg/configuration.nix | 8 ++--- hosts/ildkule/configuration.nix | 8 ++--- hosts/shark/configuration.nix | 8 ++--- 20 files changed, 75 insertions(+), 74 deletions(-) diff --git a/base/default.nix b/base/default.nix index bbc0c9a..3ac04f3 100644 --- a/base/default.nix +++ b/base/default.nix @@ -1,9 +1,9 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, fp, ... }: { imports = [ - ../users - ../modules/snakeoil-certs.nix + (fp /users) + (fp /modules/snakeoil-certs.nix) ./networking.nix ./nix.nix diff --git a/flake.lock b/flake.lock index efe3c4c..ff70982 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1729281548, - "narHash": "sha256-MuojlSnwAJAwfhgmW8ZtZrwm2Sko4fqubCvReqbUzYw=", + "lastModified": 1731746438, + "narHash": "sha256-f3SSp1axoOk0NAI7oFdRzbxG2XPBSIXC+/DaAXnvS1A=", "owner": "nix-community", "repo": "disko", - "rev": "a6a3179ddf396dfc28a078e2f169354d0c137125", + "rev": "cb64993826fa7a477490be6ccb38ba1fa1e18fa8", "type": "github" }, "original": { @@ -119,11 +119,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1729307008, - "narHash": "sha256-QUvb6epgKi9pCu9CttRQW4y5NqJ+snKr1FZpG/x3Wtc=", + "lastModified": 1731663789, + "narHash": "sha256-x07g4NcqGP6mQn6AISXJaks9sQYDjZmTMBlKIvajvyc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a9b86fc2290b69375c5542b622088eb6eca2a7c3", + "rev": "035d434d48f4375ac5d3a620954cf5fda7dd7c36", "type": "github" }, "original": { @@ -135,11 +135,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1728156290, - "narHash": "sha256-uogSvuAp+1BYtdu6UWuObjHqSbBohpyARXDWqgI12Ss=", + "lastModified": 1730602179, + "narHash": "sha256-efgLzQAWSzJuCLiCaQUCDu4NudNlHdg2NzGLX5GYaEY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "17ae88b569bb15590549ff478bab6494dde4a907", + "rev": "3c2f1c4ca372622cb2f9de8016c9a0b1cbd0f37c", "type": "github" }, "original": { @@ -151,11 +151,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1729308112, - "narHash": "sha256-Ap+cPeiluam2KFZO+OWuFTl/IkIJfyGYGMgkT2pVCRY=", + "lastModified": 1731745710, + "narHash": "sha256-SVeiClbgqL071JpAspOu0gCkPSAL51kSIRwo4C/pghA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "61253596816c4cd65e2a0f474cbc0ac0c6e0f7cf", + "rev": "dfaa4cb76c2d450d8f396bb6b9f43cede3ade129", "type": "github" }, "original": { @@ -249,11 +249,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1728345710, - "narHash": "sha256-lpunY1+bf90ts+sA2/FgxVNIegPDKCpEoWwOPu4ITTQ=", + "lastModified": 1731748189, + "narHash": "sha256-Zd/Uukvpcu26M6YGhpbsgqm6LUSLz+Q8mDZ5LOEGdiE=", "owner": "Mic92", "repo": "sops-nix", - "rev": "06535d0e3d0201e6a8080dd32dbfde339b94f01b", + "rev": "d2bd7f433b28db6bc7ae03d5eca43564da0af054", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 4616461..dd12109 100644 --- a/flake.nix +++ b/flake.nix @@ -59,6 +59,7 @@ specialArgs = { inherit unstablePkgs inputs; values = import ./values.nix; + fp = path: ./${path}; }; modules = [ diff --git a/hosts/bekkalokk/configuration.nix b/hosts/bekkalokk/configuration.nix index 4c9da34..df0cf6e 100644 --- a/hosts/bekkalokk/configuration.nix +++ b/hosts/bekkalokk/configuration.nix @@ -1,10 +1,10 @@ -{ pkgs, values, ... }: +{ fp, pkgs, values, ... }: { imports = [ ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ./services/bluemap/default.nix ./services/gitea/default.nix @@ -19,7 +19,7 @@ ./services/well-known ]; - sops.defaultSopsFile = ../../secrets/bekkalokk/bekkalokk.yaml; + sops.defaultSopsFile = fp /secrets/bekkalokk/bekkalokk.yaml; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.generateKey = true; diff --git a/hosts/bekkalokk/services/gitea/default.nix b/hosts/bekkalokk/services/gitea/default.nix index 8175e4a..daf0718 100644 --- a/hosts/bekkalokk/services/gitea/default.nix +++ b/hosts/bekkalokk/services/gitea/default.nix @@ -1,4 +1,4 @@ -{ config, values, pkgs, lib, ... }: +{ config, values, fp, pkgs, lib, ... }: let cfg = config.services.gitea; domain = "git.pvv.ntnu.no"; @@ -173,8 +173,8 @@ in { }; script = let - logo-svg = ../../../../assets/logo_blue_regular.svg; - logo-png = ../../../../assets/logo_blue_regular.png; + logo-svg = fp /assets/logo_blue_regular.svg; + logo-png = fp /assets/logo_blue_regular.png; extraLinks = pkgs.writeText "gitea-extra-links.tmpl" '' PVV Wiki diff --git a/hosts/bekkalokk/services/mediawiki/default.nix b/hosts/bekkalokk/services/mediawiki/default.nix index fab75ac..d89b200 100644 --- a/hosts/bekkalokk/services/mediawiki/default.nix +++ b/hosts/bekkalokk/services/mediawiki/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, values, pkgs-unstable, ... }: let +{ pkgs, lib, fp, config, values, pkgs-unstable, ... }: let cfg = config.services.mediawiki; # "mediawiki" @@ -210,8 +210,8 @@ in { ''; }; - "= /PNG/PVV-logo.svg".alias = ../../../../assets/logo_blue_regular.svg; - "= /PNG/PVV-logo.png".alias = ../../../../assets/logo_blue_regular.png; + "= /PNG/PVV-logo.svg".alias = fp /assets/logo_blue_regular.svg; + "= /PNG/PVV-logo.png".alias = fp /assets/logo_blue_regular.png; "= /favicon.ico".alias = pkgs.runCommandLocal "mediawiki-favicon.ico" { buildInputs = with pkgs; [ imagemagick ]; } '' @@ -219,7 +219,7 @@ in { -resize x64 \ -gravity center \ -crop 64x64+0+0 \ - ${../../../../assets/logo_blue_regular.png} \ + ${fp /assets/logo_blue_regular.png} \ -flatten \ -colors 256 \ -background transparent \ diff --git a/hosts/bekkalokk/services/webmail/snappymail.nix b/hosts/bekkalokk/services/webmail/snappymail.nix index 3d51f9e..d81509e 100644 --- a/hosts/bekkalokk/services/webmail/snappymail.nix +++ b/hosts/bekkalokk/services/webmail/snappymail.nix @@ -1,8 +1,8 @@ -{ config, lib, pkgs, ... }: +{ config, lib, fp, pkgs, ... }: let cfg = config.services.snappymail; in { - imports = [ ../../../../modules/snappymail.nix ]; + imports = [ (fp /modules/snappymail.nix) ]; services.snappymail = { enable = true; diff --git a/hosts/bicep/configuration.nix b/hosts/bicep/configuration.nix index 0145826..6c96555 100644 --- a/hosts/bicep/configuration.nix +++ b/hosts/bicep/configuration.nix @@ -1,10 +1,10 @@ -{ pkgs, values, ... }: +{ fp, pkgs, values, ... }: { imports = [ ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ./services/nginx ./services/mysql.nix @@ -15,7 +15,7 @@ ./services/matrix ]; - sops.defaultSopsFile = ../../secrets/bicep/bicep.yaml; + sops.defaultSopsFile = fp /secrets/bicep/bicep.yaml; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.generateKey = true; diff --git a/hosts/bicep/services/calendar-bot.nix b/hosts/bicep/services/calendar-bot.nix index 8eccaa6..ad5bbe5 100644 --- a/hosts/bicep/services/calendar-bot.nix +++ b/hosts/bicep/services/calendar-bot.nix @@ -1,16 +1,16 @@ -{ config, lib, pkgs, ... }: +{ config, fp, lib, pkgs, ... }: let cfg = config.services.pvv-calendar-bot; in { sops.secrets = { "calendar-bot/matrix_token" = { - sopsFile = ../../../secrets/bicep/bicep.yaml; + sopsFile = fp /secrets/bicep/bicep.yaml; key = "calendar-bot/matrix_token"; owner = cfg.user; group = cfg.group; }; "calendar-bot/mysql_password" = { - sopsFile = ../../../secrets/bicep/bicep.yaml; + sopsFile = fp /secrets/bicep/bicep.yaml; key = "calendar-bot/mysql_password"; owner = cfg.user; group = cfg.group; diff --git a/hosts/bicep/services/matrix/coturn.nix b/hosts/bicep/services/matrix/coturn.nix index e1878e9..075a4ef 100644 --- a/hosts/bicep/services/matrix/coturn.nix +++ b/hosts/bicep/services/matrix/coturn.nix @@ -1,14 +1,14 @@ -{ config, lib, pkgs, secrets, values, ... }: +{ config, lib, fp, pkgs, secrets, values, ... }: { sops.secrets."matrix/synapse/turnconfig" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "synapse/turnconfig"; owner = config.users.users.matrix-synapse.name; group = config.users.users.matrix-synapse.group; }; sops.secrets."matrix/coturn/static-auth-secret" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "coturn/static-auth-secret"; owner = config.users.users.turnserver.name; group = config.users.users.turnserver.group; diff --git a/hosts/bicep/services/matrix/discord.nix b/hosts/bicep/services/matrix/discord.nix index 5562d8d..81473d2 100644 --- a/hosts/bicep/services/matrix/discord.nix +++ b/hosts/bicep/services/matrix/discord.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, fp, ... }: let cfg = config.services.mx-puppet-discord; @@ -7,11 +7,11 @@ in users.groups.keys-matrix-registrations = { }; sops.secrets."matrix/discord/as_token" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "discord/as_token"; }; sops.secrets."matrix/discord/hs_token" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "discord/hs_token"; }; diff --git a/hosts/bicep/services/matrix/hookshot/default.nix b/hosts/bicep/services/matrix/hookshot/default.nix index 73e4812..510bc16 100644 --- a/hosts/bicep/services/matrix/hookshot/default.nix +++ b/hosts/bicep/services/matrix/hookshot/default.nix @@ -1,4 +1,4 @@ -{ config, lib, unstablePkgs, inputs, ... }: +{ config, lib, fp, unstablePkgs, inputs, ... }: let cfg = config.services.matrix-hookshot; @@ -11,11 +11,11 @@ in ]; sops.secrets."matrix/hookshot/as_token" = { - sopsFile = ../../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "hookshot/as_token"; }; sops.secrets."matrix/hookshot/hs_token" = { - sopsFile = ../../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "hookshot/hs_token"; }; diff --git a/hosts/bicep/services/matrix/mjolnir.nix b/hosts/bicep/services/matrix/mjolnir.nix index c547da2..d0e2bf5 100644 --- a/hosts/bicep/services/matrix/mjolnir.nix +++ b/hosts/bicep/services/matrix/mjolnir.nix @@ -1,8 +1,8 @@ -{ config, lib, ... }: +{ config, lib, fp, ... }: { sops.secrets."matrix/mjolnir/access_token" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "mjolnir/access_token"; owner = config.users.users.mjolnir.name; group = config.users.users.mjolnir.group; diff --git a/hosts/bicep/services/matrix/synapse.nix b/hosts/bicep/services/matrix/synapse.nix index 463be3c..8ded195 100644 --- a/hosts/bicep/services/matrix/synapse.nix +++ b/hosts/bicep/services/matrix/synapse.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, values, inputs, ... }: +{ config, lib, fp, pkgs, values, inputs, ... }: let cfg = config.services.matrix-synapse-next; @@ -10,13 +10,13 @@ let in { sops.secrets."matrix/synapse/signing_key" = { key = "synapse/signing_key"; - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; owner = config.users.users.matrix-synapse.name; group = config.users.users.matrix-synapse.group; }; sops.secrets."matrix/synapse/user_registration" = { - sopsFile = ../../../../secrets/bicep/matrix.yaml; + sopsFile = fp /secrets/bicep/matrix.yaml; key = "synapse/signing_key"; owner = config.users.users.matrix-synapse.name; group = config.users.users.matrix-synapse.group; diff --git a/hosts/bob/configuration.nix b/hosts/bob/configuration.nix index 2c9ff70..8b36198 100644 --- a/hosts/bob/configuration.nix +++ b/hosts/bob/configuration.nix @@ -1,16 +1,16 @@ -{ config, pkgs, values, ... }: +{ config, fp, pkgs, values, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ./disks.nix - ../../misc/builder.nix + (fp /misc/builder.nix) ]; - sops.defaultSopsFile = ../../secrets/bob/bob.yaml; + sops.defaultSopsFile = fp /secrets/bob/bob.yaml; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.generateKey = true; diff --git a/hosts/brzeczyszczykiewicz/configuration.nix b/hosts/brzeczyszczykiewicz/configuration.nix index a0658b3..b99fb3b 100644 --- a/hosts/brzeczyszczykiewicz/configuration.nix +++ b/hosts/brzeczyszczykiewicz/configuration.nix @@ -1,10 +1,10 @@ -{ config, pkgs, values, ... }: +{ config, fp, pkgs, values, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ./services/grzegorz.nix ]; diff --git a/hosts/brzeczyszczykiewicz/services/grzegorz.nix b/hosts/brzeczyszczykiewicz/services/grzegorz.nix index 20574fe..d43d19b 100644 --- a/hosts/brzeczyszczykiewicz/services/grzegorz.nix +++ b/hosts/brzeczyszczykiewicz/services/grzegorz.nix @@ -1,6 +1,6 @@ -{ config, ... }: +{ config, fp, ... }: { - imports = [ ../../../modules/grzegorz.nix ]; + imports = [ (fp /modules/grzegorz.nix) ]; services.nginx.virtualHosts."${config.networking.fqdn}" = { serverAliases = [ diff --git a/hosts/georg/configuration.nix b/hosts/georg/configuration.nix index d7f6d9a..92f01bc 100644 --- a/hosts/georg/configuration.nix +++ b/hosts/georg/configuration.nix @@ -1,12 +1,12 @@ -{ config, pkgs, values, ... }: +{ config, fp, pkgs, values, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) - ../../modules/grzegorz.nix + (fp /modules/grzegorz.nix) ]; boot.loader.systemd-boot.enable = true; diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index c66d261..c6c2f1d 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -1,16 +1,16 @@ -{ config, pkgs, lib, values, ... }: +{ config, fp, pkgs, lib, values, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ./services/monitoring ./services/nginx ]; - sops.defaultSopsFile = ../../secrets/ildkule/ildkule.yaml; + sops.defaultSopsFile = fp /secrets/ildkule/ildkule.yaml; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.generateKey = true; diff --git a/hosts/shark/configuration.nix b/hosts/shark/configuration.nix index dda8ccb..65c036d 100644 --- a/hosts/shark/configuration.nix +++ b/hosts/shark/configuration.nix @@ -1,13 +1,13 @@ -{ config, pkgs, values, ... }: +{ config, fp, pkgs, values, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../base - ../../misc/metrics-exporters.nix + (fp /base) + (fp /misc/metrics-exporters.nix) ]; - sops.defaultSopsFile = ../../secrets/shark/shark.yaml; + sops.defaultSopsFile = fp /secrets/shark/shark.yaml; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.generateKey = true;