From 0b9d9eded15e13079b1f0fef059ecb25bfb308c4 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 9 Aug 2016 14:15:53 +0200 Subject: [PATCH] nixos/version: Try to get Git revison from .git Let's first try if we can determine the Git revision from the .git directory and if that fails, fall back to get the info from the ".git-revision" file... and after that use something generic like "master". This should address #17218 in better way, because we don't need to create another redundant file in the source checkout of nixpkgs. I'm not going to route of falling back to using .git, because after 55d881e, we already have ".git-revision" files in people's Git repositories, which in turn means that nixos-version will report that old file every time even if the working tree has updated. Signed-off-by: aszlig Cc: @bennofs, Profpatsch Reported-by: @devhell Fixes: #17218 --- nixos/modules/misc/version.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 6af310a9d877..2ecdbdbf3925 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -63,7 +63,9 @@ in nixosRevision = mkOption { internal = true; type = types.str; - default = if pathExists revisionFile then fileContents revisionFile else "master"; + default = if pathIsDirectory gitRepo then commitIdFromGitRepo gitRepo + else if pathExists revisionFile then fileContents revisionFile + else "master"; description = "The Git revision from which this NixOS configuration was built."; };