I got this working so far:
outputs = inputs:
let
lib = inputs.nixpkgs.lib.extend (self: super: {
# Polyfill https://github.com/NixOS/nixpkgs/blob/ea77cefecb0ab07e61d6bde3e24c7ae6820b96d5/lib/attrsets.nix#L360
concatMapAttrs = with self; f: v:
foldl' mergeAttrs { }
(attrValues
(mapAttrs f v)
);
});
specialArgs = { inherit lib; };
in
inputs.flake-parts.lib.mkFlake { inherit inputs specialArgs; } {
However, this leads to error: attribute 'fileset' missing
.
For some reason, fileset
attribute gets lost.
After the addition of the following to the lib overlay (with a 2nd nixpkgs, nixpkgs-latest
, added),
fileset = inputs.nixpkgs-latest.lib.fileset;
it works.
More concisely,
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs-latest.url = "github:nixos/nixpkgs/nixpkgs-unstable";
...
};
outputs = inputs:
let
specialArgs.lib = inputs.nixpkgs.lib.extend (self: _: {
# Polyfill what's missing in our `inputs.nixpkgs`.
inherit (inputs.nixpkgs-latest.lib)
concatMapAttrs
fileset;
});
in
inputs.flake-parts.lib.mkFlake { inherit inputs specialArgs; } {
...
Wait, that didn't quite work for treefmt-nix, when using its devShell.
We also need,
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(self: super: {
lib = lib;
})
];
};
Alright, here's the final thing:
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(self: super: {
lib = super.lib.extend (self: super: {
inherit (inputs.nixpkgs-latest.lib) concatMapAttrs;
});
})
];
};
https://github.com/hercules-ci/flake-parts/discussions/234
Last updated: Nov 21 2024 at 09:35 UTC