I’m trying to create a nix flake for home manager, and wanting to do it where I have a variable with the version of nixpkgs. However, I get the error:
error: expected a string but got a thunk at /nix/store/c5nmpb64cv23mglknw1n7a2k3cjgz3ys-source/nix-home-manager-gui/.config/nixpkgs/flake.nix:7:3
… in flake attribute 'url'
at /nix/store/c5nmpb64cv23mglknw1n7a2k3cjgz3ys-source/nix-home-manager-gui/.config/nixpkgs/flake.nix:7:3:
6| # Get both NixOS state and NixOS unstable
7| nixpkgs.url = "github:NixOS/nixpkgs/nixos-" + base-state-version;
| ^
8| nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
This is how I’ve got things at the moment in my flake.nix
:
rec {
# Define the common state version
base-state-version = "22.11";
inputs = {
# Get both NixOS state and NixOS unstable
nixpkgs.url = "github:NixOS/nixpkgs/nixos-" + base-state-version;
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
# Get home-manager
home-manager.url = "github:nix-community/home-manager/release-" + base-state-version;
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
.....
Searching around, I cannot find how to non-lazily make a string such that it doesn’t become a thunk. Does anyone have any thoughts?
Also, is there a way to do this without the rec
? Or is this necessary? I’m not too sure on what the effects of using this command.