summary refs log tree commit diff
path: root/nixos/modules/system/activation
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-08-27 11:12:42 +0100
committerGitHub <noreply@github.com>2018-08-27 11:12:42 +0100
commita6ced42c606dab553922936a4cbf8f94626d62ff (patch)
tree766f4c242cbc7b1a1549b70448030bcfed8d6d13 /nixos/modules/system/activation
parent8f07a0b420f94d6aaf5afe2e0650752f2b325173 (diff)
parentfc2bde6d7a362a7f75e19f3e445a9b0f528e1681 (diff)
downloadnixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar.gz
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar.bz2
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar.lz
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar.xz
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.tar.zst
nixpkgs-a6ced42c606dab553922936a4cbf8f94626d62ff.zip
Merge pull request #44990 from Ma27/reload-user-units-during-activation
nixos/switch-to-configuration: reload user units
Diffstat (limited to 'nixos/modules/system/activation')
-rw-r--r--nixos/modules/system/activation/switch-to-configuration.pl12
1 files changed, 12 insertions, 0 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl
index ecd35767e01..b3fe6caf62d 100644
--- a/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixos/modules/system/activation/switch-to-configuration.pl
@@ -412,6 +412,18 @@ system("@systemd@/bin/systemctl", "reset-failed");
 # Make systemd reload its units.
 system("@systemd@/bin/systemctl", "daemon-reload") == 0 or $res = 3;
 
+# Reload user units
+open my $listActiveUsers, '-|', '@systemd@/bin/loginctl', 'list-users', '--no-legend';
+while (my $f = <$listActiveUsers>) {
+    next unless $f =~ /^\s*(?<uid>\d+)\s+(?<user>\S+)/;
+    my ($uid, $name) = ($+{uid}, $+{user});
+    print STDERR "reloading user units for $name...\n";
+
+    system("su", "-l", $name, "-c", "XDG_RUNTIME_DIR=/run/user/$uid @systemd@/bin/systemctl --user daemon-reload");
+}
+
+close $listActiveUsers;
+
 # Set the new tmpfiles
 print STDERR "setting up tmpfiles\n";
 system("@systemd@/bin/systemd-tmpfiles", "--create", "--remove", "--exclude-prefix=/dev") == 0 or $res = 3;