Commit Graph

25 Commits

Author SHA1 Message Date
Sandro Jäckel
9e5aa81a22
systemd-lib: add name to X-{Reloads,Restart}-Triggers to easily identify to which service/unit/... they belong 2023-09-13 21:03:37 +02:00
nikstur
a662dc8b73 nixos/lib: systemd definition files function
Add a re-usable function that converts an attrset to a directory
containing systemd definition files.
2023-07-26 23:30:08 +02:00
Raito Bezarius
1ca68deebd nixos/networkd: fix netdev MAC addresses asserts
The `||` condition made it fail no matter what because nothing can be none and a proper MAC address.

Thanks to trofi for catching it.
2023-07-20 11:03:46 +02:00
Raito Bezarius
4d38fa043b nixos/networkd: support netdev MAC addresses
According to systemd.netdev manpage:

```
MACAddress=
           Specifies the MAC address to use for the device, or takes the special value "none". When "none", systemd-networkd does not request the MAC address for
           the device, and the kernel will assign a random MAC address. For "tun", "tap", or "l2tp" devices, the MACAddress= setting in the [NetDev] section is
           not supported and will be ignored. Please specify it in the [Link] section of the corresponding systemd.network(5) file. If this option is not set,
           "vlan" device inherits the MAC address of the master interface. For other kind of netdevs, if this option is not set, then the MAC address is
           generated based on the interface name and the machine-id(5).

           Note, even if "none" is specified, systemd-udevd will assign the persistent MAC address for the device, as 99-default.link has
           MACAddressPolicy=persistent. So, it is also necessary to create a custom .link file for the device, if the MAC address assignment is not desired.
```

Therefore, `none` is an acceptable value.
2023-07-04 01:21:35 +02:00
wrvsrx
05129aab01
nixos/lib: save triggers of systemd into nix store 2023-05-11 17:38:54 +08:00
wrvsrx
cc41b47c6f
nixos/lib: hash triggers after converting them to string in systemd-lib
This change is made for two reasons:

1.  If `toString config.restartTriggers` containes `\n`, systemd unit
    file will be ill-formed.
2.  This change can limit length of the trigger, although it doesn't
    matter in most cases.
2023-05-07 09:04:18 +08:00
Sandro Jäckel
a10f3197fc
systemd-lib: fix building -.slice (root slice)
The error was:

dirname: invalid option -- '.'
Try 'dirname --help' for more information.
2023-03-20 01:11:23 +01:00
Artturin
05a2dfd674 lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
2022-12-15 22:25:51 +02:00
Christian Kögler
6d31353099 nixos: Add unit option overrideStrategy 2022-10-27 20:19:18 +02:00
Christian Kögler
c4e0d766b7 nixos/unitGenerator: fix generation for nspawn files 2022-10-23 15:57:55 +02:00
Giulio De Pasquale
fbc8dbb075 nixos/systemd: Add onSuccess module option for units 2022-04-07 13:25:52 +02:00
Janne Heß
7cdc4dd5d1
Merge pull request #164943 from ElvishJerricco/systemd-initrd-reuse-systemd-module
initrd: Opt-in bare bones systemd-based initrd
2022-04-03 15:53:02 +02:00
Janne Heß
b7c62b8238
nixos/systemd-initrd: Remove unit options that don't work 2022-04-01 11:58:30 +02:00
Janne Heß
1e5261f31c
nixos/systemd-lib: Use module composition 2022-04-01 09:57:19 +02:00
Silvan Mosberger
c70a466d21 nixos/systemd: Allow creation of unit directories
This patch allows creation of files like
/etc/systemd/system/user-.slice.d/limits.conf with

    systemd.units."user-.slice.d/limits.conf" = {
      text = ''
        [Slice]
        CPUAccounting=yes
        CPUQuota=50%
      '';
    };

which previously threw an error

Also renames the systemd-unit-path test to sytsemd-misc, and extends it to
test that `systemd.units` can handle directories. In this case we make
sure that resource limits specified in user slices apply.
2022-03-25 17:47:44 +01:00
Florian Klink
fc91cdb5bc nixos/lib/systemd-lib.nix: move comment back down to packages
https://github.com/NixOS/nixpkgs/pull/164943#discussion_r833215903
2022-03-24 19:03:09 +01:00
Florian Klink
e3083decc4 systemd-initrd, systemd-lib: drop initrdServiceToUnit
We can just use serviceToUnit here.
2022-03-24 18:57:16 +01:00
Will Fancher
9828446608 systemd-initrd: Fix Environment= and PATH 2022-03-22 21:28:51 -04:00
Will Fancher
2d4ebf1259 initrd: Optional systemd-based initrd 2022-03-22 21:28:43 -04:00
Will Fancher
25113740a5 nixos: systemd-lib: Make generateUnits general with default args 2022-03-22 07:02:23 -04:00
Bob van der Linden
9bc093b30a
nixos: systemd: split off helper functions into systemd-lib 2022-03-15 21:52:13 +01:00
Guillaume Girol
d6f45aa6c3
Merge pull request #152372 from symphorien/systemd-validate-after
nixos/systemd: validate the values of systemd.services.<name>.after
2022-01-31 20:57:13 +00:00
Guillaume Girol
2a37dd8ab3 nixos/systemd: validate the values of systemd.services.<name>.after
and similar option. Notably check that they end with one of .service,
.target, etc.
2021-12-27 12:00:00 +00:00
Dmitry Kalinkin
07a8ae0c5a
Merge branch 'staging-next' into staging
Conflicts:
	pkgs/development/libraries/log4cplus/default.nix
2021-12-11 14:01:19 -05:00
Will Fancher
851495a752 Move systemd-lib.nix and systemd-unit-options.nix into utils 2021-11-20 17:52:29 -05:00