Newbie question about flake

I am playing with raspberry-pi-nix whose nixosConfigurations is the following.

nixosConfigurations = {
        rpi-example = srcs.nixpkgs.lib.nixosSystem {
          system = "aarch64-linux";
          modules = [ self.nixosModules.raspberry-pi ./example ];
        };
      };

I copied and pasted the “./example” directory to my local directory and wrote the following flake.nix, that has identical rpi-example setup.

{
  description = "raspberry-pi nixos configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
    raspberry-pi-nix.url = "github:nix-community/raspberry-pi-nix?ref=refs/tags/v0.4.1";
  };

  outputs = srcs@{ self, ... }:
    {
      nixosConfigurations = {
        rpi-example = srcs.nixpkgs.lib.nixosSystem {
          system = "aarch64-linux";
          modules = [ srcs.raspberry-pi-nix.nixosModules.raspberry-pi ./example ];
        };
        rpi-example-org = srcs.raspberry-pi-nix.nixosConfigurations.rpi-example;
      };
    };
}

Even though the output rpi-example-org is the same as that of the original rpi-example, the output of rpi-example in my flake.nix is quite different. I expected it to be the same.

What am I missing here…?

Flakes have a lock file which stores the precice version of inputs used, raspberry-pi-nix has nixpkgs locked to ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6.

One common practice when importing flakes is to set inputs.<name>.inputs.follows.nixpkgs = "nixpkgs" so that you only have one version of nixpkgs.

1 Like

You are right!!! I was thinking that fixing the nixpkgs version would be enough. What a newbie…

Let me ask another question. Is it possible to do the opposite of what you proposed? In other words, is it possible to set the local version of nixpkgs precisely the same as that of raspberry-pi-nix?
They have all the binaries in binary cache and I would like to use them. nix build --dry-run tells me that I have to build so many things including linux kernel.

Remove inputs.nixpkgs.url and replace it with inputs.nixpkgs.follows = "raspberry-pi-nix/nixpkgs"

1 Like

That did the trick! Thank you so much…!!!