Use only tools from Nixpkgs in activation script

Note, we still pull in the user's `PATH` in case the user has defined
their own activation blocks that depend on additional tools.
Eventually this will be deprecated and removed.

See #99.
This commit is contained in:
Robert Helgesson 2017-10-20 14:02:05 +02:00
parent b9f49cee45
commit 30b9d7f00e
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
5 changed files with 43 additions and 3 deletions

View file

@ -248,6 +248,12 @@ in
activationBinPaths = lib.makeBinPath [
pkgs.bash
pkgs.coreutils
pkgs.diffutils # For `cmp` and `diff`.
pkgs.findutils
pkgs.gnugrep
pkgs.gnused
pkgs.ncurses # For `tput`.
pkgs.nix
];
sf = pkgs.writeText "activation-script" ''

View file

@ -351,6 +351,25 @@ in
before that date.
'';
}
{
time = "2017-10-20T12:15:27+00:00";
condition = with config.systemd.user;
services != {} || sockets != {} || targets != {} || timers != {};
message = ''
Home Manager's interaction with systemd is now done using
'systemctl' from Nixpkgs, not the 'systemctl' in '$PATH'.
If you are using a distribution whose systemd is
incompatible with the version in Nixpkgs then you can
override this behavior by adding
systemd.user.systemctlPath = "/usr/bin/systemctl"
to your configuration. Home Manager will then use your
chosen version.
'';
}
];
};
}

View file

@ -64,6 +64,8 @@ in
"${cfg.homeInfoDirLocation}\${INFOPATH:+:}\${INFOPATH}";
home.activation.createHomeInfoDir = dagEntryAfter ["installPackages"] ''
oPATH=$PATH
export PATH="${lib.makeBinPath [ pkgs.gzip ]}''${PATH:+:}$PATH"
$DRY_RUN_CMD mkdir -p "${cfg.homeInfoDirLocation}"
$DRY_RUN_CMD rm -f "${cfg.homeInfoDirLocation}/dir"
if [[ -d "${homeInfoPath}" ]]; then
@ -71,6 +73,8 @@ in
-exec $DRY_RUN_CMD ${infoPkg}/bin/install-info '{}' \
"${cfg.homeInfoDirLocation}/dir" \;
fi
export PATH="$oPATH"
unset oPATH
'';
home.packages = [ infoPkg ];

View file

@ -142,7 +142,7 @@ in
home.activation.applyPolybar = dagEntryAfter [ "reloadSystemD" ] ''
if [[ -v polybarChanged && -v DISPLAY ]]; then
echo "Restarting polybar"
systemctl --user restart polybar.service
${config.systemd.user.systemctlPath} --user restart polybar.service
fi
'';
};

View file

@ -49,6 +49,17 @@ in
options = {
systemd.user = {
systemctlPath = mkOption {
default = "${pkgs.systemd}/bin/systemctl";
defaultText = "\${pkgs.systemd}/bin/systemctl";
type = types.str;
description = ''
Absolute path to the <command>systemctl</command> tool. This
option may need to be set if running Home Manager on a
non-NixOS distribution.
'';
};
services = mkOption {
default = {};
type = types.attrs;
@ -157,7 +168,7 @@ in
local -a toRestart=( )
for f in ''${maybeRestart[@]} ; do
if systemctl --quiet --user is-active "$f" \
if ${cfg.systemctlPath} --quiet --user is-active "$f" \
&& ! cmp --quiet \
"$oldUserServicePath/$f" \
"$newUserServicePath/$f" ; then
@ -187,7 +198,7 @@ in
fi
}
$DRY_RUN_CMD systemctl --user daemon-reload
$DRY_RUN_CMD ${cfg.systemctlPath} --user daemon-reload
systemdPostReload
'';
})