From 61c0ecea5b98249bc234466bc0e0ae778af72a45 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 4 Aug 2023 18:36:08 +0300 Subject: [PATCH 1/2] treewide: update mainProgram docs --- doc/stdenv/meta.chapter.md | 2 +- lib/meta.nix | 5 ++--- pkgs/development/node-packages/main-programs.nix | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index e626e7942996..f6da0bb84be0 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -70,7 +70,7 @@ A list of the maintainers of this Nix expression. Maintainers are defined in [`n ### `mainProgram` {#var-meta-mainProgram} -The name of the main binary for the package. This affects the binary `nix run` executes and falls back to the name of the package. Example: `"rg"` +The name of the main binary for the package. This affects the binary `nix run` executes. Example: `"rg"` ### `priority` {#var-meta-priority} diff --git a/lib/meta.nix b/lib/meta.nix index d32a37fe61d7..21404b3a2bfa 100644 --- a/lib/meta.nix +++ b/lib/meta.nix @@ -132,10 +132,9 @@ rec { { shortName = licstr; } ); - /* Get the path to the main program of a derivation with either - meta.mainProgram or pname or name + /* Get the path to the main program of a package based on meta.mainProgram - Type: getExe :: derivation -> string + Type: getExe :: package -> string Example: getExe pkgs.hello diff --git a/pkgs/development/node-packages/main-programs.nix b/pkgs/development/node-packages/main-programs.nix index c327b3b9a5bb..2329de51149e 100644 --- a/pkgs/development/node-packages/main-programs.nix +++ b/pkgs/development/node-packages/main-programs.nix @@ -1,5 +1,4 @@ -# Use this file to add `meta.mainProgram` to packages in `nodePackages`, that don't provide an -# executable that matches that packages name, so that they'll work with `nix run`. +# Use this file to add `meta.mainProgram` to packages in `nodePackages`. { # Packages that provide multiple executables where one is clearly the `mainProgram`. "@antfu/ni" = "ni"; @@ -11,7 +10,7 @@ vue-cli = "vue"; "@withgraphite/graphite-cli" = "gt"; - # Packages that provide a single executable whose name differs from the package's `name`. + # Packages that provide a single executable. "@angular/cli" = "ng"; "@antora/cli" = "antora"; "@astrojs/language-server" = "astro-ls"; From d787798f1c69104b91f6dd8ebdaafa4be66adbda Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 4 Aug 2023 18:35:06 +0300 Subject: [PATCH 2/2] pass.withExtensions: add meta.mainProgram ``` nix-repl> lib.getExe (pass.withExtensions(_: [])) "/nix/store/rvc4ambjr8jsvm5n757icfl3j7gv1jxh-pass-env/bin/pass" ``` --- pkgs/tools/security/pass/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/security/pass/default.nix b/pkgs/tools/security/pass/default.nix index 1b840999e6af..3437b19e3a30 100644 --- a/pkgs/tools/security/pass/default.nix +++ b/pkgs/tools/security/pass/default.nix @@ -29,8 +29,7 @@ let selected = [ pass ] ++ extensions passExtensions ++ lib.optional tombPluginSupport passExtensions.tomb; in buildEnv { - # lib.getExe looks for name, so we keep it the same as mainProgram - name = "pass"; + name = "pass-env"; paths = selected; nativeBuildInputs = [ makeWrapper ]; buildInputs = lib.concatMap (x: x.buildInputs) selected; @@ -51,6 +50,7 @@ let wrapProgram $out/bin/pass \ --set SYSTEM_EXTENSION_DIR "$out/lib/password-store/extensions" ''; + meta.mainProgram = "pass"; }; in