From 3304eb374621870888d7888b0c03cc238fafea94 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Tue, 20 Feb 2024 02:31:44 -0800 Subject: [PATCH] Nix now requires app programs to be paths in store --- API_GUIDE.md | 7 ++----- builtinModules/apps.nix | 5 +++-- tests/default.nix | 9 ++------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/API_GUIDE.md b/API_GUIDE.md index 4dc15b4..b6fde0d 100644 --- a/API_GUIDE.md +++ b/API_GUIDE.md @@ -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"; }; }; diff --git a/builtinModules/apps.nix b/builtinModules/apps.nix index 93b617c..cb94e47 100644 --- a/builtinModules/apps.nix +++ b/builtinModules/apps.nix @@ -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; }; diff --git a/tests/default.nix b/tests/default.nix index 5a0bc2b..eab35f8 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -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";