diff options
author | Sander van der Burg <svanderburg@gmail.com> | 2021-03-22 22:58:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 22:58:49 +0100 |
commit | 8fc942356501c14fc3e632c7c41ad3c26ac57a3d (patch) | |
tree | 0620ddc0ff71a8c1ea048971ed0de592165320c3 /nixos/modules/system | |
parent | 31e4678c6b883d673f712bc9f5c8e4099e8ea324 (diff) | |
parent | 5c8ed06fc9dbdf92681101d4fd91c690293ae007 (diff) | |
download | nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar.gz nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar.bz2 nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar.lz nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar.xz nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.tar.zst nixpkgs-8fc942356501c14fc3e632c7c41ad3c26ac57a3d.zip |
Merge pull request #116455 from svanderburg/systemdunitpath
systemd: allow custom unit folders to be configured with SYSTEMD_UNIT…
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/stage-2-init.sh | 3 | ||||
-rw-r--r-- | nixos/modules/system/boot/stage-2.nix | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index 936077b9df1..50ee0b8841e 100644 --- a/nixos/modules/system/boot/stage-2-init.sh +++ b/nixos/modules/system/boot/stage-2-init.sh @@ -167,6 +167,7 @@ exec {logOutFd}>&- {logErrFd}>&- # Start systemd. echo "starting systemd..." + PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@ \ - LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive \ + LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive @systemdUnitPathEnvVar@ \ exec @systemdExecutable@ diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix index 94bc34fea0d..f6b6a8e4b0b 100644 --- a/nixos/modules/system/boot/stage-2.nix +++ b/nixos/modules/system/boot/stage-2.nix @@ -10,7 +10,7 @@ let src = ./stage-2-init.sh; shellDebug = "${pkgs.bashInteractive}/bin/bash"; shell = "${pkgs.bash}/bin/bash"; - inherit (config.boot) systemdExecutable; + inherit (config.boot) systemdExecutable extraSystemdUnitPaths; isExecutable = true; inherit (config.nix) readOnlyStore; inherit useHostResolvConf; @@ -20,6 +20,10 @@ let pkgs.util-linux ] ++ lib.optional useHostResolvConf pkgs.openresolv); fsPackagesPath = lib.makeBinPath config.system.fsPackages; + systemdUnitPathEnvVar = lib.optionalString (config.boot.extraSystemdUnitPaths != []) + ("SYSTEMD_UNIT_PATH=" + + builtins.concatStringsSep ":" config.boot.extraSystemdUnitPaths + + ":"); # If SYSTEMD_UNIT_PATH ends with an empty component (":"), the usual unit load path will be appended to the contents of the variable postBootCommands = pkgs.writeText "local-cmds" '' ${config.boot.postBootCommands} @@ -82,6 +86,15 @@ in PATH. ''; }; + + extraSystemdUnitPaths = mkOption { + default = []; + type = types.listOf types.str; + description = '' + Additional paths that get appended to the SYSTEMD_UNIT_PATH environment variable + that can contain mutable unit files. + ''; + }; }; }; |