diff options
author | Jasper Ras <jaspert.ras@gmail.com> | 2025-04-26 13:13:58 +0200 |
---|---|---|
committer | Jasper Ras <jaspert.ras@gmail.com> | 2025-04-26 13:13:58 +0200 |
commit | f0a7d563a385663513f24aecad92219ecfc83bd8 (patch) | |
tree | d3b201241bd8934a63646d26a94c9b2730775ca0 /Building Go applications or packages with Nix.md | |
parent | 80325cced8485df9d87c1b5d9f5d123d85b01336 (diff) |
vault backup: 2025-04-26 13:13:58
Diffstat (limited to 'Building Go applications or packages with Nix.md')
-rw-r--r-- | Building Go applications or packages with Nix.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Building Go applications or packages with Nix.md b/Building Go applications or packages with Nix.md new file mode 100644 index 0000000..27be8e1 --- /dev/null +++ b/Building Go applications or packages with Nix.md @@ -0,0 +1,35 @@ +--- +tags: + - nix +--- +In [[A nice way to test flake output]] we see a failing build due to `go build` requiring an intermediate caching step. + +I learnt [from this article](https://discourse.nixos.org/t/go-package-compilation/29165/2) that there are some helper functions in Nixpkgs to build go packages that we should use. + +The [Go](https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix) section of the Nixpkgs manual describes this proces in detail. + +Useful example: +```nix +{ + pet = buildGoModule rec { + pname = "pet"; + version = "0.3.4"; + + src = fetchFromGitHub { + owner = "knqyf263"; + repo = "pet"; + rev = "v${version}"; + hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; + }; + + vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA="; + + meta = { + description = "Simple command-line snippet manager, written in Go"; + homepage = "https://github.com/knqyf263/pet"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ kalbasit ]; + }; + }; +} +``` |