Browse Source

allow out-of-tree nixos modules

The environment variable "NIXOS_EXTRA_MODULES" is now checked to
contain a path to a file similar to modules/module-list.nix.

This gives the ability to include nixos modules that are not in the
nixos source tree.

This can be useful for modules that are still experimental, or which
aren't useful for other nixos users. Of course, this was already
possible to do this using a forked nixos tree, but with this
functionality, you can just rely on the nixos channel, easing things a
lot.
nsd-state-dir
Mathijs Kwik 10 years ago
parent
commit
b609ff4fcf
  1. 9
      default.nix
  2. 1
      modules/security/sudo.nix

9
default.nix

@ -1,12 +1,15 @@
{ configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
, extraModulesPath ? builtins.getEnv "NIXOS_EXTRA_MODULES"
, system ? builtins.currentSystem
}:
let
extraModules = if extraModulesPath == "" then [] else import extraModulesPath;
eval = import ./lib/eval-config.nix {
inherit system;
modules = [ configuration ];
modules = [ configuration ] ++ extraModules;
};
inherit (eval) config pkgs;
@ -14,7 +17,7 @@ let
# This is for `nixos-rebuild build-vm'.
vmConfig = (import ./lib/eval-config.nix {
inherit system;
modules = [ configuration ./modules/virtualisation/qemu-vm.nix ];
modules = [ configuration ./modules/virtualisation/qemu-vm.nix ] ++ extraModules;
}).config;
# This is for `nixos-rebuild build-vm-with-bootloader'.
@ -24,7 +27,7 @@ let
[ configuration
./modules/virtualisation/qemu-vm.nix
{ virtualisation.useBootLoader = true; }
];
] ++ extraModules;
}).config;
in

1
modules/security/sudo.nix

@ -35,6 +35,7 @@ in
# Environment variables to keep for root and %wheel.
Defaults:root,%wheel env_keep+=LOCALE_ARCHIVE
Defaults:root,%wheel env_keep+=NIX_PATH
Defaults:root,%wheel env_keep+=NIXOS_EXTRA_MODULES
Defaults:root,%wheel env_keep+=TERMINFO_DIRS
# Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.

Loading…
Cancel
Save