diff --git a/builder/default.nix b/builder/default.nix index 38a115f..4c753a6 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -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} ''; }; diff --git a/builder/install.go b/builder/install/install.go similarity index 100% rename from builder/install.go rename to builder/install/install.go diff --git a/builder/symlink.go b/builder/symlink/symlink.go similarity index 100% rename from builder/symlink.go rename to builder/symlink/symlink.go