Merge pull request #44990 from Ma27/reload-user-units-during-activation

nixos/switch-to-configuration: reload user units
This commit is contained in:
Jörg Thalheim 2018-08-27 11:12:42 +01:00 committed by GitHub
commit a6ced42c60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -470,6 +470,13 @@ inherit (pkgs.nixos {
The module option <option>nix.useSandbox</option> is now defaulted to <literal>true</literal>.
</para>
</listitem>
<listitem>
<para>
The config activation script of <literal>nixos-rebuild</literal> now
<link xlink:href="https://www.freedesktop.org/software/systemd/man/systemctl.html#Manager%20Lifecycle%20Commands">reloads</link>
all user units for each authenticated user.
</para>
</listitem>
</itemizedlist>
</section>
</section>

View file

@ -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;