Yeah I’ve seen Why can't I use let variables in flake.nix inputs? but I figured it would be rude to bump such an old thread.
I wanted to do this:
inputs =
let
version = "unstable";
in
{
nixpkgs = {
url = if version == "unstable" then
"github:NixOS/nixpkgs/nixpkgs-unstable"
else
"github:NixOS/nixpkgs/nixpkgs-${version}-darwin";
};
nix-darwin = {
url = if version == "unstable" then
"github:lnl7/nix-darwin"
else
"github:lnl7/nix-darwin/nix-darwin-${version}";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = if version == "unstable" then
"github:nix-community/home-manager"
else
"github:nix-community/home-manager/release-${version}";
inputs.nixpkgs.follows = "nixpkgs";
};
};
but that gives me:
error: expected a set but got a thunk at /nix/store/k3q3jn3fc95jb15v0rv5prm9axjc3dlf-source/flake.nix:4:3
A minor annoyance, but…it is kind of annoying. Would also have been nice if such major projects used a consistent convention for the version (though it wouldn’t change much in this case, it’s just one more paper cut).