From 361e2fefadf6f3a869c6e51bc4c5ab43a0d43c22 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 21 Apr 2021 23:40:24 -0500 Subject: [PATCH] imp: provide per channel modules paths to make it easy to "backport" a module. imports = [ ${myChannelModulesPathk}/installer/... --- .../fully-featured/configurations/Morty.host.nix | 8 ++++++-- systemFlake.nix | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 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 9014c9fd..da805c7d 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,16 @@ 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 = let + f = channelName: + { "${channelName}ModulesPath" = "${channels.${channelName}.input}/nixos/modules"; }; + channelModulesPath = map f (attrNames channels); + merge = lhs: rhs: lhs // rhs; + in + (foldl' merge {} channelModulesPath) // specialArgs; + }; # recursively merge attribute sets and lists up to a certain depth mergeAny = lhs: rhs: