How can I pass "inputs" as specialArgs in a flake?

I’m trying to use “inputs” inside home-manager.nix, but I failboat

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixos-hardware.url = "github:nixos/nixos-hardware";
  };
  outputs = { self, nixpkgs, nixos-hardware }: rec {
    images = {
      pi = (self.nixosConfigurations.pi.extendModules {
        modules = [
          "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
          {
            disabledModules = [ "profiles/base.nix" ];
          }
        ];
      }).config.system.build.sdImage;
    };

    sdImage.compressImage = false;
    
    packages.x86_64-linux.pi-image = images.pi;
    packages.aarch64-linux.pi-image = images.pi;
    nixosConfigurations = {
      pi = nixpkgs.lib.nixosSystem {
        system = "aarch64-linux";
        modules = [
          nixos-hardware.nixosModules.raspberry-pi-4
          "${nixpkgs}/nixos/modules/profiles/minimal.nix"
          ./configuration.nix
          ./hydra.xorg.lightdm.kodi.nix
          ./base.nix
          ./user.nix
          ./home-manager.nix
          ./bytesized.nix
        ];
        specialArgs = { inherit inputs self; };
      };
    };
  };
}


I get

error: undefined variable 'inputs'

       at /nix/store/5x5w6v9ka446gzv7kib2l2m0hhk993dd-source/flake.nix:35:24:

           34|         ];
           35|         specialArgs = { inherit inputs self; };
             |                        ^
           36|       };

Any ideas what I can try?:wink:

If you make this outputs = inputs @ { self, nixpkgs, ... }, that is the convention and will let you refer to inputs.nixos-hardware and so on, but strictly within this same file. You can pass it elsewhere but I can’t easily cite the required syntax from my mobile and the terminology varies between NixOS modules and HomeManager modules.

1 Like

ok, this actually got me one step further;)

error: attribute 'sops-nix' missing

       at /nix/store/wbw84rmr41mlv8c9593ixas76z0csa0k-source/home-manager.nix:11:5:

           10|   home-manager.sharedModules = [
           11|     inputs.sops-nix.homeManagerModules.sops
             |     ^
           12|   ];

ok, wow, it worked adding also nix-sops;). Thanks

  outputs = inputs @ { self, sops-nix, nixpkgs, nixos-hardware }: rec {

I got some other errors now, but they are unrelated;)

Thanks.