1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-15 17:50:53 +00:00
flake-parts/modules/apps.nix

67 lines
1.8 KiB
Nix
Raw Normal View History

2023-05-29 17:52:03 +00:00
{ lib, flake-parts-lib, ... }:
2022-05-11 20:45:26 +00:00
let
inherit (lib)
mkOption
types
;
2022-05-25 14:36:33 +00:00
inherit (flake-parts-lib)
2022-10-30 10:53:32 +00:00
mkTransposedPerSystemModule
2022-05-11 20:45:26 +00:00
;
2024-01-29 17:57:52 +00:00
getExe = lib.getExe or (
x:
"${lib.getBin x}/bin/${x.meta.mainProgram or (throw ''Package ${x.name or ""} does not have meta.mainProgram set, so I don't know how to find the main executable. You can set meta.mainProgram, or pass the full path to executable, e.g. program = "''${pkg}/bin/foo"'')}"
);
programType = lib.types.coercedTo derivationType getExe lib.types.str;
derivationType = lib.types.package // {
check = lib.isDerivation;
};
2022-05-11 20:45:26 +00:00
appType = lib.types.submodule {
options = {
type = mkOption {
2022-05-17 07:55:23 +00:00
type = lib.types.enum [ "app" ];
2022-05-11 20:45:26 +00:00
default = "app";
2022-11-11 06:39:25 +00:00
description = ''
2022-11-11 05:40:37 +00:00
A type tag for `apps` consumers.
2022-05-11 20:45:26 +00:00
'';
};
program = mkOption {
type = programType;
2022-11-11 06:39:25 +00:00
description = ''
2022-11-11 05:40:37 +00:00
A path to an executable or a derivation with `meta.mainProgram`.
2022-05-11 20:45:26 +00:00
'';
};
meta = mkOption {
type = types.lazyAttrsOf lib.types.raw;
default = { };
# TODO refer to Nix manual 2.25
description = ''
Metadata information about the app.
Standardized in Nix at <https://github.com/NixOS/nix/pull/11297>.
Note: `nix flake check` is only aware of the `description` attribute in `meta`.
'';
};
2022-05-11 20:45:26 +00:00
};
};
in
2022-10-30 10:53:32 +00:00
mkTransposedPerSystemModule {
name = "apps";
option = mkOption {
type = types.lazyAttrsOf appType;
default = { };
description = ''
2022-11-11 05:40:37 +00:00
Programs runnable with nix run `<name>`.
2022-10-30 10:53:32 +00:00
'';
example = lib.literalExpression or lib.literalExample ''
{
default.program = "''${config.packages.hello}/bin/hello";
}
'';
2022-05-11 20:45:26 +00:00
};
2022-10-30 10:53:32 +00:00
file = ./apps.nix;
2022-05-11 20:45:26 +00:00
}