diff options
author | worldofpeace <worldofpeace@protonmail.ch> | 2020-01-07 21:41:28 -0500 |
---|---|---|
committer | worldofpeace <worldofpeace@protonmail.ch> | 2020-01-07 21:42:14 -0500 |
commit | 1c2e27e4d55d14f8a6d769eb9a27c0bc3c4f883e (patch) | |
tree | 806826db5ae881d7565aaa6169b7e93d7884472e /nixos/modules/system | |
parent | ffe6b959a1c0288c38cbd4850454deeb6f4a18f1 (diff) |
nixos/systemd-lib: don't fail on systemd.packages duplicates
In some cases like we've noticed in https://github.com/NixOS/nixpkgs/issues/76169,
having duplicate packages in systemd.packages like
```
systemd.packages = [ gnome-shell gnome-shell gnome-session ];
```
breaks.
Here we use an associative array to ensure no
duplicate paths when we symlink all the units listed
in systemd.packages.
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/boot/systemd-lib.nix | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/systemd-lib.nix b/nixos/modules/system/boot/systemd-lib.nix index 28ad4f121bbe..fd1a5b9f62c5 100644 --- a/nixos/modules/system/boot/systemd-lib.nix +++ b/nixos/modules/system/boot/systemd-lib.nix @@ -147,7 +147,13 @@ in rec { done # Symlink all units provided listed in systemd.packages. - for i in ${toString cfg.packages}; do + packages="${toString cfg.packages}" + + # Filter duplicate directories + declare -A unique_packages + for k in $packages ; do unique_packages[$k]=1 ; done + + for i in ''${!unique_packages[@]}; do for fn in $i/etc/systemd/${type}/* $i/lib/systemd/${type}/*; do if ! [[ "$fn" =~ .wants$ ]]; then if [[ -d "$fn" ]]; then |