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 719848b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion examples/fully-featured/configurations/Morty.host.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ ... }: {
# 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"; };
}
11 changes: 10 additions & 1 deletion systemFlake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}/nixos/modules"; };
channelModulesPath = map f (attrValues 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 719848b

Please sign in to comment.