1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-01 07:29:46 +01:00

home.activationPackageSet -> _module.args.activationPkgs

This commit is contained in:
David Guibert 2024-01-31 08:45:54 +01:00
parent 035d5caf09
commit fb61dd9ea2
6 changed files with 40 additions and 49 deletions

View file

@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ pkgs, activationPkgs, config, lib, ... }:
with lib;
@ -79,7 +79,7 @@ in
(mapAttrsToList (n: v: v.target)
(filterAttrs (n: v: v.force) cfg));
check = config.home.activationPackageSet.writeText "check" ''
check = activationPkgs.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 = config.home.activationPackageSet.writeShellScript "link" ''
link = activationPkgs.writeShellScript "link" ''
${config.lib.bash.initHomeManagerLib}
newGenFiles="$1"

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, activationPkgs, ... }:
with lib;
@ -425,11 +425,6 @@ 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;
@ -654,7 +649,6 @@ in
source ${../lib/bash/home-manager.sh}
'';
home.activationPackageSet = lib.mkDefault pkgs;
home.activationPackage =
let
mkCmd = res: ''
@ -672,7 +666,7 @@ in
# Programs that always should be available on the activation
# script's PATH.
activationBinPaths = lib.makeBinPath (
with cfg.activationPackageSet; [
with activationPkgs; [
bash
coreutils
diffutils # For `cmp` and `diff`.
@ -691,11 +685,11 @@ in
if config.nix.enable && config.nix.package != null then
":${config.nix.package}/bin"
else
":$(${cfg.activationPackageSet.coreutils}/bin/dirname $(${cfg.activationPackageSet.coreutils}/bin/readlink -m $(type -p nix-env)))"
":$(${activationPkgs.coreutils}/bin/dirname $(${activationPkgs.coreutils}/bin/readlink -m $(type -p nix-env)))"
)
+ optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH";
activationScript = cfg.activationPackageSet.writeShellScript "activation-script" ''
activationScript = activationPkgs.writeShellScript "activation-script" ''
set -eu
set -o pipefail

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, activationPkgs, ... }:
with lib;
@ -85,43 +85,39 @@ in {
'';
home.activation.dconfSettings = hm.dag.entryAfter [ "installPackages" ] (let
iniFile = config.home.activationPackageSet.writeText "hm-dconf.ini"
(toDconfIni cfg.settings);
iniFile =
activationPkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings);
statePath = "state/${stateDconfKeys.name}";
cleanup =
config.home.activationPackageSet.writeShellScript "dconf-cleanup" ''
set -euo pipefail
cleanup = activationPkgs.writeShellScript "dconf-cleanup" ''
set -euo pipefail
${config.lib.bash.initHomeManagerLib}
${config.lib.bash.initHomeManagerLib}
PATH=${
makeBinPath [
config.home.activationPackageSet.dconf
config.home.activationPackageSet.jq
]
}''${PATH:+:}$PATH
PATH=${
makeBinPath [ activationPkgs.dconf activationPkgs.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=""

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, activationPkgs, ... }:
with lib;
@ -106,7 +106,7 @@ in {
home.activation.xfconfSettings = hm.dag.entryAfter [ "installPackages" ]
(let
mkCommand = channel: property: value: ''
run ${cfg.activationPackageSet.xfce.xfconf}/bin/xfconf-query \
run ${activationPkgs.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 = cfg.activationPackageSet.writeShellScript "load-xfconf"
load = activationPkgs.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="${cfg.activationPackageSet.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
export DBUS_RUN_SESSION_CMD="${activationPkgs.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
fi
run $DBUS_RUN_SESSION_CMD ${load}

View file

@ -395,6 +395,7 @@ let
else
<nixpkgs>);
_module.args.pkgs = lib.mkDefault pkgs;
_module.args.activationPkgs = lib.mkDefault pkgs;
_module.check = check;
lib = lib.hm;
} // optionalAttrs useNixpkgsModule {

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, activationPkgs, ... }:
let
@ -314,7 +314,7 @@ in {
'';
legacy = ''
PATH=${dirOf cfg.systemctlPath}:$PATH \
${cfg.activationPackageSet.ruby}/bin/ruby ${./systemd-activate.rb} \
${activationPkgs.ruby}/bin/ruby ${./systemd-activate.rb} \
"''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}"
'';
sd-switch = let