90 lines
2.4 KiB
Nix
90 lines
2.4 KiB
Nix
{ config, lib, ... }:
|
|
let
|
|
metadataType =
|
|
with lib;
|
|
submodule {
|
|
options = {
|
|
description = {
|
|
type = with types; nullOr str;
|
|
default = null;
|
|
};
|
|
# other metadata (look it up)
|
|
};
|
|
};
|
|
inner = with lib; {
|
|
# source: https://wiki.nixos.org/wiki/Flakes#Output_schema
|
|
checks = mkOption {
|
|
# NOTE: this is different from the flakes themselves -- this version accepts
|
|
# anything (not just a derivation):
|
|
# - for a derivation type, the behavior is the same
|
|
# - for a non-derivation type, expression gets deep-evaluated instead
|
|
type = with types; attrsOf types.raw;
|
|
description = "Evaluated by `nix flake check`";
|
|
default = { };
|
|
};
|
|
packages = mkOption {
|
|
type = with types; attrsOf package;
|
|
description = "Executed by `nix build .#<name>`";
|
|
default = { };
|
|
};
|
|
apps = mkOption {
|
|
description = "Executed by `nix run .#<name>`";
|
|
type =
|
|
with types;
|
|
attrsOf (submodule {
|
|
options = {
|
|
program = mkOption1 {
|
|
description = "An executable to run";
|
|
type = pathInStore;
|
|
};
|
|
meta = mkOption {
|
|
description = "The executable metadata";
|
|
type = metadataType;
|
|
default = { };
|
|
};
|
|
};
|
|
});
|
|
default = { };
|
|
};
|
|
};
|
|
# decorates the inner options with additinal "forSystem" option used to specialize on the
|
|
# system
|
|
forSystem =
|
|
with lib;
|
|
inner:
|
|
inner
|
|
// {
|
|
forSystem = mkOption {
|
|
description = "flake outputs only present at a specific system";
|
|
type = attrsOf (submodule {
|
|
options = inner;
|
|
});
|
|
};
|
|
};
|
|
# decorates the inner options with additinal "raw" option used to expose other unchecked
|
|
# flake outputs verbatim
|
|
raw =
|
|
with lib;
|
|
inner:
|
|
inner
|
|
// {
|
|
raw = mkOption {
|
|
description = "flake outputs only present at a specific system";
|
|
type = attrsOf (submodule {
|
|
options = inner;
|
|
});
|
|
};
|
|
};
|
|
in
|
|
{
|
|
# options = (passthru (forSystem (passthru inner)));
|
|
options = inner // {
|
|
__check = {
|
|
type = lib.types.listOf lib.types.raw;
|
|
default =
|
|
(builtins.attrValues config.check)
|
|
// (builtins.attrValues config.packages)
|
|
// (builtins.attrValues config.apps);
|
|
};
|
|
};
|
|
}
|