Package an application with Nixpkgs by picking the build helper for its language and setting a few attributes.
Each language ecosystem has its own build helper. See for the full set.
Package a Go application
buildGoModule builds Go programs that use Go modules.
Write the package to package.nix:
buildGoModule needs pname, version, src, and vendorHash.
Pin Nixpkgs and call the package from default.nix:
let nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; pkgs = import nixpkgs { };inpkgs.callPackage ./package.nix { }Build it:
$ nix-build ./default.nix# or equivalent$ nix-buildRun it:
$ ./result/bin/pet --helppet - Simple command-line snippet manager.vendorHash pins the fetched dependencies.
To find its value:
- Set
vendorHashto an empty string"". - Run
nix-build. - Copy the correct value from the error into
vendorHash.
See the Go reference for every attribute and advanced usage.