mirror of
https://github.com/nix-community/home-manager
synced 2025-01-11 19:49:49 +01:00
files: minor cleanup
This commit is contained in:
parent
85d67b0a6e
commit
9b7a90daa1
1 changed files with 15 additions and 11 deletions
|
@ -162,7 +162,7 @@ in
|
||||||
# source and target generation.
|
# source and target generation.
|
||||||
home.activation.linkGeneration = hm.dag.entryAfter ["writeBoundary"] (
|
home.activation.linkGeneration = hm.dag.entryAfter ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
link = pkgs.writeText "link" ''
|
link = pkgs.writeShellScript "link" ''
|
||||||
newGenFiles="$1"
|
newGenFiles="$1"
|
||||||
shift
|
shift
|
||||||
for sourcePath in "$@" ; do
|
for sourcePath in "$@" ; do
|
||||||
|
@ -177,7 +177,7 @@ in
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
cleanup = pkgs.writeText "cleanup" ''
|
cleanup = pkgs.writeShellScript "cleanup" ''
|
||||||
. ${./lib-bash/color-echo.sh}
|
. ${./lib-bash/color-echo.sh}
|
||||||
|
|
||||||
# A symbolic link whose target path matches this pattern will be
|
# A symbolic link whose target path matches this pattern will be
|
||||||
|
@ -257,7 +257,9 @@ in
|
||||||
);
|
);
|
||||||
|
|
||||||
home.activation.checkFilesChanged = hm.dag.entryBefore ["linkGeneration"] (
|
home.activation.checkFilesChanged = hm.dag.entryBefore ["linkGeneration"] (
|
||||||
''
|
let
|
||||||
|
homeDirArg = escapeShellArg homeDirectory;
|
||||||
|
in ''
|
||||||
function _cmp() {
|
function _cmp() {
|
||||||
if [[ -d $1 && -d $2 ]]; then
|
if [[ -d $1 && -d $2 ]]; then
|
||||||
diff -rq "$1" "$2" &> /dev/null
|
diff -rq "$1" "$2" &> /dev/null
|
||||||
|
@ -266,10 +268,14 @@ in
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
declare -A changedFiles
|
declare -A changedFiles
|
||||||
'' + concatMapStrings (v: ''
|
'' + concatMapStrings (v:
|
||||||
_cmp ${escapeShellArg (sourceStorePath v)} ${escapeShellArg homeDirectory}/${escapeShellArg v.target} \
|
let
|
||||||
&& changedFiles[${escapeShellArg v.target}]=0 \
|
sourceArg = escapeShellArg (sourceStorePath v);
|
||||||
|| changedFiles[${escapeShellArg v.target}]=1
|
targetArg = escapeShellArg v.target;
|
||||||
|
in ''
|
||||||
|
_cmp ${sourceArg} ${homeDirArg}/${targetArg} \
|
||||||
|
&& changedFiles[${targetArg}]=0 \
|
||||||
|
|| changedFiles[${targetArg}]=1
|
||||||
'') (filter (v: v.onChange != "") (attrValues cfg))
|
'') (filter (v: v.onChange != "") (attrValues cfg))
|
||||||
+ ''
|
+ ''
|
||||||
unset -f _cmp
|
unset -f _cmp
|
||||||
|
@ -286,12 +292,10 @@ in
|
||||||
|
|
||||||
# Symlink directories and files that have the right execute bit.
|
# Symlink directories and files that have the right execute bit.
|
||||||
# Copy files that need their execute bit changed.
|
# Copy files that need their execute bit changed.
|
||||||
home-files = pkgs.runCommand
|
home-files = pkgs.runCommandLocal
|
||||||
"home-manager-files"
|
"home-manager-files"
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [ pkgs.xorg.lndir ];
|
nativeBuildInputs = [ pkgs.xorg.lndir ];
|
||||||
preferLocalBuild = true;
|
|
||||||
allowSubstitutes = false;
|
|
||||||
}
|
}
|
||||||
(''
|
(''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
|
|
Loading…
Reference in a new issue