mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 01:59:45 +01:00
home-environment: add hm-version file
This commits adds a file `hm-version` to the generated generation directory. This file will contain the release version, and if available, the Git commit hash.
This commit is contained in:
parent
7dc4e4ebd7
commit
32fe7d2ebb
1 changed files with 29 additions and 0 deletions
|
@ -676,6 +676,33 @@ in
|
||||||
|
|
||||||
${activationCmds}
|
${activationCmds}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
getVersion = pkgs.writeShellScript "get-hm-version" ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "${../.}" || exit 1
|
||||||
|
|
||||||
|
# Get the base release and initialize an empty version suffix.
|
||||||
|
release=$(< .release)
|
||||||
|
suffix=""
|
||||||
|
|
||||||
|
# If we are in a Git repo then update the suffix to be
|
||||||
|
#
|
||||||
|
# .git.HASH
|
||||||
|
#
|
||||||
|
# where HASH are the first 8 characters of the commit hash.
|
||||||
|
if [[ -f .git/HEAD ]]; then
|
||||||
|
ref=$(sed '/ref:/ { s/.* //; }' .git/HEAD)
|
||||||
|
if [[ -f ".git/$ref" ]]; then
|
||||||
|
hash=$(< ".git/$ref")
|
||||||
|
if [[ -n "$hash" ]]; then
|
||||||
|
suffix=".git.''${hash:0:8}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$release$suffix"
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
pkgs.runCommand
|
pkgs.runCommand
|
||||||
"home-manager-generation"
|
"home-manager-generation"
|
||||||
|
@ -685,6 +712,8 @@ in
|
||||||
''
|
''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
|
|
||||||
|
${getVersion} > $out/hm-version
|
||||||
|
|
||||||
cp ${activationScript} $out/activate
|
cp ${activationScript} $out/activate
|
||||||
|
|
||||||
mkdir $out/bin
|
mkdir $out/bin
|
||||||
|
|
Loading…
Reference in a new issue