Created
June 29, 2014 19:57
-
-
Save zimbatm/8a3fd32b6aec0cac57f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? (import <nixpkgs> {}) | |
, stdenv ? pkgs.stdenv | |
, go ? pkgs.go | |
, git ? pkgs.git | |
}: | |
rec { | |
readChop = with builtins; path: | |
let | |
str = readFile path; | |
len = stringLength str; | |
in substring 0 (sub len 1) str; | |
gitref = with builtins; dir: | |
let | |
head = readChop (toPath "${dir}/.git/HEAD"); | |
in | |
if (pkgs.lib.hasPrefix "ref: " head) then | |
readChop (substring 3 (sub (stringLength head) 4) head) | |
else | |
head; | |
crank = stdenv.mkDerivation rec { | |
git_version = gitref ./.; | |
version = "1.0.0-${git_version}"; | |
name = "direnv-${version}"; | |
src = ./.; | |
buildInputs = [ go ]; | |
buildPhase = "make"; | |
installPhase = ''make install "DESTDIR=$out"''; | |
dontStrip = 1; | |
meta = { | |
homepage = "http://direnv.net"; | |
description = "path-dependent environments"; | |
maintainers = [ | |
stdenv.lib.maintainers.zimbatm | |
]; | |
license = stdenv.lib.licenses.mit; | |
platforms = go.meta.platforms; | |
}; | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Produces: