From 4312cfdbda1855088905a3d9959a4fac362fd051 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 5 Oct 2018 10:48:42 -0400 Subject: version.nix: extract revision-fetching function --- lib/trivial.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/trivial.nix b/lib/trivial.nix index b1eea0bf1247..938df6ced476 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -105,6 +105,16 @@ rec { then lib.strings.fileContents suffixFile else "pre-git"; + # Attempt to get the revision nixpkgs is from + revisionWithDefault = default: + let + revisionFile = "${toString ./..}/.git-revision"; + gitRepo = "${toString ./..}/.git"; + in if lib.pathIsDirectory gitRepo + then lib.commitIdFromGitRepo gitRepo + else if lib.pathExists revisionFile then lib.fileContents revisionFile + else default; + nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version; # Whether we're being called by nix-shell. -- cgit 1.4.1