mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-14 11:47:31 +00:00
commit
bffc4be17f
2 changed files with 33 additions and 10 deletions
|
@ -14,11 +14,18 @@ rec {
|
|||
inherit (f-p-lib) mkFlake;
|
||||
inherit (f-p.inputs.nixpkgs-lib) lib;
|
||||
|
||||
pkg = system: name: derivation {
|
||||
name = name;
|
||||
builder = "no-builder";
|
||||
system = system;
|
||||
};
|
||||
pkg = system: name:
|
||||
derivation
|
||||
{
|
||||
name = name;
|
||||
builder = "no-builder";
|
||||
system = system;
|
||||
}
|
||||
// {
|
||||
meta = {
|
||||
mainProgram = name;
|
||||
};
|
||||
};
|
||||
|
||||
empty = mkFlake
|
||||
{ inputs.self = { }; }
|
||||
|
@ -46,8 +53,9 @@ rec {
|
|||
{ inputs.self = { }; }
|
||||
{
|
||||
systems = [ "a" "b" ];
|
||||
perSystem = { system, ... }: {
|
||||
perSystem = { config, system, ... }: {
|
||||
packages.hello = pkg system "hello";
|
||||
apps.hello.program = config.packages.hello;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -142,7 +150,20 @@ rec {
|
|||
};
|
||||
|
||||
assert example1 == {
|
||||
apps = { a = { }; b = { }; };
|
||||
apps = {
|
||||
a = {
|
||||
hello = {
|
||||
program = "${pkg "a" "hello"}/bin/hello";
|
||||
type = "app";
|
||||
};
|
||||
};
|
||||
b = {
|
||||
hello = {
|
||||
program = "${pkg "b" "hello"}/bin/hello";
|
||||
type = "app";
|
||||
};
|
||||
};
|
||||
};
|
||||
checks = { a = { }; b = { }; };
|
||||
devShells = { a = { }; b = { }; };
|
||||
formatter = { };
|
||||
|
|
|
@ -8,15 +8,17 @@ let
|
|||
mkTransposedPerSystemModule
|
||||
;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
getExe = 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"'')}";
|
||||
|
||||
appType = lib.types.submodule {
|
||||
options = {
|
||||
type = mkOption {
|
||||
|
|
Loading…
Reference in a new issue