Merge pull request #287743 from nagisa/adds-systemd-upholds

systemd: add support for upholds and upheldBy

authored by Will Fancher and committed by GitHub f7087dd1 aeea37e7

+30 -1
+4
nixos/doc/manual/release-notes/rl-2405.section.md
··· 286 [fileSystems.overlay](#opt-fileSystems._name_.overlay.lowerdir). See also the 287 [NixOS docs](#sec-overlayfs). 288 289 - `stdenv`: The `--replace` flag in `substitute`, `substituteInPlace`, `substituteAll`, `substituteAllStream`, and `substituteStream` is now deprecated if favor of the new `--replace-fail`, `--replace-warn` and `--replace-quiet`. The deprecated `--replace` equates to `--replace-warn`. 290 291 - A new hardening flag, `zerocallusedregs` was made available, corresponding to the gcc/clang option `-fzero-call-used-regs=used-gpr`.
··· 286 [fileSystems.overlay](#opt-fileSystems._name_.overlay.lowerdir). See also the 287 [NixOS docs](#sec-overlayfs). 288 289 + - systemd units can now specify the `Upholds=` and `UpheldBy=` unit dependencies via the aptly 290 + named `upholds` and `upheldBy` options. These options get systemd to enforce that the 291 + dependencies remain continuosly running for as long as the dependent unit is in a running state. 292 + 293 - `stdenv`: The `--replace` flag in `substitute`, `substituteInPlace`, `substituteAll`, `substituteAllStream`, and `substituteStream` is now deprecated if favor of the new `--replace-fail`, `--replace-warn` and `--replace-quiet`. The deprecated `--replace` equates to `--replace-warn`. 294 295 - A new hardening flag, `zerocallusedregs` was made available, corresponding to the gcc/clang option `-fzero-call-used-regs=used-gpr`.
+9 -1
nixos/lib/systemd-lib.nix
··· 242 ln -sfn '${name}' $out/'${name2}' 243 '') (unit.aliases or [])) units)} 244 245 - # Create .wants and .requires symlinks from the wantedBy and 246 # requiredBy options. 247 ${concatStrings (mapAttrsToList (name: unit: 248 concatMapStrings (name2: '' 249 mkdir -p $out/'${name2}.wants' 250 ln -sfn '../${name}' $out/'${name2}.wants'/ 251 '') (unit.wantedBy or [])) units)} 252 253 ${concatStrings (mapAttrsToList (name: unit: 254 concatMapStrings (name2: '' ··· 289 { Requires = toString config.requires; } 290 // optionalAttrs (config.wants != []) 291 { Wants = toString config.wants; } 292 // optionalAttrs (config.after != []) 293 { After = toString config.after; } 294 // optionalAttrs (config.before != [])
··· 242 ln -sfn '${name}' $out/'${name2}' 243 '') (unit.aliases or [])) units)} 244 245 + # Create .wants, .upholds and .requires symlinks from the wantedBy, upheldBy and 246 # requiredBy options. 247 ${concatStrings (mapAttrsToList (name: unit: 248 concatMapStrings (name2: '' 249 mkdir -p $out/'${name2}.wants' 250 ln -sfn '../${name}' $out/'${name2}.wants'/ 251 '') (unit.wantedBy or [])) units)} 252 + 253 + ${concatStrings (mapAttrsToList (name: unit: 254 + concatMapStrings (name2: '' 255 + mkdir -p $out/'${name2}.upholds' 256 + ln -sfn '../${name}' $out/'${name2}.upholds'/ 257 + '') (unit.upheldBy or [])) units)} 258 259 ${concatStrings (mapAttrsToList (name: unit: 260 concatMapStrings (name2: '' ··· 295 { Requires = toString config.requires; } 296 // optionalAttrs (config.wants != []) 297 { Wants = toString config.wants; } 298 + // optionalAttrs (config.upholds != []) 299 + { Upholds = toString config.upholds; } 300 // optionalAttrs (config.after != []) 301 { After = toString config.after; } 302 // optionalAttrs (config.before != [])
+17
nixos/lib/systemd-unit-options.nix
··· 74 ''; 75 }; 76 77 wantedBy = mkOption { 78 default = []; 79 type = types.listOf unitNameType; ··· 144 type = types.listOf unitNameType; 145 description = lib.mdDoc '' 146 Start the specified units when this unit is started. 147 ''; 148 }; 149
··· 74 ''; 75 }; 76 77 + upheldBy = mkOption { 78 + default = []; 79 + type = types.listOf unitNameType; 80 + description = lib.mdDoc '' 81 + Keep this unit running as long as the listed units are running. This is a continuously 82 + enforced version of wantedBy. 83 + ''; 84 + }; 85 + 86 wantedBy = mkOption { 87 default = []; 88 type = types.listOf unitNameType; ··· 153 type = types.listOf unitNameType; 154 description = lib.mdDoc '' 155 Start the specified units when this unit is started. 156 + ''; 157 + }; 158 + 159 + upholds = mkOption { 160 + default = []; 161 + type = types.listOf unitNameType; 162 + description = lib.mdDoc '' 163 + Keeps the specified running while this unit is running. A continuous version of `wants`. 164 ''; 165 }; 166