Why does nixpkgs not contain any packages in this expression?

{
  description = "Build image";
  inputs.nixpkgs.url = "github:nixos/nixpkgs";
  outputs = { self, nixpkgs }: rec {
    nixosConfigurations.rpi = nixpkgs.lib.nixosSystem rec {
      system = "aarch64-linux";
      modules = [
        "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
        {
          boot.kernelPackages = nixpkgs.linuxPackages_latest;
          services.pcscd.enable = true;
          services.udev.packages = [ nixpkgs.yubikey-personalization ];

          environment.systemPackages = [
            nixpkgs.gnupg
            nixpkgs.pinentry-curses
            nixpkgs.pinentry-qt
            nixpkgs.paperkey
            nixpkgs.wget
          ];

          programs = {
            ssh.startAgent = false;
            gnupg.agent = {
              enable = true;
              enableSSHSupport = true;
            };
          };
        }
      ];
    };
    images.rpi = nixosConfigurations.rpi.config.system.build.sdImage;
  };
}

I’m still very new to Nix and I’ve been trying to put together a flake for building raw images to flash NixOS to my RPi. In the above example, I’m getting a bunch of attribute '....' missing errors in the references to nixpkgs. The errors start in the attribute set in the modules array. It seems like it’s somehow getting mutated, but again I’m too much of a beginner to really comprehend what’s going on here. Any help would be appreciated.

nixpkgs is a flake, to access its packages you need to use nixpkgs.legacyPackages.${system}.

Though I’d probably rewrite the module to use a function instead and use the pkgs argsument.

Would you be able to expound on that? Something like this?

{
  description = "Build image";
  inputs.nixpkgs.url = "github:nixos/nixpkgs";
  outputs = { self, nixpkgs }: rec {
    nixosConfigurations.rpi = nixpkgs.lib.nixosSystem rec {
      system = "aarch64-linux";
      modules = [
        "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
        ({ pkgs, ... }: {
          boot.kernelPackages = pkgs.linuxPackages_latest;
          services.pcscd.enable = true;
          services.udev.packages = [ pkgs.yubikey-personalization ];

          environment.systemPackages = [
            pkgs.gnupg
            pkgs.pinentry-curses
            pkgs.pinentry-qt
            pkgs.paperkey
            pkgs.wget
          ];

          programs = {
            ssh.startAgent = false;
            gnupg.agent = {
              enable = true;
              enableSSHSupport = true;
            };
          };
        })
      ];
    };
    images.rpi = nixosConfigurations.rpi.config.system.build.sdImage;
  };
}
1 Like

Exactly, something like that

1 Like