mirror of
https://github.com/nix-community/home-manager
synced 2024-12-01 07:29:46 +01:00
made activationPackage working on deployment host
When cross-compiling a profile, the build machine is different from the target machine. Hence when $HOME is shared betwen the two machines, this patch allows to deploy the profile from the build machine when `home.activationPackageSet = pkgs.buildPackages`.
This commit is contained in:
parent
e84811035d
commit
035d5caf09
5 changed files with 44 additions and 31 deletions
|
@ -79,7 +79,7 @@ in
|
|||
(mapAttrsToList (n: v: v.target)
|
||||
(filterAttrs (n: v: v.force) cfg));
|
||||
|
||||
check = pkgs.writeText "check" ''
|
||||
check = config.home.activationPackageSet.writeText "check" ''
|
||||
${config.lib.bash.initHomeManagerLib}
|
||||
|
||||
# A symbolic link whose target path matches this pattern will be
|
||||
|
@ -168,7 +168,7 @@ in
|
|||
# source and target generation.
|
||||
home.activation.linkGeneration = hm.dag.entryAfter ["writeBoundary"] (
|
||||
let
|
||||
link = pkgs.writeShellScript "link" ''
|
||||
link = config.home.activationPackageSet.writeShellScript "link" ''
|
||||
${config.lib.bash.initHomeManagerLib}
|
||||
|
||||
newGenFiles="$1"
|
||||
|
|
|
@ -425,6 +425,11 @@ in
|
|||
description = "The package containing the complete activation script.";
|
||||
};
|
||||
|
||||
home.activationPackageSet = mkOption {
|
||||
type = with types; lazyAttrsOf anything;
|
||||
description = "The package set to be used to in the complete activation script.";
|
||||
};
|
||||
|
||||
home.extraActivationPath = mkOption {
|
||||
internal = true;
|
||||
type = types.listOf types.package;
|
||||
|
@ -649,6 +654,7 @@ in
|
|||
source ${../lib/bash/home-manager.sh}
|
||||
'';
|
||||
|
||||
home.activationPackageSet = lib.mkDefault pkgs;
|
||||
home.activationPackage =
|
||||
let
|
||||
mkCmd = res: ''
|
||||
|
@ -666,7 +672,7 @@ in
|
|||
# Programs that always should be available on the activation
|
||||
# script's PATH.
|
||||
activationBinPaths = lib.makeBinPath (
|
||||
with pkgs; [
|
||||
with cfg.activationPackageSet; [
|
||||
bash
|
||||
coreutils
|
||||
diffutils # For `cmp` and `diff`.
|
||||
|
@ -685,11 +691,11 @@ in
|
|||
if config.nix.enable && config.nix.package != null then
|
||||
":${config.nix.package}/bin"
|
||||
else
|
||||
":$(${pkgs.coreutils}/bin/dirname $(${pkgs.coreutils}/bin/readlink -m $(type -p nix-env)))"
|
||||
":$(${cfg.activationPackageSet.coreutils}/bin/dirname $(${cfg.activationPackageSet.coreutils}/bin/readlink -m $(type -p nix-env)))"
|
||||
)
|
||||
+ optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH";
|
||||
|
||||
activationScript = pkgs.writeShellScript "activation-script" ''
|
||||
activationScript = cfg.activationPackageSet.writeShellScript "activation-script" ''
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
|
|
|
@ -85,36 +85,43 @@ in {
|
|||
'';
|
||||
|
||||
home.activation.dconfSettings = hm.dag.entryAfter [ "installPackages" ] (let
|
||||
iniFile = pkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings);
|
||||
iniFile = config.home.activationPackageSet.writeText "hm-dconf.ini"
|
||||
(toDconfIni cfg.settings);
|
||||
|
||||
statePath = "state/${stateDconfKeys.name}";
|
||||
|
||||
cleanup = pkgs.writeShellScript "dconf-cleanup" ''
|
||||
set -euo pipefail
|
||||
cleanup =
|
||||
config.home.activationPackageSet.writeShellScript "dconf-cleanup" ''
|
||||
set -euo pipefail
|
||||
|
||||
${config.lib.bash.initHomeManagerLib}
|
||||
${config.lib.bash.initHomeManagerLib}
|
||||
|
||||
PATH=${makeBinPath [ pkgs.dconf pkgs.jq ]}''${PATH:+:}$PATH
|
||||
PATH=${
|
||||
makeBinPath [
|
||||
config.home.activationPackageSet.dconf
|
||||
config.home.activationPackageSet.jq
|
||||
]
|
||||
}''${PATH:+:}$PATH
|
||||
|
||||
oldState="$1"
|
||||
newState="$2"
|
||||
oldState="$1"
|
||||
newState="$2"
|
||||
|
||||
# Can't do cleanup if we don't know the old state.
|
||||
if [[ ! -f $oldState ]]; then
|
||||
exit 0
|
||||
fi
|
||||
# Can't do cleanup if we don't know the old state.
|
||||
if [[ ! -f $oldState ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Reset all keys that are present in the old generation but not the new
|
||||
# one.
|
||||
jq -r -n \
|
||||
--slurpfile old "$oldState" \
|
||||
--slurpfile new "$newState" \
|
||||
'($old[] - $new[])[]' \
|
||||
| while read -r key; do
|
||||
verboseEcho "Resetting dconf key \"$key\""
|
||||
run $DCONF_DBUS_RUN_SESSION dconf reset "$key"
|
||||
done
|
||||
'';
|
||||
# Reset all keys that are present in the old generation but not the new
|
||||
# one.
|
||||
jq -r -n \
|
||||
--slurpfile old "$oldState" \
|
||||
--slurpfile new "$newState" \
|
||||
'($old[] - $new[])[]' \
|
||||
| while read -r key; do
|
||||
verboseEcho "Resetting dconf key \"$key\""
|
||||
run $DCONF_DBUS_RUN_SESSION dconf reset "$key"
|
||||
done
|
||||
'';
|
||||
in ''
|
||||
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
|
||||
export DCONF_DBUS_RUN_SESSION=""
|
||||
|
|
|
@ -106,7 +106,7 @@ in {
|
|||
home.activation.xfconfSettings = hm.dag.entryAfter [ "installPackages" ]
|
||||
(let
|
||||
mkCommand = channel: property: value: ''
|
||||
run ${pkgs.xfce.xfconf}/bin/xfconf-query \
|
||||
run ${cfg.activationPackageSet.xfce.xfconf}/bin/xfconf-query \
|
||||
${
|
||||
escapeShellArgs ([ "-c" channel "-p" "/${property}" ]
|
||||
++ (if value == null then
|
||||
|
@ -120,13 +120,13 @@ in {
|
|||
(channel: properties: mapAttrsToList (mkCommand channel) properties)
|
||||
cfg.settings;
|
||||
|
||||
load = pkgs.writeShellScript "load-xfconf"
|
||||
load = cfg.activationPackageSet.writeShellScript "load-xfconf"
|
||||
(concatMapStrings concatStrings commands);
|
||||
in ''
|
||||
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
|
||||
export DBUS_RUN_SESSION_CMD=""
|
||||
else
|
||||
export DBUS_RUN_SESSION_CMD="${pkgs.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
|
||||
export DBUS_RUN_SESSION_CMD="${cfg.activationPackageSet.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
|
||||
fi
|
||||
|
||||
run $DBUS_RUN_SESSION_CMD ${load}
|
||||
|
|
|
@ -314,7 +314,7 @@ in {
|
|||
'';
|
||||
legacy = ''
|
||||
PATH=${dirOf cfg.systemctlPath}:$PATH \
|
||||
${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \
|
||||
${cfg.activationPackageSet.ruby}/bin/ruby ${./systemd-activate.rb} \
|
||||
"''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}"
|
||||
'';
|
||||
sd-switch = let
|
||||
|
|
Loading…
Reference in a new issue