1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

Switch to extended Nixpkg's lib

This change makes use of the `extend` function inside `lib` to inject
a new `hm` field containing the Home Manager library functions. This
simplifies use of the Home Manager library in the modules and reduces
the risk of accidental infinite recursion.

PR #994
This commit is contained in:
Robert Helgesson 2020-01-16 23:41:14 +01:00
parent c8323a0bf1
commit 6e4b9af080
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
19 changed files with 136 additions and 75 deletions

View file

@ -6,8 +6,6 @@ let
cfg = config.home.file;
dag = config.lib.dag;
homeDirectory = config.home.homeDirectory;
fileType = (import lib/file-type.nix {
@ -43,7 +41,7 @@ in
config = {
# This verifies that the links we are about to create will not
# overwrite an existing file.
home.activation.checkLinkTargets = dag.entryBefore ["writeBoundary"] (
home.activation.checkLinkTargets = hm.dag.entryBefore ["writeBoundary"] (
let
check = pkgs.writeText "check" ''
. ${./lib-bash/color-echo.sh}
@ -113,7 +111,7 @@ in
# and a failure during the intermediate state FA ∩ FB will not
# result in lost links because this set of links are in both the
# source and target generation.
home.activation.linkGeneration = dag.entryAfter ["writeBoundary"] (
home.activation.linkGeneration = hm.dag.entryAfter ["writeBoundary"] (
let
link = pkgs.writeText "link" ''
newGenFiles="$1"
@ -210,7 +208,7 @@ in
''
);
home.activation.checkFilesChanged = dag.entryBefore ["linkGeneration"] (
home.activation.checkFilesChanged = hm.dag.entryBefore ["linkGeneration"] (
''
declare -A changedFiles
'' + concatMapStrings (v: ''
@ -220,7 +218,7 @@ in
'') (filter (v: v.onChange != "") (attrValues cfg))
);
home.activation.onFilesChange = dag.entryAfter ["linkGeneration"] (
home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] (
concatMapStrings (v: ''
if [[ ${"$\{changedFiles"}["${v.target}"]} -eq 1 ]]; then
${v.onChange}