forked from extern/flakelight
Improve app handling
Adds app attr for default app and allows apps to be functions like packages and devShells.
This commit is contained in:
parent
28d5f5a5b4
commit
e33400c88c
32
default.nix
32
default.nix
@ -81,6 +81,7 @@ let
|
|||||||
"env"
|
"env"
|
||||||
"overlay"
|
"overlay"
|
||||||
"overlays"
|
"overlays"
|
||||||
|
"app"
|
||||||
"apps"
|
"apps"
|
||||||
"checks"
|
"checks"
|
||||||
"nixosModules"
|
"nixosModules"
|
||||||
@ -118,13 +119,14 @@ let
|
|||||||
|
|
||||||
callWith = pkgs: x:
|
callWith = pkgs: x:
|
||||||
let
|
let
|
||||||
x' = if (isPath x) || (isString x) then import x else x;
|
x' = ensureFn (if (isPath x) || (isString x) then import x else x);
|
||||||
in
|
in
|
||||||
if ! isFunction x' then x'
|
callFn pkgs x';
|
||||||
else
|
|
||||||
if functionArgs x' == { }
|
callFn = pkgs: f:
|
||||||
then x' pkgs
|
if functionArgs f == { }
|
||||||
else pkgs.callPackage x' { };
|
then f pkgs
|
||||||
|
else pkgs.callPackage f { };
|
||||||
|
|
||||||
genPackages = pkgs: mapAttrs (_: callWith pkgs);
|
genPackages = pkgs: mapAttrs (_: callWith pkgs);
|
||||||
|
|
||||||
@ -181,7 +183,10 @@ let
|
|||||||
// optionalAttrs (module' ? overlay) {
|
// optionalAttrs (module' ? overlay) {
|
||||||
default = module'.overlay;
|
default = module'.overlay;
|
||||||
};
|
};
|
||||||
apps = ensureFn module'.apps;
|
apps = mergeAttrFns (ensureFn module'.apps)
|
||||||
|
(_: optionalAttrs (module' ? app) {
|
||||||
|
default = module'.app;
|
||||||
|
});
|
||||||
checks = ensureFn module'.checks;
|
checks = ensureFn module'.checks;
|
||||||
nixosModules = applyParams module'.nixosModules;
|
nixosModules = applyParams module'.nixosModules;
|
||||||
nixosConfigurations = applyParams module'.nixosConfigurations;
|
nixosConfigurations = applyParams module'.nixosConfigurations;
|
||||||
@ -228,9 +233,12 @@ let
|
|||||||
|
|
||||||
isApp = x: (x ? type) && (x.type == "app") && (x ? program);
|
isApp = x: (x ? type) && (x.type == "app") && (x ? program);
|
||||||
|
|
||||||
mkApp = lib: app:
|
mkApp = pkgs: app:
|
||||||
if isApp app then app
|
let
|
||||||
else { type = "app"; program = "${app}"; };
|
app' = callFn pkgs (ensureFn app);
|
||||||
|
in
|
||||||
|
if isApp app' then app'
|
||||||
|
else { type = "app"; program = "${app'}"; };
|
||||||
|
|
||||||
eachSystem = fn: foldAttrs mergeAttrs { } (map
|
eachSystem = fn: foldAttrs mergeAttrs { } (map
|
||||||
(system: mapAttrs
|
(system: mapAttrs
|
||||||
@ -290,9 +298,9 @@ let
|
|||||||
(merged.checks pkgs);
|
(merged.checks pkgs);
|
||||||
in
|
in
|
||||||
optionalAttrs (checks != { }) { inherit checks; }))
|
optionalAttrs (checks != { }) { inherit checks; }))
|
||||||
(eachSystem ({ pkgs, lib, ... }:
|
(eachSystem (pkgs:
|
||||||
let
|
let
|
||||||
apps = mapAttrs (_: mkApp lib) (merged.apps pkgs);
|
apps = mapAttrs (_: mkApp pkgs) (merged.apps pkgs);
|
||||||
in
|
in
|
||||||
optionalAttrs (apps != { }) { inherit apps; }))
|
optionalAttrs (apps != { }) { inherit apps; }))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user