22 Mar 2024 |
| mrene joined the room. | 00:44:32 |
| @bumperboat:matrix.org changed their display name from bumperboat to bumperboat (UTC+8 when). | 13:27:55 |
| @bumperboat:matrix.org changed their display name from bumperboat (UTC+8 when) to bumperboat (UTC+8). | 15:01:26 |
23 Mar 2024 |
| @federicodschonborn:matrix.org joined the room. | 00:37:08 |
| @jgero:matrix.org joined the room. | 12:04:00 |
24 Mar 2024 |
| hoskellisiera joined the room. | 01:48:44 |
| hoskellisiera changed their profile picture. | 19:48:50 |
25 Mar 2024 |
| stv0g joined the room. | 18:15:27 |
stv0g | Hi all, I am trying to install Ginkgo into my devShell with the version locked in go.sum. In non-Nix environments, I achieve this by simply running 'nix install github.com/path/to/package'. But for nix I am a bit stuck.. | 18:17:16 |
Curid | Stop testing Go like javascript | 18:25:40 |
qbit | stv0g: hi! I assume you mean "go install" vs "nix install" ? :D | 18:51:38 |
stv0g | Oh yeah, sorry | 18:51:49 |
stv0g | This is my current attempt:
pkgs.runCommand "ginkgo" {
nativeBuildInputs = [
pkgs.go
];
} ''
export HOME=$(pwd)
export GO111MODULE=off
export GOPATH=$out
mkdir -p $GOPATH
ln -s ${packages.go-babel.goModules} $out/src
go install -v -n -a github.com/onsi/ginkgo/v2/ginkgo
# mkdir -p $out/bin
# ls -l /build/bin/
# mv /build/bin/ginkgo $out/bin
'';
| 18:52:15 |
qbit | so you have ginkgo in nixpkgs | 18:52:30 |
qbit | no need to go install it | 18:52:35 |
stv0g | The issue is that the version in nixpkgs might not match the version in my go.mod | 18:52:55 |
stv0g | Same is true for other Go tools like protoc-gen-go | 18:53:19 |
qbit | seems you would have the same problem with that approach | 18:54:06 |
stv0g | I've tried to reuse the vendor'ed modules by buildGoModule and then run "go install" with pkgs.runCommand | 18:54:30 |
qbit | i guess it will bump the go.mod file? | 18:54:30 |
stv0g | I guess by using the vendored modules, I am actually ignoring the go.mod already because its only used to build the goModules derivation | 18:55:21 |
qbit | mmm, you might be able to use the FOD modules stuff via GOCACHE | 18:55:42 |
qbit | nothing's gonna be ideal (at least that I can think of) | 18:56:09 |
qbit | maybe vendor your deps, then just build the code locally? | 18:59:18 |
qbit | that'd probably be the cleanest | 18:59:24 |
stv0g | I think I got it working with:
pkgs.runCommand "ginkgo" {
nativeBuildInputs = [
pkgs.go
];
} ''
export HOME=$(pwd)
export GO111MODULE=off
export GOPATH=/build
ln -s ${packages.go-babel.goModules} src
go build -o $out/bin/ginkgo github.com/onsi/ginkgo/v2/ginkgo
'';
| 18:59:54 |
qbit | i'd make it grep the ginkgo version from go.mod and explicitly build the version | 19:00:57 |
qbit | just to be sure | 19:01:00 |
stv0g | Okay also a instresting idea.. But that could still be a different version from whats acutally used by my code I assume.. I would need to check the go.sum file to be 100% certain | 19:07:04 |
qbit | so like: go build -o $out/bin/gnkgo github.com/onsi/ginkgo/v2/ginkgo@$(grep ginkgo go.mod | awk '{print $NF}' | 19:09:32 |