mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2025-03-16 13:28:20 +00:00
The `anything` type is too strict, because it uses `attrsOf` internally, filtering out `mkIf` attrs and therefore evaluating attribute values when only the names would be needed. Furthermore, it is not safe to make assumptions about the objects in legacyPackages, because while most attributes contain packages or package sets, anything is allowed, so we don't know for sure how to merge. Fixes #52
55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
{ config, lib, flake-parts-lib, ... }:
|
|
let
|
|
inherit (lib)
|
|
filterAttrs
|
|
mapAttrs
|
|
mkOption
|
|
optionalAttrs
|
|
types
|
|
;
|
|
inherit (flake-parts-lib)
|
|
mkSubmoduleOptions
|
|
mkPerSystemOption
|
|
;
|
|
in
|
|
{
|
|
options = {
|
|
flake = mkSubmoduleOptions {
|
|
legacyPackages = mkOption {
|
|
type = types.lazyAttrsOf (types.lazyAttrsOf types.raw);
|
|
default = { };
|
|
description = ''
|
|
Per system, an attribute set of unmergeable values. This is also used by <literal>nix build .#<attrpath></literal>.
|
|
'';
|
|
};
|
|
};
|
|
|
|
perSystem = mkPerSystemOption ({ config, ... }: {
|
|
options = {
|
|
legacyPackages = mkOption {
|
|
type = types.lazyAttrsOf types.raw;
|
|
default = { };
|
|
description = ''
|
|
An attribute set of unmergeable values. This is also used by <literal>nix build .#<attrpath></literal>.
|
|
'';
|
|
};
|
|
};
|
|
});
|
|
};
|
|
|
|
config = {
|
|
flake.legacyPackages =
|
|
mapAttrs
|
|
(k: v: v.legacyPackages)
|
|
(filterAttrs
|
|
(k: v: v.legacyPackages != null)
|
|
config.allSystems
|
|
);
|
|
|
|
perInput = system: flake:
|
|
optionalAttrs (flake?legacyPackages.${system}) {
|
|
legacyPackages = flake.legacyPackages.${system};
|
|
};
|
|
|
|
};
|
|
}
|