I want to replace all occurrences of string 25.05 with references to top-level global variable systemVersion in the flake.nix.
sudo nixos-rebuild switch --flake .#<hostname> produces the following error:
error:
… while evaluating the file '/nix/store/8pn89la8gksmhwxr3p66j50q2smwbwnl-source/flake.nix':
error: file '/nix/store/8pn89la8gksmhwxr3p66j50q2smwbwnl-source/flake.nix' must be an attribute set
Code:
let
systemVersion = "25.05";
in {
description = "whiteman808's config for NixOS";
inputs = {
## NixOS ecosystem
nixpkgs.url = "github:NixOS/nixpkgs/nixos-${systemVersion}";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
# home-manager, used for managing user configuration
home-manager = {
url = "github:nix-community/home-manager/release-${systemVersion}";
# The `follows` keyword in inputs is used for inheritance.
# Here, `inputs.nixpkgs` of home-manager is kept consistent with
# the `inputs.nixpkgs` of the current flake,
# to avoid problems caused by different versions of nixpkgs.
inputs.nixpkgs.follows = "nixpkgs";
};
# credential management in flake
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
<other-stuff-here>
}