Skip to content

Commit

Permalink
nix: Export submodules, exclude test files, + fixup references to go …
Browse files Browse the repository at this point in the history
…compiler.
  • Loading branch information
mstone committed May 8, 2016
1 parent 099f7c6 commit df670cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{stdenv, goPackages, git, runCommand, makeWrapper}:
{stdenv, lib, goPackages, git, runCommand, makeWrapper}:
let
removeReferences = [ goPackages.go ];
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
'');
in
goPackages.buildGoPackage rec {
name = "focus";

Expand All @@ -10,6 +16,7 @@ goPackages.buildGoPackage rec {
localRev = builtins.readFile ./.git/refs/heads/master;
} ''
mkdir -p $out && git -C ${toString ./.} archive --format=tar $localRev | tar xf - -C $out
git -C ${toString ./.} submodule foreach 'git -C ${toString ./.}/$path archive HEAD | tar xf - -C $out/$path'
cp -r ${toString ./.}/.git $out/.git
'';

Expand All @@ -35,6 +42,16 @@ goPackages.buildGoPackage rec {
(cd go/src/${goPackagePath}; go generate)
'';

excludedPackages = "kitchen-sink";

preFixup = ''
while read file; do
cat $file ${removeExpr removeReferences} > $file.tmp
mv $file.tmp $file
chmod +x $file
done < <(find $out -type f 2>/dev/null)
'';

postInstall = ''
for f in $(find $bin/bin -type f); do
wrapProgram $f \
Expand Down
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ let
};

focus = ((import ./default.nix) {
inherit (pkgs) stdenv makeWrapper runCommand git;
inherit (pkgs) stdenv lib makeWrapper runCommand git;
inherit goPackages;
});
in
Expand Down

0 comments on commit df670cf

Please sign in to comment.