diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 113990814efa..d9dc6549f365 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -321,6 +321,23 @@ in rec {
};
+ pathOptions = unitOptions // {
+
+ pathConfig = mkOption {
+ default = {};
+ example = { PathChanged = "/some/path"; Unit = "changedpath.service"; };
+ type = types.attrsOf unitOption;
+ description = ''
+ Each attribute in this set specifies an option in the
+ [Path] section of the unit. See
+ systemd.path
+ 5 for details.
+ '';
+ };
+
+ };
+
+
mountOptions = unitOptions // {
what = mkOption {
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 49502b3e6851..72d724024093 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -304,6 +304,15 @@ let
'';
};
+ pathToUnit = name: def:
+ { inherit (def) wantedBy requiredBy enable;
+ text = commonUnitText def +
+ ''
+ [Path]
+ ${attrsToSection def.pathConfig}
+ '';
+ };
+
mountToUnit = name: def:
{ inherit (def) wantedBy requiredBy enable;
text = commonUnitText def +
@@ -472,6 +481,13 @@ in
description = "Definition of systemd timer units.";
};
+ systemd.paths = mkOption {
+ default = {};
+ type = types.attrsOf types.optionSet;
+ options = [ pathOptions unitConfig ];
+ description = "Definition of systemd path units.";
+ };
+
systemd.mounts = mkOption {
default = [];
type = types.listOf types.optionSet;
@@ -657,6 +673,7 @@ in
// mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services
// mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
+ // mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths
// listToAttrs (map
(v: let n = escapeSystemdPath v.where;
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)