builtins.getFlake attribute 'default' missing

I’m trying to write a shell that uses a flake. This works fine:

nix shell git+https://codeberg.org/mhwombat/hello-flake

So I expected this to work:

with (import <nixpkgs> {});
let
  hello = (builtins.getFlake git+https://codeberg.org/mhwombat/hello-flake).packages.${builtins.currentSystem}.default;
in
mkShell {
  buildInputs = [
    hello
  ];
}

But I get the following error. What am I doing wrong?

$ with (import <nixpkgs> {});
let
  hello = (builtins.getFlake git+https://codeberg.org/mhwombat/hello-flake).packages.${builtins.currentSystem}.default;
in
mkShell {
  buildInputs = [
    hello
  ];
}

Note: I also have a version of the flake https://codeberg.org/mhwombat/hello-flake-compat that uses the flake-compat library. I could use that instead, but if I understand things correctly, I shouldn’t need that to use builtins.getFlake.

If you look at the flake.nix in that repo, or just do a nix flake show on it, you’ll see that it uses defaultPackage, which is deprecated iirc, but still recognized by nix.

1 Like

Based on what @tejing said, I tried this and it worked:

with (import <nixpkgs> {});
let
  hello = (builtins.getFlake git+https://codeberg.org/mhwombat/hello-flake).defaultPackage.${builtins.currentSystem};
#  hello = (builtins.getFlake git+https://codeberg.org/mhwombat/hello-flake).packages.${builtins.currentSystem}.default;
in
mkShell {
  buildInputs = [
    hello
  ];
}