Merge pull request #291 from hercules-ci/better-dogfooding
Add `flake-parts-lib.importAndPublish`
This commit is contained in:
commit
9305fe4e5c
2 changed files with 33 additions and 0 deletions
|
|
@ -169,6 +169,22 @@ rec {
|
|||
partitionedAttrs.devShells = "dev";
|
||||
});
|
||||
|
||||
dogfoodProvider = mkFlake
|
||||
{ inputs.self = { }; }
|
||||
({ flake-parts-lib, ... }: {
|
||||
imports = [
|
||||
(flake-parts-lib.importAndPublish "dogfood" { flake.marker = "dogfood"; })
|
||||
];
|
||||
});
|
||||
|
||||
dogfoodConsumer = mkFlake
|
||||
{ inputs.self = { }; }
|
||||
({ flake-parts-lib, ... }: {
|
||||
imports = [
|
||||
dogfoodProvider.modules.flake.dogfood
|
||||
];
|
||||
});
|
||||
|
||||
runTests = ok:
|
||||
|
||||
assert empty == {
|
||||
|
|
@ -255,6 +271,9 @@ rec {
|
|||
|
||||
assert builtins.isAttrs partitionWithoutExtraInputsFlake.devShells.x86_64-linux;
|
||||
|
||||
assert dogfoodProvider.marker == "dogfood";
|
||||
assert dogfoodConsumer.marker == "dogfood";
|
||||
|
||||
ok;
|
||||
|
||||
result = runTests "ok";
|
||||
|
|
|
|||
14
lib.nix
14
lib.nix
|
|
@ -221,6 +221,20 @@ let
|
|||
importApply =
|
||||
modulePath: staticArgs:
|
||||
lib.setDefaultModuleLocation modulePath (import modulePath staticArgs);
|
||||
|
||||
/**
|
||||
`importAndPublish name module` returns a module that both imports the `module`, and exposes it as flake attribute `modules.flake.${name}`.
|
||||
|
||||
This also imports the optional [`modules`](https://flake.parts/options/flake-parts-modules.html) module to support that.
|
||||
*/
|
||||
importAndPublish = name: module: { lib, ... }: {
|
||||
_class = "flake";
|
||||
imports = [
|
||||
module
|
||||
./extras/modules.nix
|
||||
];
|
||||
flake.modules.flake.${name} = module;
|
||||
};
|
||||
};
|
||||
|
||||
# A best effort, lenient estimate. Please use a recent nixpkgs lib if you
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue