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 286 [fileSystems.overlay](#opt-fileSystems._name_.overlay.lowerdir). See also the 287 287 [NixOS docs](#sec-overlayfs). 288 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 + 289 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`. 290 294 291 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 242 ln -sfn '${name}' $out/'${name2}' 243 243 '') (unit.aliases or [])) units)} 244 244 245 - # Create .wants and .requires symlinks from the wantedBy and 245 + # Create .wants, .upholds and .requires symlinks from the wantedBy, upheldBy and 246 246 # requiredBy options. 247 247 ${concatStrings (mapAttrsToList (name: unit: 248 248 concatMapStrings (name2: '' 249 249 mkdir -p $out/'${name2}.wants' 250 250 ln -sfn '../${name}' $out/'${name2}.wants'/ 251 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)} 252 258 253 259 ${concatStrings (mapAttrsToList (name: unit: 254 260 concatMapStrings (name2: '' ··· 289 295 { Requires = toString config.requires; } 290 296 // optionalAttrs (config.wants != []) 291 297 { Wants = toString config.wants; } 298 + // optionalAttrs (config.upholds != []) 299 + { Upholds = toString config.upholds; } 292 300 // optionalAttrs (config.after != []) 293 301 { After = toString config.after; } 294 302 // optionalAttrs (config.before != [])
+17
nixos/lib/systemd-unit-options.nix
··· 74 74 ''; 75 75 }; 76 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 + 77 86 wantedBy = mkOption { 78 87 default = []; 79 88 type = types.listOf unitNameType; ··· 144 153 type = types.listOf unitNameType; 145 154 description = lib.mdDoc '' 146 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`. 147 164 ''; 148 165 }; 149 166