From 7003170e61f143c2b1bf944e2895ff89fd38026d Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 21 Apr 2021 23:40:24 -0500 Subject: [PATCH 1/2] imp: provide per channel modules paths to make it easy to "backport" a module. imports = [ ${myChannelModulesPathk}/installer/... Signed-off-by: David Arnold --- .../configurations/Morty.host.nix | 8 ++++++-- systemFlake.nix | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/fully-featured/configurations/Morty.host.nix b/examples/fully-featured/configurations/Morty.host.nix index 1f0fabe2..16a1c13c 100644 --- a/examples/fully-featured/configurations/Morty.host.nix +++ b/examples/fully-featured/configurations/Morty.host.nix @@ -1,4 +1,8 @@ -{ ... }: { +# auto-special args ModulesPath for easy backporting of modules +{ unstableModulesPath, ... }: { + + imports = [ "${unstableModulesPath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix" ]; + disabledModules = [ "installer/cd-dvd/installation-cd-minimal-new-kernel.nix" ]; + boot.loader.grub.devices = [ "nodev" ]; - fileSystems."/" = { device = "test"; fsType = "ext4"; }; } diff --git a/systemFlake.nix b/systemFlake.nix index 3feda486..ada45260 100644 --- a/systemFlake.nix +++ b/systemFlake.nix @@ -30,7 +30,7 @@ let inherit (flake-utils-plus.lib) eachSystem patchChannel; - inherit (builtins) foldl' mapAttrs removeAttrs attrValues isAttrs isList; + inherit (builtins) foldl' mapAttrs removeAttrs attrValues attrNames isAttrs isList; # set defaults and validate host arguments evalHostArgs = @@ -42,7 +42,9 @@ let , extraArgs ? { } # These are not part of the module system, so they can be used in `imports` lines without infinite recursion , specialArgs ? { } - }: { inherit channelName system output builder modules extraArgs specialArgs; }; + }: { + inherit channelName system output builder modules extraArgs specialArgs; + }; # recursively merge attribute sets and lists up to a certain depth mergeAny = lhs: rhs: @@ -91,8 +93,15 @@ let lib = selectedNixpkgs.lib; # Use nixos modules from patched nixpkgs baseModules = import (patchedChannel + "/nixos/modules/module-list.nix"); - # Override `modulesPath` because otherwise imports from there will not use patched nixpkgs - specialArgs = { modulesPath = builtins.toString (patchedChannel + "/nixos/modules"); } // host.specialArgs; + specialArgs = let + f = channelName: + { "${channelName}ModulesPath" = builtins.toString (channels.${channelName}.input + "/nixos/modules"); }; + in + # Add `ModulesPath`s + (foldl' (lhs: rhs: lhs // rhs) {} (map f (attrNames channels))) + # Override `modulesPath` because otherwise imports from there will not use patched nixpkgs + // { modulesPath = builtins.toString (patchedChannel + "/nixos/modules"); } + // host.specialArgs; # The only way to find out if a host has `nixpkgs.config` set to # the non-default value is by evalling most of the config. hostConfig = (lib.evalModules { From a5246e7fe7e7750489ed7b36ec7285306c9b8a4d Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sun, 25 Apr 2021 14:42:08 -0500 Subject: [PATCH 2/2] fix test --- systemFlake.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/systemFlake.nix b/systemFlake.nix index ada45260..b790ef4e 100644 --- a/systemFlake.nix +++ b/systemFlake.nix @@ -93,12 +93,13 @@ let lib = selectedNixpkgs.lib; # Use nixos modules from patched nixpkgs baseModules = import (patchedChannel + "/nixos/modules/module-list.nix"); - specialArgs = let - f = channelName: - { "${channelName}ModulesPath" = builtins.toString (channels.${channelName}.input + "/nixos/modules"); }; - in + specialArgs = + let + f = channelName: + { "${channelName}ModulesPath" = builtins.toString (channels.${channelName}.input + "/nixos/modules"); }; + in # Add `ModulesPath`s - (foldl' (lhs: rhs: lhs // rhs) {} (map f (attrNames channels))) + (foldl' (lhs: rhs: lhs // rhs) { } (map f (attrNames channels))) # Override `modulesPath` because otherwise imports from there will not use patched nixpkgs // { modulesPath = builtins.toString (patchedChannel + "/nixos/modules"); } // host.specialArgs; @@ -158,9 +159,9 @@ let ]; }) ] ++ host.modules; - specialArgs = host.specialArgs; + inherit specialArgs; } // (optionalAttrs (host.output == "nixosConfigurations") { - inherit lib baseModules specialArgs; + inherit lib baseModules; })); } );