diff options
author | Will Fancher <elvishjerricco@gmail.com> | 2022-03-19 23:00:06 -0400 |
---|---|---|
committer | Will Fancher <elvishjerricco@gmail.com> | 2022-03-22 21:28:43 -0400 |
commit | 2d4ebf1259149ac52c191f461eef4eae6c3671fc (patch) | |
tree | e7a95cda3d80c24f28a57f0a4a71ee5d665ec9d5 /nixos/lib | |
parent | 25113740a5063483645cab857716a77437cd881e (diff) | |
download | nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar.gz nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar.bz2 nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar.lz nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar.xz nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.tar.zst nixpkgs-2d4ebf1259149ac52c191f461eef4eae6c3671fc.zip |
initrd: Optional systemd-based initrd
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/systemd-lib.nix | 29 | ||||
-rw-r--r-- | nixos/lib/systemd-types.nix | 1 |
2 files changed, 22 insertions, 8 deletions
diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix index 27c8b5b0471..3129fbe7bdb 100644 --- a/nixos/lib/systemd-lib.nix +++ b/nixos/lib/systemd-lib.nix @@ -291,16 +291,10 @@ in rec { }; }; - serviceConfig = { name, config, ... }: { + mkServiceConfig = path: { name, config, ... }: { config = mkMerge [ { # Default path for systemd services. Should be quite minimal. - path = mkAfter - [ pkgs.coreutils - pkgs.findutils - pkgs.gnugrep - pkgs.gnused - systemd - ]; + path = mkAfter path; environment.PATH = "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}"; } (mkIf (config.preStart != "") @@ -330,6 +324,16 @@ in rec { ]; }; + serviceConfig = mkServiceConfig [ + pkgs.coreutils + pkgs.findutils + pkgs.gnugrep + pkgs.gnused + systemd + ]; + + initrdServiceConfig = mkServiceConfig []; + mountConfig = { config, ... }: { config = { mountConfig = @@ -387,6 +391,15 @@ in rec { ''; }; + initrdServiceToUnit = name: def: + { inherit (def) aliases wantedBy requiredBy enable; + text = commonUnitText def + + '' + [Service] + ${attrsToSection def.serviceConfig} + ''; + }; + socketToUnit = name: def: { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + diff --git a/nixos/lib/systemd-types.nix b/nixos/lib/systemd-types.nix index a7a324f187c..b303335ffc1 100644 --- a/nixos/lib/systemd-types.nix +++ b/nixos/lib/systemd-types.nix @@ -12,6 +12,7 @@ rec { })); services = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ]); + initrdServices = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig initrdServiceConfig ]); targets = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig ]); |