query
On this page

revisionWithDefault

lib.trivial.revisionWithDefault

Docs pulled from | This Revision | 10 minutes ago


Attempts to return the the current revision of nixpkgs and returns the supplied default value otherwise.

Inputs

default

Default value to return if revision can not be determined

Type

revisionWithDefault :: string -> string

Noogle detected

Implementation

The following is the current implementation of this function.

revisionWithDefault =
    default:
    let
      revisionFile = "${toString ./..}/.git-revision";
      gitRepo = "${toString ./..}/.git";
    in
    if lib.pathIsGitRepo gitRepo then
      lib.commitIdFromGitRepo gitRepo
    else if lib.pathExists revisionFile then
      lib.fileContents revisionFile
    else
      default;