One flake, two architectures. How is this working?

I have a NixOS systen configuration flake that I use for multiple hosts. It imports nixpkgs like so:

{
  description = "Main Flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    [...]
  };

  outputs = { self, nixpkgs, home-manager, nixvirt, ... }@inputs:
  let
    pkgs = import nixpkgs {
      system = "x86_64-linux";
      config.allowUnfree = true;
    };
  in
  {
    nixosConfigurations.caprica = nixpkgs.lib.nixosSystem { [...] };
    nixosConfigurations.aquaria = nixpkgs.lib.nixosSystem { [...] };
    [...]
  };
}

This works perfectly. Recently, I added a Raspberry Pi to my fleet (so aarch64-linux instead of x86_64-linux). I didn’t remember to update the architecture in the flake. And yet… it still works (nearly) perfectly. But how is that possible, since I’m declaring system = "x86_64-linux" for all my systems?

The only reason I know there’s any kind of problem is that I happened to reference a ${pkgs.coreutils} binary in a Home Manager module and that produced an error on the Raspberry Pi because it was the wrong architecture. I understand why it’s complaining about that, but I’m not sure how the rest of the system is functioning right now. Can anyone shed light? If it helps, my complete configuration is in this flake.nix in this repo. Thanks!

This should be dead code, you can remove it.

Also your rpi config should have nixpkgs.hostPlatform = "aarch64-linux"; in the config somewhere.

Also stop using import function for modules, just put the path in imports.

Example of a problematic line:

Shouud just be

  home-manager.users.rob.imports = [ ./modules/home-rob-minimal.nix ];

Thank you for the helpful feedback! I struggled with passing non-default arguments to submodules early on and I hadn’t gotten a chance to go back and clean it up so this was a good exercise.

And getting rid of the “dead” pkgs declaration seems to have fixed the architecture mismatch problem so thanks again. I guess it wasn’t truly dead, but not needed.