| 9 May 2024 |
jrick | add CGO_ENABLED = 1; to your buildGoModule attrset | 21:12:54 |
jrick | cgo is disabled by default, and any source files that exclude cgo build tags won't be used | 21:14:08 |
jrick | at least i think it is disabled by default. i set it for the cgo things i build | 21:19:20 |
Diamond (it/she) | if it's not already in the nixpkgs file and that does indeed fix the issue, then you should file a PR | 22:01:34 |
Diamond (it/she) | it might be a regression, iirc Go now disables Cgo by default unless it detects CC in the env | 22:01:51 |
Diamond (it/she) | https://tip.golang.org/doc/go1.20 | 22:02:11 |
Diamond (it/she) | The go command now disables cgo by default on systems without a C toolchain. More specifically, when the CGOENABLED environment variable is unset, the CC environment variable is unset, and the default C compiler (typically clang or gcc) is not found in the path, CGOENABLED defaults to 0. As always, you can override the default by setting CGO_ENABLED explicitly.
| 22:02:20 |
| 10 May 2024 |
symys | wait.... It's actually building with encryption support in the VM without adding CGO_ENABLED=1; or gcc or anything. I'm confused, but I guess it's a quirk with my local system after all. Even so, the program does use CGO, and it's not like adding that attribute breaks the build, so should I submit the PR anyway? | 02:44:32 |
Diamond (it/she) | verify that your VM has the same nixpkgs input first | 02:54:01 |
| @brumik1:matrix.org joined the room. | 07:54:38 |
| @cequal:matrix.org joined the room. | 12:26:08 |
| 11 May 2024 |
@brumik1:matrix.org | Hello, bit new here (with nix too). I would like to ask if somebody could clarify for me how do I add a runtimeInput to a go package? I understand that this is not a Go issue as per-say, but rather more flakes/derivation problem.
I use gomod2nix with flake. All works good except that I have a cmd line tool that my go program needs to call. I would like my flake to specify this dependency just like writeShellApplication does. Maybe somebody could help me out or at least give some pointers?
| 08:03:58 |
@brumik1:matrix.org | * Hello, bit new here (with nix too). I would like to ask if somebody could clarify for me how do I add a runtimeInput to a go package? I understand that this is not a Go issue as per-say, but rather more flakes/derivation problem.
I use gomod2nix with flake. All works good except that I have a cmd line tool that my go program needs to call. I would like my flake to specify this dependency just like writeShellApplication does. Maybe somebody could help me out or at least give some pointers?
Edit: the project: https://github.com/brumik/bw-setup-secrets/
| 08:05:22 |
Diamond (it/she) | In reply to @brumik1:matrix.org
Hello, bit new here (with nix too). I would like to ask if somebody could clarify for me how do I add a runtimeInput to a go package? I understand that this is not a Go issue as per-say, but rather more flakes/derivation problem.
I use gomod2nix with flake. All works good except that I have a cmd line tool that my go program needs to call. I would like my flake to specify this dependency just like writeShellApplication does. Maybe somebody could help me out or at least give some pointers?
Edit: the project: https://github.com/brumik/bw-setup-secrets/
you want to add a hook that calls wrapProgram on your binary to wrap it around a shell script that appends the PATH variable appropriately | 09:52:33 |
Diamond (it/she) | you may want to try using postInstall maybe | 09:54:14 |
@brumik1:matrix.org | Thank you for the answer!
PostInstall is part of mkDerivation right? Can I do there writeShellApplication? Some approximate example would help me greatly in my failing attempts
| 10:10:31 |
Diamond (it/she) | `nix buildGoModule { // ... shellHook = } | 23:26:15 |
Diamond (it/she) | omg | 23:26:17 |
Diamond (it/she) | buildGoModule {
# ...
nativeBuildInputs = with pkgs; [
makeWrapper
];
shellHook = ''
wrapProgram $out/bin/progname --set PATH ${lib.makeBinPath with pkgs; [
# runtime packages go here
]}
'';
}
| 23:27:48 |
Diamond (it/she) | buildGoModule {
# ...
nativeBuildInputs = with pkgs; [
makeWrapper
];
shellHook = ''
wrapProgram $out/bin/progname --set PATH ${lib.makeBinPath with pkgs; [
# runtime packages go here
]}
'';
}
| 23:28:15 |
| reese (they/them) left the room. | 23:30:54 |
dnr | I like to do this by having the go program run things by absolute path. You can set this up by taking the binary name from a global and then overriding it with linker flags | 23:45:28 |
dnr | e.g. https://github.com/dnr/nix-sandwich/blob/main/default.nix#L14-L20 | 23:45:36 |
| 12 May 2024 |
Diamond (it/she) | woah | 00:02:50 |
Diamond (it/she) | why? | 00:02:50 |
Diamond (it/she) | this is a really cool project though | 00:03:34 |
@brumik1:matrix.org | I might be mistaken here, but shellHook isnt supposed to be run when entering the shell instead when you build the package? | 09:32:57 |
@brumik1:matrix.org | I do agree the project is really cool dnr! | 09:34:27 |
@brumik1:matrix.org | I ended up with using postFixup. I hope it is not antipattern | 09:47:03 |
dnr | In reply to @diamondburned:matrix.org why? You mean why do it that way? It just seems cleaner to me than using a wrapper. There's just one binary and no script. The disadvantage I guess is that you can't override things by messing with PATH and calling the wrapped binary directly | 19:05:41 |