fort-nix / nix-bitcoin

A collection of Nix packages and NixOS modules for easily installing full-featured Bitcoin nodes with an emphasis on security.
https://nixbitcoin.org
MIT License
513 stars 107 forks source link

`useVersionLockedPkgs = true` causes build error #709

Closed kmajs closed 2 months ago

kmajs commented 5 months ago

After upgrading to NixOS 24.05 and setting useVersionLockedPkgs = true, I get the following error:

$ nixos-rebuild switch --flake .#host1 --target-host "root@host1"
...
error: Neither nixpkgs.system nor any other option in nixpkgs.* is meant
 to be read by modules and configurations.
 Use pkgs.stdenv.hostPlatform instead.

My flake input is nix-bitcoin.url = "github:fort-nix/nix-bitcoin/release".

(Prior to upgrading my system, NixOS 23.11 worked with the default useVersionLockedPkgs = false.)

kmajs commented 2 months ago

In case anyone else runs into this later, it looks like this is happening when the system argument is omitted in the call to nixpkgs.lib.nixosSystem:

...
nixosConfigurations.bitcoinNode = nixpkgs.lib.nixosSystem {
  system = "x86_64-linux";   #required if useVersionLockedPkgs = true
  modules = [
    nix-bitcoin.nixosModules.default
    ({ ... }: {
      ...
      nixpkgs.system = "x86_64-linux";  # alternatively, can be set modularly
    })
  ];
};

When useVersionLockedPkgs = true, config.nixpkgs.system is used to create nix-bitcoin.pkgs, so it needs to be defined.

erikarvstedt commented 2 months ago

Note that setting system is always required with lib.nixosSystem, regardless of whether useVersionLockedPkgs is enabled or not.

kmajs commented 2 months ago

Thanks, I've added the argument for the nix-bitcoin machine. I think I've been able to omit system for my other nixosConfigurations because I'm using nixpkgs.hostPlatform instead. Apparently, if using a recently generated hardware-configuration.nix, system does not need to be specified. I don't fully understand all the platform/system options in nixpkgs, but it's working now, so I'll keep it. :)