bscpkgs/default.nix
Aleix Boné 43d32ac16d Use nixpkgs from flake.lock and support attrs when importing bscpkgs
This makes `nix-build` and friends use the current flake lock instead of
the outdated pinned version we had in `./nixpkgs.nix`

With this, `nix-build -A ovni` and `nix build .#ovni` should produce the
same result.

This will fail if the flake nixpkgs input does not come from NixOS/nixpkgs.
We could use edolstra/flake-compat instead, but it's overkill imho.

Additionally, I made default.nix behave like nixpkgs, so that we can
import bscpkgs à la nixpkgs (Apply overlays and other options that nixpkgs
accepts):

```nix
let pkgs = import bscpkgs { inherit system; }; in <...>
```

Reviewed-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
2025-06-16 12:29:55 +02:00

20 lines
531 B
Nix

let
bscOverlay = import ./overlay.nix;
# read flake.lock and determine revision from there
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.nixpkgs.locked) rev narHash;
fetchedNixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = narHash;
};
in
{ overlays ? [ ]
, nixpkgs ? fetchedNixpkgs
, ...
}@attrs:
import nixpkgs (
(builtins.removeAttrs attrs [ "overlays" "nixpkgs" ]) //
{ overlays = [ bscOverlay ] ++ overlays; }
)