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"'')}"
|
|
|
|
);
|
|
|
|
|
2022-06-23 01:03:48 +00:00
|
|
|
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
|
|
|
'';
|
|
|
|
};
|
2024-08-07 19:45:58 +00:00
|
|
|
meta = mkOption {
|
|
|
|
type = types.lazyAttrsOf lib.types.raw;
|
|
|
|
default = { };
|
2024-08-17 12:18:49 +00:00
|
|
|
# TODO refer to Nix manual 2.25
|
2024-08-07 19:45:58 +00:00
|
|
|
description = ''
|
|
|
|
Metadata information about the app.
|
2024-08-17 12:18:00 +00:00
|
|
|
Standardized in Nix at <https://github.com/NixOS/nix/pull/11297>.
|
2024-08-07 19:45:58 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|