Nix now requires app programs to be paths in store

This commit is contained in:
Archit Gupta 2024-02-20 02:31:44 -08:00
parent bac4759bcb
commit 3304eb3746
3 changed files with 7 additions and 14 deletions

View File

@ -683,9 +683,8 @@ Types:
The `app` and `apps` options allow you to set `apps.${system}` outputs.
`apps` is an attribute set of apps or a function that takes packages and returns
an attribute set of apps. If the app value is not an app, it is converted to a
string and set as the program attr of an app. If it is a function, it is passed
packages.
an attribute set of apps. If the app value is a function, it is passed packages.
If the app value or function result is a string, it is converted to an app.
`app` sets `apps.default`.
@ -697,7 +696,6 @@ For example:
outputs = { flakelight, ... }:
flakelight ./. {
apps = {
shell = "/bin/sh";
emacs = pkgs: "${pkgs.emacs}/bin/emacs";
bash = pkgs: { type = "app"; program = "${pkgs.bash}/bin/bash"; };
};
@ -713,7 +711,6 @@ Alternatively, the above can be written as:
outputs = { flakelight, ... }:
flakelight ./. {
apps = { emacs, bash, ... }: {
shell = "/bin/sh";
emacs = "${emacs}/bin/emacs";
bash = { type = "app"; program = "${bash}/bin/bash"; };
};

View File

@ -5,7 +5,7 @@
{ config, lib, flakelight, genSystems, ... }:
let
inherit (lib) isStringLike mapAttrs mkIf mkMerge mkOption mkOptionType;
inherit (lib.types) coercedTo lazyAttrsOf;
inherit (lib.types) coercedTo lazyAttrsOf pathInStore;
inherit (lib.options) mergeEqualOption;
inherit (flakelight.types) nullable optFunctionTo;
@ -13,7 +13,8 @@ let
name = "app";
description = "flake app";
descriptionClass = "noun";
check = x: (x ? type) && (x.type == "app") && (x ? program);
check = x: (x ? type) && (x.type == "app") &&
(x ? program) && (pathInStore.check x.program);
merge = mergeEqualOption;
};

View File

@ -466,11 +466,11 @@ in
app-string = test
(flakelight ./empty {
inputs = { inherit nixpkgs; };
app = "/bin/sh";
app = "${nixpkgs.legacyPackages.x86_64-linux.hello}/bin/hello";
})
(f: (f.apps.x86_64-linux.default == {
type = "app";
program = "/bin/sh";
program = "${nixpkgs.legacyPackages.x86_64-linux.hello}/bin/hello";
}));
app-string-fn = test
@ -487,16 +487,11 @@ in
(flakelight ./empty {
inputs = { inherit nixpkgs; };
apps = {
shell = "/bin/sh";
emacs = pkgs: "${pkgs.emacs}/bin/emacs";
bash = pkgs: { type = "app"; program = "${pkgs.bash}/bin/bash"; };
};
})
(f: f.apps.x86_64-linux == {
shell = {
type = "app";
program = "/bin/sh";
};
emacs = {
type = "app";
program = "${nixpkgs.legacyPackages.x86_64-linux.emacs}/bin/emacs";