forked from mirrors/gomod2nix
Precompile internal packages instead of using go run
It shaves off a second or so of wait time per environment.
This commit is contained in:
parent
973b050adf
commit
908ab2bb87
3 changed files with 24 additions and 2 deletions
|
@ -15,6 +15,28 @@ let
|
|||
|
||||
removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
|
||||
|
||||
# Internal only build-time attributes
|
||||
internal =
|
||||
let
|
||||
mkInternalPkg = name: src: pkgs.runCommand "gomod2nix-${name}"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.go ];
|
||||
} ''
|
||||
export HOME=$(mktemp -d)
|
||||
cp ${src} src.go
|
||||
go build -o $out src.go
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
# Create a symlink tree of vendored sources
|
||||
symlink = mkInternalPkg "symlink" ./symlink/symlink.go;
|
||||
|
||||
# Install development dependencies from tools.go
|
||||
install = mkInternalPkg "symlink" ./install/install.go;
|
||||
|
||||
};
|
||||
|
||||
fetchGoModule =
|
||||
{ hash
|
||||
, goPackagePath
|
||||
|
@ -57,7 +79,7 @@ let
|
|||
export GOCACHE=$TMPDIR/go-cache
|
||||
export GOPATH="$TMPDIR/go"
|
||||
|
||||
go run ${./symlink.go}
|
||||
${internal.symlink}
|
||||
${lib.concatStringsSep "\n" localReplaceCommands}
|
||||
|
||||
mv vendor $out
|
||||
|
@ -119,7 +141,7 @@ let
|
|||
cd source
|
||||
ln -s ${vendorEnv} vendor
|
||||
|
||||
go run ${./install.go}
|
||||
${internal.install}
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue