diff --git a/modules/contracts/backup/test.nix b/modules/contracts/backup/test.nix index 52d8bf0..61c594d 100644 --- a/modules/contracts/backup/test.nix +++ b/modules/contracts/backup/test.nix @@ -1,11 +1,8 @@ { pkgs, lib, ... }: let - pkgs' = pkgs; - testLib = pkgs.callPackage ../../../test/common.nix {}; - inherit (lib) concatStringsSep concatMapStringsSep getAttrFromPath mkIf optionalAttrs setAttrByPath; - inherit (testLib) indent; + inherit (lib) concatMapStringsSep getAttrFromPath mkIf optionalAttrs setAttrByPath; in { name, providerRoot, @@ -21,7 +18,7 @@ in inherit name; nodes.machine = { config, ... }: { - imports = ( testLib.baseImports pkgs' ) ++ modules; + imports = [ testLib.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath providerRoot { diff --git a/modules/contracts/databasebackup/test.nix b/modules/contracts/databasebackup/test.nix index da585d0..081bf00 100644 --- a/modules/contracts/databasebackup/test.nix +++ b/modules/contracts/databasebackup/test.nix @@ -1,7 +1,5 @@ { pkgs, lib, ... }: let - pkgs' = pkgs; - testLib = pkgs.callPackage ../../../test/common.nix {}; inherit (lib) getAttrFromPath mkIf optionalAttrs setAttrByPath; @@ -17,7 +15,7 @@ in inherit name; nodes.machine = { config, ... }: { - imports = ( testLib.baseImports pkgs' ) ++ modules; + imports = [ testLib.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath providerRoot { request = (getAttrFromPath requesterRoot config).request; diff --git a/modules/contracts/secret/test.nix b/modules/contracts/secret/test.nix index 517b56a..272bcb9 100644 --- a/modules/contracts/secret/test.nix +++ b/modules/contracts/secret/test.nix @@ -1,7 +1,5 @@ { pkgs, lib, ... }: let - pkgs' = pkgs; - testLib = pkgs.callPackage ../../../test/common.nix {}; inherit (lib) getAttrFromPath setAttrByPath; @@ -19,7 +17,7 @@ in name = "secret_${name}_${owner}_${group}_${mode}"; nodes.machine = { config, ... }: { - imports = ( testLib.baseImports pkgs' ) ++ modules; + imports = [ testLib.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath configRoot { A = { diff --git a/test/blocks/restic.nix b/test/blocks/restic.nix index 9ec4a0c..43f2187 100644 --- a/test/blocks/restic.nix +++ b/test/blocks/restic.nix @@ -1,19 +1,13 @@ -{ pkgs, lib, ... }: +{ pkgs, ... }: let - pkgs' = pkgs; - testLib = pkgs.callPackage ../common.nix {}; - shblib = pkgs.callPackage ../../lib {}; - - base = testLib.base [ - ../../modules/blocks/restic.nix - ]; commonTest = user: pkgs.testers.runNixOSTest { name = "restic_backupAndRestore_${user}"; nodes.machine = { config, ... }: { - imports = ( testLib.baseImports pkgs' ) ++ [ + imports = [ + testLib.baseImports ../../modules/blocks/hardcodedsecret.nix ../../modules/blocks/restic.nix ]; diff --git a/test/common.nix b/test/common.nix index f74c8fe..7b1154b 100644 --- a/test/common.nix +++ b/test/common.nix @@ -1,9 +1,11 @@ -{ lib }: +{ pkgs, lib }: let - baseImports = pkgs: [ - (pkgs.path + "/nixos/modules/profiles/headless.nix") - (pkgs.path + "/nixos/modules/profiles/qemu-guest.nix") - ]; + baseImports = { + imports = [ + (pkgs.path + "/nixos/modules/profiles/headless.nix") + (pkgs.path + "/nixos/modules/profiles/qemu-guest.nix") + ]; + }; accessScript = lib.makeOverridable ({ subdomain @@ -112,19 +114,17 @@ in backup = backupScript args; }; - base = pkgs: additionalModules: { + baseModule = { imports = - ( baseImports pkgs ) - ++ [ - # TODO: replace postgresql.nix and authelia.nix by the sso contract + [ + baseImports ../modules/blocks/postgresql.nix ../modules/blocks/authelia.nix ../modules/blocks/nginx.nix ../modules/blocks/hardcodedsecret.nix - ] - ++ additionalModules; + ]; - # Nginx port. + # HTTP(s) server port. networking.firewall.allowedTCPPorts = [ 80 443 ]; }; diff --git a/test/services/arr.nix b/test/services/arr.nix index 8d0531a..071546e 100644 --- a/test/services/arr.nix +++ b/test/services/arr.nix @@ -50,10 +50,6 @@ let ''; }; - base = testLib.base pkgs' [ - ../../modules/services/arr.nix - ]; - basic = appname: { ... }: { shb.arr.${appname} = { enable = true; @@ -69,7 +65,8 @@ let nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/arr.nix (basic appname) ]; }; @@ -84,7 +81,8 @@ let nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/arr.nix (basic appname) (testLib.backup config.shb.arr.${appname}.backup) ]; @@ -106,7 +104,8 @@ let nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/arr.nix (testLib.certs domain) (basic appname) (https appname) @@ -129,7 +128,8 @@ let nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/arr.nix (testLib.certs domain) (basic appname) (https appname) diff --git a/test/services/audiobookshelf.nix b/test/services/audiobookshelf.nix index a857208..62bc16e 100644 --- a/test/services/audiobookshelf.nix +++ b/test/services/audiobookshelf.nix @@ -23,10 +23,6 @@ let # ''; }; - base = testLib.base pkgs' [ - ../../modules/services/audiobookshelf.nix - ]; - basic = { shb.audiobookshelf = { enable = true; @@ -58,7 +54,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/audiobookshelf.nix basic ]; }; @@ -71,12 +68,15 @@ in https = pkgs.testers.runNixOSTest { name = "audiobookshelf-https"; - nodes.server = lib.mkMerge [ - base - (testLib.certs domain) - basic - https - ]; + nodes.server = { + imports = [ + testLib.baseModule + ../../modules/services/audiobookshelf.nix + (testLib.certs domain) + basic + https + ]; + }; nodes.client = {}; @@ -88,7 +88,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/audiobookshelf.nix (testLib.certs domain) basic https diff --git a/test/services/deluge.nix b/test/services/deluge.nix index f124e94..c5f0cf3 100644 --- a/test/services/deluge.nix +++ b/test/services/deluge.nix @@ -73,11 +73,6 @@ let print(response) ''; - base = testLib.base pkgs' [ - ../../modules/blocks/hardcodedsecret.nix - ../../modules/services/deluge.nix - ]; - basic = { config, ... }: { shb.deluge = { enable = true; @@ -127,7 +122,9 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/deluge.nix basic ]; }; @@ -142,7 +139,9 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/deluge.nix basic (testLib.backup config.shb.deluge.backup) ]; @@ -158,7 +157,9 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/deluge.nix (testLib.certs domain) basic https @@ -175,7 +176,9 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/deluge.nix (testLib.certs domain) basic https @@ -197,7 +200,9 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/deluge.nix (testLib.certs domain) basic https diff --git a/test/services/forgejo.nix b/test/services/forgejo.nix index fdd725c..7b3d21e 100644 --- a/test/services/forgejo.nix +++ b/test/services/forgejo.nix @@ -25,10 +25,6 @@ let ''; }; - base = testLib.base pkgs' [ - ../../modules/services/forgejo.nix - ]; - basic = { config, ... }: { shb.forgejo = { enable = true; @@ -104,7 +100,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/forgejo.nix basic ]; }; @@ -119,7 +116,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/forgejo.nix basic (testLib.backup config.shb.forgejo.backup) ]; @@ -135,7 +133,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/forgejo.nix (testLib.certs domain) basic https @@ -152,7 +151,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/forgejo.nix basic (testLib.ldap domain pkgs') ldap @@ -169,7 +169,8 @@ in nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/forgejo.nix (testLib.certs domain) basic https diff --git a/test/services/grocy.nix b/test/services/grocy.nix index a51fc98..9c39502 100644 --- a/test/services/grocy.nix +++ b/test/services/grocy.nix @@ -23,10 +23,6 @@ let # ''; }; - base = testLib.base pkgs' [ - ../../modules/services/grocy.nix - ]; - basic = { config, ... }: { shb.grocy = { enable = true; @@ -46,7 +42,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/grocy.nix basic ]; }; @@ -61,7 +58,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/grocy.nix (testLib.certs domain) basic https diff --git a/test/services/hledger.nix b/test/services/hledger.nix index dfae061..f8cbf09 100644 --- a/test/services/hledger.nix +++ b/test/services/hledger.nix @@ -18,10 +18,6 @@ let ]; }; - base = testLib.base pkgs' [ - ../../modules/services/hledger.nix - ]; - basic = { config, ... }: { shb.hledger = { enable = true; @@ -47,7 +43,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/hledger.nix basic ]; }; @@ -62,7 +59,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/hledger.nix basic (testLib.backup config.shb.hledger.backup) ]; @@ -78,7 +76,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/hledger.nix (testLib.certs domain) basic https @@ -95,7 +94,8 @@ in nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/hledger.nix (testLib.certs domain) basic https diff --git a/test/services/home-assistant.nix b/test/services/home-assistant.nix index 5233d29..a1810a8 100644 --- a/test/services/home-assistant.nix +++ b/test/services/home-assistant.nix @@ -19,10 +19,6 @@ let ]; }; - base = testLib.base pkgs' [ - ../../modules/services/home-assistant.nix - ]; - basic = { config, ... }: { shb.home-assistant = { enable = true; @@ -115,7 +111,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/home-assistant.nix basic ]; }; @@ -130,7 +127,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/home-assistant.nix basic (testLib.backup config.shb.home-assistant.backup) ]; @@ -146,7 +144,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/home-assistant.nix (testLib.certs domain) basic https @@ -163,7 +162,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/home-assistant.nix basic (testLib.ldap domain pkgs') ldap @@ -181,7 +181,8 @@ in # name = "vaultwarden_sso"; # # nodes.server = lib.mkMerge [ - # base + # testLib.baseModule + # ../../modules/services/home-assistant.nix # (testLib.certs domain) # basic # https @@ -201,7 +202,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/home-assistant.nix basic voice ]; diff --git a/test/services/jellyfin.nix b/test/services/jellyfin.nix index ca3d6aa..ac48bc1 100644 --- a/test/services/jellyfin.nix +++ b/test/services/jellyfin.nix @@ -19,10 +19,6 @@ let ]; }; - base = testLib.base pkgs' [ - ../../modules/services/jellyfin.nix - ]; - basic = { shb.jellyfin = { enable = true; @@ -80,7 +76,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/jellyfin.nix basic ]; }; @@ -95,7 +92,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/jellyfin.nix basic (testLib.backup config.shb.jellyfin.backup) ]; @@ -111,7 +109,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/jellyfin.nix (testLib.certs domain) basic https @@ -128,7 +127,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/jellyfin.nix basic (testLib.ldap domain pkgs') ldap @@ -145,7 +145,8 @@ in nodes.server = { config, pkgs, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/jellyfin.nix (testLib.certs domain) basic https diff --git a/test/services/monitoring.nix b/test/services/monitoring.nix index 732ee89..b872fe3 100644 --- a/test/services/monitoring.nix +++ b/test/services/monitoring.nix @@ -20,10 +20,6 @@ let ]; }; - base = testLib.base pkgs' [ - ../../modules/blocks/monitoring.nix - ]; - basic = { config, ... }: { shb.monitoring = { enable = true; @@ -56,7 +52,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/monitoring.nix basic ]; }; @@ -71,7 +68,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/monitoring.nix (testLib.certs domain) basic https diff --git a/test/services/nextcloud.nix b/test/services/nextcloud.nix index 6833f72..d8950ae 100644 --- a/test/services/nextcloud.nix +++ b/test/services/nextcloud.nix @@ -115,10 +115,6 @@ let ''; }; - base = testLib.base pkgs' [ - ../../modules/services/nextcloud-server.nix - ]; - basic = { config, ... }: { shb.nextcloud = { enable = true; @@ -242,7 +238,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix basic ]; }; @@ -257,7 +254,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix basic (testLib.backup config.shb.nextcloud.backup) ]; @@ -273,7 +271,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix (testLib.certs domain) basic https @@ -291,7 +290,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix (testLib.certs domain) basic https @@ -309,7 +309,8 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix (testLib.certs domain) basic https @@ -327,7 +328,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix (testLib.certs domain) basic https @@ -346,7 +348,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix (testLib.certs domain) basic https @@ -367,7 +370,8 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/services/nextcloud-server.nix basic prometheus ]; diff --git a/test/services/vaultwarden.nix b/test/services/vaultwarden.nix index 6524f12..5c4ef27 100644 --- a/test/services/vaultwarden.nix +++ b/test/services/vaultwarden.nix @@ -50,11 +50,6 @@ let ''; }; - base = testLib.base pkgs' [ - ../../modules/blocks/hardcodedsecret.nix - ../../modules/services/vaultwarden.nix - ]; - basic = { config, ... }: { shb.nginx.accessLog = true; shb.vaultwarden = { @@ -100,7 +95,9 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/vaultwarden.nix basic ]; }; @@ -115,7 +112,9 @@ in nodes.server = { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/vaultwarden.nix (testLib.certs domain) basic https @@ -133,7 +132,9 @@ in # name = "vaultwarden_ldap"; # # nodes.server = lib.mkMerge [ - # base + # testLib.baseModule + # ../../modules/blocks/hardcodedsecret.nix + # ../../modules/services/vaultwarden.nix # basic # ldap # ]; @@ -148,7 +149,9 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/vaultwarden.nix (testLib.certs domain) basic https @@ -185,7 +188,9 @@ in nodes.server = { config, ... }: { imports = [ - base + testLib.baseModule + ../../modules/blocks/hardcodedsecret.nix + ../../modules/services/vaultwarden.nix basic (testLib.backup config.shb.vaultwarden.backup) ];