9 with utils.systemdUtils.unitOptions;
10 with utils.systemdUtils.lib;
14 cfg = config.systemd.nspawn;
16 checkExec = checkUnitConfig "Exec" [
59 (assertValueOneOf "Boot" boolValues)
60 (assertValueOneOf "ProcessTwo" boolValues)
61 (assertValueOneOf "NotifyReady" boolValues)
64 checkFiles = checkUnitConfig "Files" [
76 "PrivateUsersOwnership"
78 (assertValueOneOf "ReadOnly" boolValues)
79 (assertValueOneOf "Volatile" (boolValues ++ [ "state" ]))
80 (assertValueOneOf "PrivateUsersChown" boolValues)
81 (assertValueOneOf "PrivateUsersOwnership" [
89 checkNetwork = checkUnitConfig "Network" [
93 "VirtualEthernetExtra"
101 (assertValueOneOf "Private" boolValues)
102 (assertValueOneOf "VirtualEthernet" boolValues)
106 options = (getAttrs [ "enable" ] sharedOptions) // {
107 execConfig = mkOption {
110 Parameters = "/bin/sh";
112 type = types.addCheck (types.attrsOf unitOption) checkExec;
114 Each attribute in this set specifies an option in the
115 `[Exec]` section of this unit. See
116 {manpage}`systemd.nspawn(5)` for details.
120 filesConfig = mkOption {
123 Bind = [ "/home/alice" ];
125 type = types.addCheck (types.attrsOf unitOption) checkFiles;
127 Each attribute in this set specifies an option in the
128 `[Files]` section of this unit. See
129 {manpage}`systemd.nspawn(5)` for details.
133 networkConfig = mkOption {
138 type = types.addCheck (types.attrsOf unitOption) checkNetwork;
140 Each attribute in this set specifies an option in the
141 `[Network]` section of this unit. See
142 {manpage}`systemd.nspawn(5)` for details.
155 ${attrsToSection def.execConfig}
158 ${attrsToSection def.filesConfig}
161 ${attrsToSection def.networkConfig}
165 base // { unit = makeUnit name base; };
172 systemd.nspawn = mkOption {
174 type = with types; attrsOf (submodule instanceOptions);
175 description = "Definition of systemd-nspawn configurations.";
185 nspawnFile = "${n}.nspawn";
187 nameValuePair nspawnFile (instanceToUnit nspawnFile v)
192 environment.etc."systemd/nspawn".source = mkIf (cfg != { }) (generateUnits {
193 allowCollisions = false;
201 systemd.targets.multi-user.wants = [ "machines.target" ];
202 systemd.services."systemd-nspawn@".environment = {
203 SYSTEMD_NSPAWN_UNIFIED_HIERARCHY = mkDefault "1";