From b60ce985b74f176e61ab15dbc1344d975b7f910f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 16 Feb 2023 17:22:27 +0000 Subject: [PATCH] inline lib/merge-modules.nix it wasn't really adding value once I learned that evalModules is at nixpkgs.lib https://github.com/telent/liminix/compare/main...vesim987:liminix:main#diff-8ebcd005c04c8eddff72aa83f26a9ee6cfef3c04ce16b8f051aa6c6f4b0c9e73L1 --- default.nix | 19 +++++++++++-------- lib/merge-modules.nix | 8 -------- tests/module/configuration.nix | 10 ---------- tests/module/defs.nix | 16 ---------------- tests/module/module.nix | 6 ------ tests/module/run.sh | 2 -- tests/module/test.nix | 17 ----------------- 7 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 lib/merge-modules.nix delete mode 100644 tests/module/configuration.nix delete mode 100644 tests/module/defs.nix delete mode 100644 tests/module/module.nix delete mode 100755 tests/module/run.sh delete mode 100644 tests/module/test.nix diff --git a/default.nix b/default.nix index bae2479..9034eeb 100644 --- a/default.nix +++ b/default.nix @@ -11,14 +11,17 @@ let config = {allowUnsupportedSystem = true; }; }); - config = (import ./lib/merge-modules.nix) [ - ./modules/base.nix - device.module - liminix-config - ./modules/s6 - ./modules/users.nix - ./modules/outputs.nix - ] pkgs; + config = (pkgs.lib.evalModules { + modules = [ + { _module.args = { inherit pkgs; lib = pkgs.lib; }; } + ./modules/base.nix + device.module + liminix-config + ./modules/s6 + ./modules/users.nix + ./modules/outputs.nix + ]; + }).config; borderVm = ((import ) { system = builtins.currentSystem; diff --git a/lib/merge-modules.nix b/lib/merge-modules.nix deleted file mode 100644 index 5b93339..0000000 --- a/lib/merge-modules.nix +++ /dev/null @@ -1,8 +0,0 @@ -modules : pkgs : -let evalModules = (import ).evalModules; -in (evalModules { - modules = - [ - { _module.args = { inherit pkgs; lib = pkgs.lib; }; } - ] ++ modules; -}).config diff --git a/tests/module/configuration.nix b/tests/module/configuration.nix deleted file mode 100644 index eef2a8a..0000000 --- a/tests/module/configuration.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, pkgs, ... } : -{ - imports = [ ./defs.nix ./module.nix ]; - config = { - services.a.enable = true; - services.b.enable = true; - - systemPackages = [ pkgs.hello ] ; - }; -} diff --git a/tests/module/defs.nix b/tests/module/defs.nix deleted file mode 100644 index 5ca3e29..0000000 --- a/tests/module/defs.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ lib, ...}: -let inherit (lib) mkEnableOption mkOption types; -in { - options = { - services.a = { - enable = mkEnableOption "hello service"; - }; - services.b = { - enable = mkEnableOption "other service"; - }; - services.z = mkOption { }; - systemPackages = mkOption { - type = types.listOf types.package; - }; - }; -} diff --git a/tests/module/module.nix b/tests/module/module.nix deleted file mode 100644 index 69b4817..0000000 --- a/tests/module/module.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ config, pkgs, ... } : -{ - services.z = pkgs.figlet; - - systemPackages = [ pkgs.units ] ; -} diff --git a/tests/module/run.sh b/tests/module/run.sh deleted file mode 100755 index 37010d5..0000000 --- a/tests/module/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -set -e -NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build --arg device "import " test.nix diff --git a/tests/module/test.nix b/tests/module/test.nix deleted file mode 100644 index e3d72ba..0000000 --- a/tests/module/test.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ device }: -let - overlay = import ; - nixpkgs = import ( device.system // {overlays = [overlay]; }); - inherit (nixpkgs) lib pkgs; - inherit (lib.asserts) assertMsg; - config = - (import ) [./configuration.nix] pkgs; - res1 = assertMsg - # check we have packages from both modules - (config.systemPackages == ( with pkgs; [ units hello ])) "failed"; - res2 = let s = config.services; - in assertMsg (s.a.enable && s.b.enable && (s.z != null) ) "failed"; -in pkgs.writeText "foo" '' - ${if res1 then "OK" else "not OK"} - ${if res2 then "OK" else "not OK"} -''