Add the lib default output #4
3 changed files with 70 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
args: {
|
args: {
|
||||||
definition = import ./def.nix;
|
definition = import ./def.nix;
|
||||||
defaultOutputs = {
|
defaultOutputs = {
|
||||||
|
lib = import ./lib.nix;
|
||||||
apps = import ./apps.nix;
|
apps = import ./apps.nix;
|
||||||
checks = import ./checks.nix args;
|
checks = import ./checks.nix args;
|
||||||
devShells = import ./devShells.nix;
|
devShells = import ./devShells.nix;
|
||||||
|
|
|
||||||
33
nix/output/lib.nix
Normal file
33
nix/output/lib.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
config.outputKinds = [
|
||||||
|
(_: {
|
||||||
|
options = {
|
||||||
|
lib = mkOption {
|
||||||
|
type = with types; anything;
|
||||||
|
description = ''
|
||||||
|
Exported from the flake at `.lib` and `.lib.<system>` respectively.
|
||||||
|
Arbitrary shape. Intended for use in "library" flakes, exporting the Nix
|
||||||
|
expressions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
hasSystem,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
if hasSystem then
|
||||||
|
{
|
||||||
|
lib.${system} = config.lib;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lib = config.lib;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
36
tests/export-lib.nix
Normal file
36
tests/export-lib.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
checkSystem,
|
||||||
|
modularFlake,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
noSystem = {
|
||||||
|
ans = 42;
|
||||||
|
str = "no system, no pkgs";
|
||||||
|
};
|
||||||
|
yesSystem = {
|
||||||
|
ans = 43;
|
||||||
|
str = "we have nixpkgs here";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
outputs = with modularFlake.defaultOutputs; [ lib ];
|
||||||
|
modules = [
|
||||||
|
(
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
hasSystem,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
lib = if hasSystem then yesSystem else noSystem;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
|
fails = false;
|
||||||
|
expectedOutput = {
|
||||||
|
lib = noSystem // {
|
||||||
|
${checkSystem} = yesSystem;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue