Add option systemd.automounts, for definining automount units
This commit is contained in:
parent
9df40867b9
commit
3a17c2b30b
@ -323,4 +323,28 @@ rec {
|
||||
};
|
||||
};
|
||||
|
||||
automountOptions = unitOptions // {
|
||||
|
||||
where = mkOption {
|
||||
example = "/mnt";
|
||||
type = types.uniq types.string;
|
||||
description = ''
|
||||
Absolute path of a directory of the mount point.
|
||||
Will be created if it doesn't exist. (Mandatory)
|
||||
'';
|
||||
};
|
||||
|
||||
automountConfig = mkOption {
|
||||
default = {};
|
||||
example = { DirectoryMode = "0775"; };
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
Each attribute in this set specifies an option in the
|
||||
<literal>[Automount]</literal> section of the unit. See
|
||||
<citerefentry><refentrytitle>systemd.automount</refentrytitle>
|
||||
<manvolnum>5</manvolnum></citerefentry> for details.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -185,6 +185,14 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
automountConfig = { name, config, ... }: {
|
||||
config = {
|
||||
automountConfig =
|
||||
{ Where = config.where;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
toOption = x:
|
||||
if x == true then "true"
|
||||
else if x == false then "false"
|
||||
@ -291,6 +299,18 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
automountToUnit = name: def:
|
||||
{ inherit (def) wantedBy requiredBy enable;
|
||||
text =
|
||||
''
|
||||
[Unit]
|
||||
${attrsToSection def.unitConfig}
|
||||
|
||||
[Automount]
|
||||
${attrsToSection def.automountConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
nixosUnits = mapAttrsToList makeUnit cfg.units;
|
||||
|
||||
units = pkgs.runCommand "units" { preferLocalBuild = true; }
|
||||
@ -440,6 +460,17 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.automounts = mkOption {
|
||||
default = [];
|
||||
type = types.listOf types.optionSet;
|
||||
options = [ automountOptions unitConfig automountConfig ];
|
||||
description = ''
|
||||
Definition of systemd automount units.
|
||||
This is a list instead of an attrSet, because systemd mandates the names to be derived from
|
||||
the 'where' attribute.
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.defaultUnit = mkOption {
|
||||
default = "multi-user.target";
|
||||
type = types.uniq types.string;
|
||||
@ -579,7 +610,10 @@ in
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.timer" (timerToUnit n v)) cfg.timers
|
||||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts);
|
||||
in nameValuePair "${n}.mount" (mountToUnit n v)) cfg.mounts)
|
||||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
||||
|
||||
system.requiredKernelConfig = map config.lib.kernelConfig.isEnabled [
|
||||
"CGROUPS" "AUTOFS4_FS" "DEVTMPFS"
|
||||
|
Loading…
Reference in New Issue
Block a user