mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
Add transposition.<name>.adHoc
This commit is contained in:
parent
6269836424
commit
0c8eff7513
2 changed files with 38 additions and 1 deletions
10
README.md
10
README.md
|
@ -128,3 +128,13 @@ Why so many ways?
|
||||||
|
|
||||||
1. Flakes counterintuitively handles `system` by enumerating all of them in attribute sets. `flake-parts` does not impose this restriction, but does need to support it.
|
1. Flakes counterintuitively handles `system` by enumerating all of them in attribute sets. `flake-parts` does not impose this restriction, but does need to support it.
|
||||||
2. `flake-parts` provides an extensible structure that is richer than the flakes interface alone.
|
2. `flake-parts` provides an extensible structure that is richer than the flakes interface alone.
|
||||||
|
|
||||||
|
# How do I define my own flake output attribute?
|
||||||
|
|
||||||
|
Have a look at the [source](https://github.com/hercules-ci/flake-parts/tree/main/modules) for some examples.
|
||||||
|
|
||||||
|
Whether directly or indirectly, you'll be defining an attribute inside [the `flake` option](https://flake.parts/options.html#opt-flake).
|
||||||
|
|
||||||
|
If you want the attribute to be derived from [`perSystem`](https://flake.parts/options.html#opt-perSystem) you can start with [`packages.nix`](https://github.com/hercules-ci/flake-parts/blob/main/modules/packages.nix) as an example, or [`formatter.nix`](https://github.com/hercules-ci/flake-parts/blob/main/modules/formatter.nix) if you need to do some filtering.
|
||||||
|
|
||||||
|
If you really don't care about your attribute, you may temporarily use [`transposition.<name>.adHoc = true`](https://flake.parts/options.html#opt-transposition._name_.adHoc) to create and expose a `perSystem` option without merging support, type checking or documentation.
|
||||||
|
|
|
@ -11,6 +11,23 @@ let
|
||||||
mkSubmoduleOptions
|
mkSubmoduleOptions
|
||||||
mkPerSystemOption
|
mkPerSystemOption
|
||||||
;
|
;
|
||||||
|
|
||||||
|
transpositionModule = {
|
||||||
|
options = {
|
||||||
|
adHoc = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to provide a stub option declaration for <option>perSystem.<name></option>
|
||||||
|
|
||||||
|
The stub option declaration does not support merging and lacks
|
||||||
|
documentation, so you are recommended to declare the <option>perSystem.<name></option>
|
||||||
|
option yourself and avoid <option>adHoc</option>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -30,7 +47,7 @@ in
|
||||||
'';
|
'';
|
||||||
type =
|
type =
|
||||||
types.lazyAttrsOf
|
types.lazyAttrsOf
|
||||||
(types.submoduleWith { modules = [ ]; });
|
(types.submoduleWith { modules = [ transpositionModule ]; });
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,5 +69,15 @@ in
|
||||||
(attrName: attrConfig: flake?${attrName}.${system})
|
(attrName: attrConfig: flake?${attrName}.${system})
|
||||||
config.transposition
|
config.transposition
|
||||||
);
|
);
|
||||||
|
|
||||||
|
perSystem = { ... }: {
|
||||||
|
options =
|
||||||
|
mapAttrs
|
||||||
|
(k: v: lib.mkOption { })
|
||||||
|
(filterAttrs
|
||||||
|
(k: v: v.adHoc)
|
||||||
|
config.transposition
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue