Hi, I would like to provide the pkgs.* used in checks.* in a devShell. I can add them to the buildInputs list of devShell as shown in the example flake below. But, the duplication doesn’t look nice. Is there a more elegant solution?
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
in rec {
checks = with pkgs.python3Packages; {
hello = pkgs.runCommand "hello" { } ''
${pkgs.hello}/bin/hello
mkdir $out
'';
};
devShell = pkgs.mkShell {
# XXX: I don't want to duplicate all pkgs.* used in checks.* here:
buildInputs = [ pkgs.hello ];
};
});
}
This is what the self argument of the flake is for: referencing other outputs in the same flake.
I pretty always define an overlay and use it to get the pkgs. I.e. Personally I’ve found that things evolve into a pattern roughly like this on most non-trivial things I’ve tried:
IMHO, overlay should almost be mandatory and then package, devShell, check etc as optional extras. (It’s quite easy to tie yourself into knots with self if you’re not careful)