nixos/systemd: allow disabling the path default for services (#482045)

This commit is contained in:
Will Fancher 2026-02-10 01:03:13 +00:00 committed by GitHub
commit 999004c3c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 11 deletions

View file

@ -688,17 +688,19 @@ rec {
}; };
}; };
stage2ServiceConfig = { stage2ServiceConfig =
imports = [ serviceConfig ]; { config, ... }:
# Default path for systemd services. Should be quite minimal. {
config.path = mkAfter [ imports = [ serviceConfig ];
pkgs.coreutils # Default path for systemd services. Should be quite minimal.
pkgs.findutils config.path = mkIf config.enableDefaultPath (mkAfter [
pkgs.gnugrep pkgs.coreutils
pkgs.gnused pkgs.findutils
systemd pkgs.gnugrep
]; pkgs.gnused
}; systemd
]);
};
stage1ServiceConfig = serviceConfig; stage1ServiceConfig = serviceConfig;

View file

@ -379,6 +379,14 @@ rec {
''; '';
}; };
enableDefaultPath = mkOption {
default = true;
type = types.bool;
description = ''
Whether to append a minimal default {env}`PATH` environment variable to the service, containing common system utilities.
'';
};
serviceConfig = mkOption { serviceConfig = mkOption {
default = { }; default = { };
example = { example = {