Skip to content

Commit

Permalink
imp: provide per channel modules paths to make it easy to "backport"
Browse files Browse the repository at this point in the history
a module. imports = [ ${myChannelModulesPathk}/installer/...
  • Loading branch information
David Arnold committed Apr 22, 2021
1 parent 072c13c commit 361e2fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 6 additions & 2 deletions examples/fully-featured/configurations/Morty.host.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ ... }: {
# auto-special args <channelName>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"; };
}
13 changes: 11 additions & 2 deletions systemFlake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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:
Expand Down

0 comments on commit 361e2fe

Please sign in to comment.