fh
fh copied to clipboard
Generated flake.nix for a go project doesn't work: error: undefined variable 'go_1_20'
I am following zero-to-nix and tried running fh in a simple go project. The generated flake doesn't work. I am a complete newbie, so I'm not sure how to debug the problem.
The generated flake.nix and flake.lock are:
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.10)
{
# A helpful description of your flake
description = "rfc20.org website";
# Flake inputs
inputs = {
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz";
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
};
# Flake outputs that other flakes can use
outputs = { self, flake-schemas, nixpkgs }:
let
# Helpers for producing system-specific outputs
supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in {
# Schemas tell Nix about the structure of your flake's outputs
schemas = flake-schemas.schemas;
# Development environments
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
# Pinned packages available in the environment
packages = with pkgs; [
go_1_20
nixpkgs-fmt
];
};
});
};
}
{
"nodes": {
"flake-schemas": {
"locked": {
"lastModified": 1721999734,
"narHash": "sha256-G5CxYeJVm4lcEtaO87LKzOsVnWeTcHGKbKxNamNWgOw=",
"rev": "0a5c42297d870156d9c57d8f99e476b738dcd982",
"revCount": 75,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.5/0190ef2f-61e0-794b-ba14-e82f225e55e6/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A.tar.gz"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1722087241,
"narHash": "sha256-2ShmEaFi0kJVOEEu5gmlykN5dwjWYWYUJmlRTvZQRpU=",
"rev": "8c50662509100d53229d4be607f1a3a31157fa12",
"revCount": 633516,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2405.633516%2Brev-8c50662509100d53229d4be607f1a3a31157fa12/0190f691-c019-7d99-b723-4b2dd6dfd38f/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
}
},
"root": {
"inputs": {
"flake-schemas": "flake-schemas",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
The output of 'nix develop' is:
% nix develop
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
| ^
10|
… while evaluating derivation 'nix-shell'
whose name attribute is located at /nix/store/d6533m6b80n3c9lia5kvaz59ad3fynwk-source/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
at /nix/store/d6533m6b80n3c9lia5kvaz59ad3fynwk-source/pkgs/stdenv/generic/make-derivation.nix:377:7:
376| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
377| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
378| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: undefined variable 'go_1_20'
at /nix/store/n6zxrknnddqz7hk4z8mijbzia23i43bc-source/flake.nix:30:13:
29| packages = with pkgs; [
30| go_1_20
| ^
31| nixpkgs-fmt
I suppose the cool thing about flakes is that the repro is now available at:
nix develop "github:matta/rfc20?rev=7e841a805579a41d2677667cb2b76b05e2f554d5"
You could try replacing go_1_20 with go_1_21, go_1_22, or go_1_23. go_1_20 was removed because it is EOL.