I’m currently trying to hack together my first package as a go module. I use the file dotcopy.nix
, which looks like:
{ lib
, buildGoModule
, fetchFromGitHub
}:
buildGoModule rec {
pname = "dotcopy";
version = "0.2.9";
src = fetchFromGitHub {
owner = "firesquid6";
repo = "dotcopy";
rev = "v${version}";
hash = "sha256-33cH8Yz2cMZzaoalniRjwy6ooAmy8rhQqf9ZeprpklA=";
};
vendorSha256 = lib.fakeSha256;
meta = with lib; {
description = "A linux dotfile manager";
homepage = "https://dotcopy.firesquid.co";
license = licenses.gpl3;
longDescription = ''
Dotcopy is a linux dotfile manager that allows you to "compile" your dotfiles to use the same template for multiple machines.
'';
maintainers = with maintainers; [ firesquid6 ];
};
}
I also have a default.nix
file in the same directory:
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-22.11";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
{
dotcopy = pkgs.callPackage ./dotcopy.nix { };
}
I then run nix-build
, and get the following behavior:
🕙 22:49:41 ✖ nix-build
these 2 derivations will be built:
/nix/store/w0wwgs90rwlyny4gjkjfx90148z4hnxs-dotcopy-0.2.9-go-modules.drv
/nix/store/ifr8dbnfh5dv5wd7jdda1cl887byc1rg-dotcopy-0.2.9.drv
building '/nix/store/w0wwgs90rwlyny4gjkjfx90148z4hnxs-dotcopy-0.2.9-go-modules.drv'...
unpacking sources
unpacking source archive /nix/store/v5mpqhxh81ij6ckwb1bsfsw6wkzwmj1v-source
source root is source
patching sources
configuring
building
go: errors parsing go.mod:
/build/source/go.mod:3: invalid go version '1.21.6': must match format 1.23
error: builder for '/nix/store/w0wwgs90rwlyny4gjkjfx90148z4hnxs-dotcopy-0.2.9-go-modules.drv' failed with exit code 1;
last 8 log lines:
> unpacking sources
> unpacking source archive /nix/store/v5mpqhxh81ij6ckwb1bsfsw6wkzwmj1v-source
> source root is source
> patching sources
> configuring
> building
> go: errors parsing go.mod:
> /build/source/go.mod:3: invalid go version '1.21.6': must match format 1.23
For full logs, run 'nix log /nix/store/w0wwgs90rwlyny4gjkjfx90148z4hnxs-dotcopy-0.2.9-go-modules.drv'.
error: 1 dependencies of derivation '/nix/store/ifr8dbnfh5dv5wd7jdda1cl887byc1rg-dotcopy-0.2.9.drv' failed to build
To me, it seems like buildGoModule is trying to compile my 1.21.6 module as 1.23, and failing because of that. Here is my project if the source code is the culprit: https://github.com/firesquid6/dotcopy.