summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/meta.nix6
-rw-r--r--nixos/modules/programs/oddjobd.nix7
-rw-r--r--pkgs/applications/audio/espeak-ng/default.nix1
-rw-r--r--pkgs/applications/display-managers/greetd/regreet.nix1
-rw-r--r--pkgs/applications/emulators/darling/default.nix1
-rw-r--r--pkgs/applications/graphics/openscad/default.nix1
-rw-r--r--pkgs/applications/graphics/tesseract/tesseract5.nix1
-rw-r--r--pkgs/applications/networking/browsers/firefox/packages.nix5
-rw-r--r--pkgs/applications/networking/clash-verge/default.nix1
-rw-r--r--pkgs/applications/networking/instant-messengers/discord/linux.nix1
-rw-r--r--pkgs/applications/networking/irc/thelounge/default.nix1
-rw-r--r--pkgs/applications/version-management/gitea/default.nix1
-rw-r--r--pkgs/applications/virtualization/kvmtool/default.nix1
-rw-r--r--pkgs/applications/window-managers/cage/default.nix1
-rw-r--r--pkgs/build-support/writers/scripts.nix24
-rw-r--r--pkgs/desktops/gnome/apps/file-roller/default.nix1
-rw-r--r--pkgs/development/interpreters/perl/intepreter.nix1
-rw-r--r--pkgs/development/interpreters/python/cpython/default.nix1
-rw-r--r--pkgs/development/libraries/xdg-dbus-proxy/default.nix1
-rw-r--r--pkgs/development/python-modules/flake8/default.nix1
-rw-r--r--pkgs/development/tools/continuous-integration/woodpecker/agent.nix1
-rw-r--r--pkgs/development/tools/continuous-integration/woodpecker/server.nix1
-rw-r--r--pkgs/development/tools/esbuild/default.nix1
-rw-r--r--pkgs/development/tools/esbuild/netlify.nix1
-rw-r--r--pkgs/development/tools/geckodriver/default.nix1
-rw-r--r--pkgs/development/tools/misc/libtool/default.nix2
-rw-r--r--pkgs/development/tools/misc/libtool/libtool2.nix1
-rw-r--r--pkgs/development/tools/misc/tokei/default.nix1
-rw-r--r--pkgs/development/tools/selenium/chromedriver/default.nix1
-rw-r--r--pkgs/os-specific/linux/below/default.nix1
-rw-r--r--pkgs/servers/code-server/default.nix1
-rw-r--r--pkgs/servers/consul/default.nix1
-rw-r--r--pkgs/servers/dns/acme-dns/default.nix1
-rw-r--r--pkgs/servers/ldap/lldap/default.nix1
-rw-r--r--pkgs/servers/monitoring/grafana-agent/default.nix1
-rw-r--r--pkgs/servers/openvscode-server/default.nix1
-rw-r--r--pkgs/servers/pufferpanel/default.nix1
-rw-r--r--pkgs/servers/web-apps/kavita/default.nix1
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix10
-rw-r--r--pkgs/tools/backup/tarsnap/default.nix1
-rw-r--r--pkgs/tools/misc/coreboot-utils/default.nix1
-rw-r--r--pkgs/tools/misc/direnv/default.nix1
-rw-r--r--pkgs/tools/misc/file/default.nix1
-rw-r--r--pkgs/tools/misc/nurl/default.nix1
-rw-r--r--pkgs/tools/misc/vector/default.nix1
-rw-r--r--pkgs/tools/misc/xvfb-run/default.nix1
-rw-r--r--pkgs/tools/misc/yt-dlp/default.nix1
-rw-r--r--pkgs/tools/networking/clash-meta/default.nix1
-rw-r--r--pkgs/tools/networking/clash/default.nix1
-rw-r--r--pkgs/tools/networking/sitespeed-io/default.nix1
-rw-r--r--pkgs/tools/networking/wgautomesh/default.nix1
-rw-r--r--pkgs/tools/package-management/harmonia/default.nix1
-rw-r--r--pkgs/tools/package-management/nix/common.nix1
-rw-r--r--pkgs/tools/system/auto-cpufreq/default.nix1
-rw-r--r--pkgs/tools/system/htop/default.nix1
-rw-r--r--pkgs/tools/system/kanata/default.nix1
56 files changed, 95 insertions, 9 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
index 5fd55c4e90d..d32a37fe61d 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -144,5 +144,9 @@ rec {
        => "/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache"
   */
   getExe = x:
-    "${lib.getBin x}/bin/${x.meta.mainProgram or (lib.getName x)}";
+    "${lib.getBin x}/bin/${x.meta.mainProgram or (
+      # This could be turned into an error when 23.05 is at end of life
+      lib.warn "getExe: Package ${lib.strings.escapeNixIdentifier x.meta.name or x.pname or x.name} does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, specify the full path to the program, such as \"\${lib.getBin foo}/bin/bar\"."
+      lib.getName x
+    )}";
 }
diff --git a/nixos/modules/programs/oddjobd.nix b/nixos/modules/programs/oddjobd.nix
index a37df0482c9..b0920d007c9 100644
--- a/nixos/modules/programs/oddjobd.nix
+++ b/nixos/modules/programs/oddjobd.nix
@@ -10,6 +10,11 @@ in
   };
 
   config = lib.mkIf cfg.enable {
+    assertions = [
+      { assertion = false;
+        message = "The oddjob service was found to be broken without NixOS test or maintainer. Please take ownership of this service.";
+      }
+    ];
     systemd.packages = [ cfg.package ];
 
     systemd.services.oddjobd = {
@@ -21,7 +26,7 @@ in
       serviceConfig = {
         Type = "dbus";
         BusName = "org.freedesktop.oddjob";
-        ExecStart = "${lib.getExe cfg.package}/bin/oddjobd";
+        ExecStart = "${lib.getBin cfg.package}/bin/oddjobd";
       };
     };
   };
diff --git a/pkgs/applications/audio/espeak-ng/default.nix b/pkgs/applications/audio/espeak-ng/default.nix
index d53c0ac1caf..5e62399c8a4 100644
--- a/pkgs/applications/audio/espeak-ng/default.nix
+++ b/pkgs/applications/audio/espeak-ng/default.nix
@@ -75,5 +75,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ aske ];
     platforms = platforms.all;
+    mainProgram = "espeak-ng";
   };
 }
diff --git a/pkgs/applications/display-managers/greetd/regreet.nix b/pkgs/applications/display-managers/greetd/regreet.nix
index a520ad88d6e..6cd336821cc 100644
--- a/pkgs/applications/display-managers/greetd/regreet.nix
+++ b/pkgs/applications/display-managers/greetd/regreet.nix
@@ -31,5 +31,6 @@ rustPlatform.buildRustPackage rec {
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ fufexan ];
     platforms = platforms.linux;
+    mainProgram = "regreet";
   };
 }
diff --git a/pkgs/applications/emulators/darling/default.nix b/pkgs/applications/emulators/darling/default.nix
index 988ca796479..cc4d7265ce2 100644
--- a/pkgs/applications/emulators/darling/default.nix
+++ b/pkgs/applications/emulators/darling/default.nix
@@ -227,5 +227,6 @@ in stdenv.mkDerivation {
     license = licenses.gpl3Plus;
     maintainers = with maintainers; [ zhaofengli ];
     platforms = [ "x86_64-linux" ];
+    mainProgram = "darling";
   };
 }
diff --git a/pkgs/applications/graphics/openscad/default.nix b/pkgs/applications/graphics/openscad/default.nix
index 94c30fe0a32..37fcc0eb48e 100644
--- a/pkgs/applications/graphics/openscad/default.nix
+++ b/pkgs/applications/graphics/openscad/default.nix
@@ -109,5 +109,6 @@ mkDerivation rec {
     license = lib.licenses.gpl2;
     platforms = lib.platforms.unix;
     maintainers = with lib.maintainers; [ bjornfor raskin gebner ];
+    mainProgram = "openscad";
   };
 }
diff --git a/pkgs/applications/graphics/tesseract/tesseract5.nix b/pkgs/applications/graphics/tesseract/tesseract5.nix
index 614a9e844cc..aa7f17b20c2 100644
--- a/pkgs/applications/graphics/tesseract/tesseract5.nix
+++ b/pkgs/applications/graphics/tesseract/tesseract5.nix
@@ -41,5 +41,6 @@ stdenv.mkDerivation rec {
     license = lib.licenses.asl20;
     maintainers = with lib.maintainers; [ anselmschueler ];
     platforms = lib.platforms.unix;
+    mainProgram = "tesseract";
   };
 }
diff --git a/pkgs/applications/networking/browsers/firefox/packages.nix b/pkgs/applications/networking/browsers/firefox/packages.nix
index 13bbf7da085..7b839cdfcb2 100644
--- a/pkgs/applications/networking/browsers/firefox/packages.nix
+++ b/pkgs/applications/networking/browsers/firefox/packages.nix
@@ -20,6 +20,7 @@
                                              # not in `badPlatforms` because cross-compilation on 64-bit machine might work.
       maxSilent = 14400; # 4h, double the default of 7200s (c.f. #129212, #129115)
       license = lib.licenses.mpl20;
+      mainProgram = "firefox";
     };
     tests = [ nixosTests.firefox ];
     updateScript = callPackage ./update.nix {
@@ -46,6 +47,7 @@
                                              # not in `badPlatforms` because cross-compilation on 64-bit machine might work.
       maxSilent = 14400; # 4h, double the default of 7200s (c.f. #129212, #129115)
       license = lib.licenses.mpl20;
+      mainProgram = "firefox";
     };
     tests = [ nixosTests.firefox-beta ];
     updateScript = callPackage ./update.nix {
@@ -74,6 +76,7 @@
                                              # not in `badPlatforms` because cross-compilation on 64-bit machine might work.
       maxSilent = 14400; # 4h, double the default of 7200s (c.f. #129212, #129115)
       license = lib.licenses.mpl20;
+      mainProgram = "firefox";
     };
     tests = [ nixosTests.firefox-devedition ];
     updateScript = callPackage ./update.nix {
@@ -104,6 +107,7 @@
       broken = stdenv.buildPlatform.is32bit; # since Firefox 60, build on 32-bit platforms fails with "out of memory".
                                              # not in `badPlatforms` because cross-compilation on 64-bit machine might work.
       license = lib.licenses.mpl20;
+      mainProgram = "firefox";
     };
     tests = [ nixosTests.firefox-esr-102 ];
     updateScript = callPackage ./update.nix {
@@ -132,6 +136,7 @@
       broken = stdenv.buildPlatform.is32bit; # since Firefox 60, build on 32-bit platforms fails with "out of memory".
                                              # not in `badPlatforms` because cross-compilation on 64-bit machine might work.
       license = lib.licenses.mpl20;
+      mainProgram = "firefox";
     };
     tests = [ nixosTests.firefox-esr-115 ];
     updateScript = callPackage ./update.nix {
diff --git a/pkgs/applications/networking/clash-verge/default.nix b/pkgs/applications/networking/clash-verge/default.nix
index 7869ed9a1f7..bbe36cb0d66 100644
--- a/pkgs/applications/networking/clash-verge/default.nix
+++ b/pkgs/applications/networking/clash-verge/default.nix
@@ -60,5 +60,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl3Plus;
     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
     maintainers = with maintainers; [ zendo ];
+    mainProgram = "clash-verge";
   };
 }
diff --git a/pkgs/applications/networking/instant-messengers/discord/linux.nix b/pkgs/applications/networking/instant-messengers/discord/linux.nix
index 236ceaa0a78..ce94764ed9b 100644
--- a/pkgs/applications/networking/instant-messengers/discord/linux.nix
+++ b/pkgs/applications/networking/instant-messengers/discord/linux.nix
@@ -18,6 +18,7 @@ let
     {
       pythonInterpreter = "${python3.interpreter}";
       configDirName = lib.toLower binaryName;
+      meta.mainProgram = "disable-breaking-updates.py";
     } ''
     mkdir -p $out/bin
     cp ${./disable-breaking-updates.py} $out/bin/disable-breaking-updates.py
diff --git a/pkgs/applications/networking/irc/thelounge/default.nix b/pkgs/applications/networking/irc/thelounge/default.nix
index adb46e2bab7..eff1458e07e 100644
--- a/pkgs/applications/networking/irc/thelounge/default.nix
+++ b/pkgs/applications/networking/irc/thelounge/default.nix
@@ -88,5 +88,6 @@ stdenv.mkDerivation (finalAttrs: {
     maintainers = with maintainers; [ winter raitobezarius ];
     license = licenses.mit;
     inherit (nodejs.meta) platforms;
+    mainProgram = "thelounge";
   };
 })
diff --git a/pkgs/applications/version-management/gitea/default.nix b/pkgs/applications/version-management/gitea/default.nix
index bb696b4087f..89cae801ec2 100644
--- a/pkgs/applications/version-management/gitea/default.nix
+++ b/pkgs/applications/version-management/gitea/default.nix
@@ -88,5 +88,6 @@ buildGoModule rec {
     license = licenses.mit;
     maintainers = with maintainers; [ disassembler kolaente ma27 techknowlogick ];
     broken = stdenv.isDarwin;
+    mainProgram = "gitea";
   };
 }
diff --git a/pkgs/applications/virtualization/kvmtool/default.nix b/pkgs/applications/virtualization/kvmtool/default.nix
index bf134e2cb07..e3b52c411d6 100644
--- a/pkgs/applications/virtualization/kvmtool/default.nix
+++ b/pkgs/applications/virtualization/kvmtool/default.nix
@@ -29,5 +29,6 @@ stdenv.mkDerivation {
     license = licenses.gpl2Only;
     maintainers = with maintainers; [ astro ];
     platforms = [ "x86_64-linux" "aarch64-linux" ];
+    mainProgram = "nvramtool";
   };
 }
diff --git a/pkgs/applications/window-managers/cage/default.nix b/pkgs/applications/window-managers/cage/default.nix
index 6c56c75418f..c94263f8161 100644
--- a/pkgs/applications/window-managers/cage/default.nix
+++ b/pkgs/applications/window-managers/cage/default.nix
@@ -44,5 +44,6 @@ stdenv.mkDerivation rec {
     license     = licenses.mit;
     platforms   = platforms.linux;
     maintainers = with maintainers; [ primeos ];
+    mainProgram = "cage";
   };
 }
diff --git a/pkgs/build-support/writers/scripts.nix b/pkgs/build-support/writers/scripts.nix
index 7fc47fbcdf9..c43f10f0a2e 100644
--- a/pkgs/build-support/writers/scripts.nix
+++ b/pkgs/build-support/writers/scripts.nix
@@ -25,13 +25,21 @@ rec {
       name = last (builtins.split "/" nameOrPath);
     in
 
-    pkgs.runCommandLocal name (if (types.str.check content) then {
-      inherit content interpreter;
-      passAsFile = [ "content" ];
-    } else {
-      inherit interpreter;
-      contentPath = content;
-    }) ''
+    pkgs.runCommandLocal name (
+      lib.optionalAttrs (nameOrPath == "/bin/${name}") {
+        meta.mainProgram = name;
+      }
+      // (
+        if (types.str.check content) then {
+          inherit content interpreter;
+          passAsFile = [ "content" ];
+        } else {
+          inherit interpreter;
+          contentPath = content;
+        }
+      )
+    )
+    ''
       # On darwin a script cannot be used as an interpreter in a shebang but
       # there doesn't seem to be a limit to the size of shebang and multiple
       # arguments to the interpreter are allowed.
@@ -89,6 +97,8 @@ rec {
       # https://github.com/NixOS/nixpkgs/issues/154203
       # https://github.com/NixOS/nixpkgs/issues/148189
       nativeBuildInputs = [ stdenv.cc.bintools ];
+    } // lib.optionalAttrs (nameOrPath == "/bin/${name}") {
+      meta.mainProgram = name;
     }) ''
       ${compileScript}
       ${lib.optionalString strip
diff --git a/pkgs/desktops/gnome/apps/file-roller/default.nix b/pkgs/desktops/gnome/apps/file-roller/default.nix
index 44b7659d30c..97508ed418c 100644
--- a/pkgs/desktops/gnome/apps/file-roller/default.nix
+++ b/pkgs/desktops/gnome/apps/file-roller/default.nix
@@ -73,5 +73,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl2Plus;
     platforms = platforms.linux;
     maintainers = teams.gnome.members ++ teams.pantheon.members;
+    mainProgram = "file-roller";
   };
 }
diff --git a/pkgs/development/interpreters/perl/intepreter.nix b/pkgs/development/interpreters/perl/intepreter.nix
index 6d543e7d840..96d6430c14e 100644
--- a/pkgs/development/interpreters/perl/intepreter.nix
+++ b/pkgs/development/interpreters/perl/intepreter.nix
@@ -232,6 +232,7 @@ stdenv.mkDerivation (rec {
     maintainers = [ maintainers.eelco ];
     platforms = platforms.all;
     priority = 6; # in `buildEnv' (including the one inside `perl.withPackages') the library files will have priority over files in `perl`
+    mainProgram = "perl";
   };
 } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) rec {
   crossVersion = "c876045741f5159318085d2737b0090f35a842ca"; # June 5, 2022
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix
index ff103373a10..f84cca760f8 100644
--- a/pkgs/development/interpreters/python/cpython/default.nix
+++ b/pkgs/development/interpreters/python/cpython/default.nix
@@ -572,5 +572,6 @@ in with passthru; stdenv.mkDerivation {
     license = licenses.psfl;
     platforms = platforms.linux ++ platforms.darwin;
     maintainers = with maintainers; [ fridh ];
+    mainProgram = "python3";
   };
 }
diff --git a/pkgs/development/libraries/xdg-dbus-proxy/default.nix b/pkgs/development/libraries/xdg-dbus-proxy/default.nix
index cc7406b1146..c88c7d42b12 100644
--- a/pkgs/development/libraries/xdg-dbus-proxy/default.nix
+++ b/pkgs/development/libraries/xdg-dbus-proxy/default.nix
@@ -46,5 +46,6 @@ stdenv.mkDerivation rec {
     license = licenses.lgpl21Plus;
     maintainers = with maintainers; [ jtojnar ];
     platforms = platforms.linux;
+    mainProgram = "xdg-dbus-proxy";
   };
 }
diff --git a/pkgs/development/python-modules/flake8/default.nix b/pkgs/development/python-modules/flake8/default.nix
index d56d42abf2e..860f449fd8b 100644
--- a/pkgs/development/python-modules/flake8/default.nix
+++ b/pkgs/development/python-modules/flake8/default.nix
@@ -45,5 +45,6 @@ buildPythonPackage rec {
     homepage = "https://github.com/pycqa/flake8";
     license = licenses.mit;
     maintainers = with maintainers; [ dotlambda ];
+    mainProgram = "flake8";
   };
 }
diff --git a/pkgs/development/tools/continuous-integration/woodpecker/agent.nix b/pkgs/development/tools/continuous-integration/woodpecker/agent.nix
index b225db034c1..5bbc4cf99ce 100644
--- a/pkgs/development/tools/continuous-integration/woodpecker/agent.nix
+++ b/pkgs/development/tools/continuous-integration/woodpecker/agent.nix
@@ -12,5 +12,6 @@ buildGoModule {
 
   meta = common.meta // {
     description = "Woodpecker Continuous Integration agent";
+    mainProgram = "woodpecker-agent";
   };
 }
diff --git a/pkgs/development/tools/continuous-integration/woodpecker/server.nix b/pkgs/development/tools/continuous-integration/woodpecker/server.nix
index fd8415c901c..874949dff2f 100644
--- a/pkgs/development/tools/continuous-integration/woodpecker/server.nix
+++ b/pkgs/development/tools/continuous-integration/woodpecker/server.nix
@@ -22,5 +22,6 @@ buildGoModule {
 
   meta = common.meta // {
     description = "Woodpecker Continuous Integration server";
+    mainProgram = "woodpecker-server";
   };
 }
diff --git a/pkgs/development/tools/esbuild/default.nix b/pkgs/development/tools/esbuild/default.nix
index 6179116d0ad..1e7c0b3ff1e 100644
--- a/pkgs/development/tools/esbuild/default.nix
+++ b/pkgs/development/tools/esbuild/default.nix
@@ -23,5 +23,6 @@ buildGoModule rec {
     changelog = "https://github.com/evanw/esbuild/blob/v${version}/CHANGELOG.md";
     license = licenses.mit;
     maintainers = with maintainers; [ lucus16 marsam undefined-moe ];
+    mainProgram = "esbuild";
   };
 }
diff --git a/pkgs/development/tools/esbuild/netlify.nix b/pkgs/development/tools/esbuild/netlify.nix
index ddf5b301d34..68542612292 100644
--- a/pkgs/development/tools/esbuild/netlify.nix
+++ b/pkgs/development/tools/esbuild/netlify.nix
@@ -29,5 +29,6 @@ buildGoModule rec {
     homepage = "https://github.com/netlify/esbuild";
     license = licenses.mit;
     maintainers = with maintainers; [ roberth ];
+    mainProgram = "esbuild";
   };
 }
diff --git a/pkgs/development/tools/geckodriver/default.nix b/pkgs/development/tools/geckodriver/default.nix
index 6f6a937efbe..ef71dc143f1 100644
--- a/pkgs/development/tools/geckodriver/default.nix
+++ b/pkgs/development/tools/geckodriver/default.nix
@@ -26,5 +26,6 @@ rustPlatform.buildRustPackage rec {
     homepage = "https://github.com/mozilla/geckodriver";
     license = licenses.mpl20;
     maintainers = with maintainers; [ jraygauthier ];
+    mainProgram = "geckodriver";
   };
 }
diff --git a/pkgs/development/tools/misc/libtool/default.nix b/pkgs/development/tools/misc/libtool/default.nix
index b9e32372922..6970d2a94ec 100644
--- a/pkgs/development/tools/misc/libtool/default.nix
+++ b/pkgs/development/tools/misc/libtool/default.nix
@@ -34,5 +34,7 @@ stdenv.mkDerivation rec {
 
     license = lib.licenses.gpl2Plus;
     platforms = lib.platforms.unix;
+
+    mainProgram = "libtool";
   };
 }
diff --git a/pkgs/development/tools/misc/libtool/libtool2.nix b/pkgs/development/tools/misc/libtool/libtool2.nix
index a2c58010eff..50c064cadfd 100644
--- a/pkgs/development/tools/misc/libtool/libtool2.nix
+++ b/pkgs/development/tools/misc/libtool/libtool2.nix
@@ -68,5 +68,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl2Plus;
     maintainers = [ ];
     platforms = platforms.unix;
+    mainProgram = "libtool";
   };
 }
diff --git a/pkgs/development/tools/misc/tokei/default.nix b/pkgs/development/tools/misc/tokei/default.nix
index a93eee5cb1d..b91460160ce 100644
--- a/pkgs/development/tools/misc/tokei/default.nix
+++ b/pkgs/development/tools/misc/tokei/default.nix
@@ -28,5 +28,6 @@ rustPlatform.buildRustPackage rec {
     homepage = "https://github.com/XAMPPRocky/tokei";
     license = with licenses; [ asl20 /* or */ mit ];
     maintainers = with maintainers; [ gebner lilyball ];
+    mainProgram = "tokei";
   };
 }
diff --git a/pkgs/development/tools/selenium/chromedriver/default.nix b/pkgs/development/tools/selenium/chromedriver/default.nix
index d8201fabb2f..08f067ecbd7 100644
--- a/pkgs/development/tools/selenium/chromedriver/default.nix
+++ b/pkgs/development/tools/selenium/chromedriver/default.nix
@@ -73,5 +73,6 @@ in stdenv.mkDerivation rec {
     # Note from primeos: By updating Chromium I also update Google Chrome and
     # ChromeDriver.
     platforms = attrNames allSpecs;
+    mainProgram = "chromedriver";
   };
 }
diff --git a/pkgs/os-specific/linux/below/default.nix b/pkgs/os-specific/linux/below/default.nix
index 2bdca0805a2..0a91fd58590 100644
--- a/pkgs/os-specific/linux/below/default.nix
+++ b/pkgs/os-specific/linux/below/default.nix
@@ -43,5 +43,6 @@ rustPlatform.buildRustPackage rec {
     description = "A time traveling resource monitor for modern Linux systems";
     license = licenses.asl20;
     homepage = "https://github.com/facebookincubator/below";
+    mainProgram = "below";
   };
 }
diff --git a/pkgs/servers/code-server/default.nix b/pkgs/servers/code-server/default.nix
index 990ab50f28b..0c5cb231085 100644
--- a/pkgs/servers/code-server/default.nix
+++ b/pkgs/servers/code-server/default.nix
@@ -322,5 +322,6 @@ stdenv.mkDerivation (finalAttrs: {
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [ offline henkery code-asher ];
     platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+    mainProgram = "code-server";
   };
 })
diff --git a/pkgs/servers/consul/default.nix b/pkgs/servers/consul/default.nix
index 1f9b6806032..6f145137567 100644
--- a/pkgs/servers/consul/default.nix
+++ b/pkgs/servers/consul/default.nix
@@ -42,5 +42,6 @@ buildGoModule rec {
     platforms = platforms.linux ++ platforms.darwin;
     license = licenses.mpl20;
     maintainers = with maintainers; [ pradeepchhetri vdemeester nh2 techknowlogick];
+    mainProgram = "consul";
   };
 }
diff --git a/pkgs/servers/dns/acme-dns/default.nix b/pkgs/servers/dns/acme-dns/default.nix
index 08cd511f182..db6ea4bbea0 100644
--- a/pkgs/servers/dns/acme-dns/default.nix
+++ b/pkgs/servers/dns/acme-dns/default.nix
@@ -30,5 +30,6 @@ buildGoModule rec {
     changelog = "https://github.com/joohoi/acme-dns/releases/tag/${src.rev}";
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [ emilylange ];
+    mainProgram = "acme-dns";
   };
 }
diff --git a/pkgs/servers/ldap/lldap/default.nix b/pkgs/servers/ldap/lldap/default.nix
index 1948ca015dd..3c83fe037a0 100644
--- a/pkgs/servers/ldap/lldap/default.nix
+++ b/pkgs/servers/ldap/lldap/default.nix
@@ -110,5 +110,6 @@ in rustPlatform.buildRustPackage (commonDerivationAttrs // {
     license = licenses.gpl3Only;
     platforms = platforms.linux;
     maintainers = with maintainers; [ emilylange bendlas ];
+    mainProgram = "lldap";
   };
 })
diff --git a/pkgs/servers/monitoring/grafana-agent/default.nix b/pkgs/servers/monitoring/grafana-agent/default.nix
index 3859c2df596..e07621e8213 100644
--- a/pkgs/servers/monitoring/grafana-agent/default.nix
+++ b/pkgs/servers/monitoring/grafana-agent/default.nix
@@ -73,5 +73,6 @@ buildGoModule rec {
     homepage = "https://grafana.com/products/cloud";
     changelog = "https://github.com/grafana/agent/blob/${src.rev}/CHANGELOG.md";
     maintainers = with lib.maintainers; [ flokli emilylange ];
+    mainProgram = "grafana-agent";
   };
 }
diff --git a/pkgs/servers/openvscode-server/default.nix b/pkgs/servers/openvscode-server/default.nix
index 8ce4b7676e4..43f9d7a7fe7 100644
--- a/pkgs/servers/openvscode-server/default.nix
+++ b/pkgs/servers/openvscode-server/default.nix
@@ -219,5 +219,6 @@ stdenv.mkDerivation (finalAttrs: {
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [ dguenther ghuntley emilytrau ];
     platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
+    mainProgram = "openvscode-server";
   };
 })
diff --git a/pkgs/servers/pufferpanel/default.nix b/pkgs/servers/pufferpanel/default.nix
index f1079a03fce..d3420f90db5 100644
--- a/pkgs/servers/pufferpanel/default.nix
+++ b/pkgs/servers/pufferpanel/default.nix
@@ -98,5 +98,6 @@ buildGoModule rec {
     homepage = "https://www.pufferpanel.com/";
     license = with licenses; [ asl20 ];
     maintainers = with maintainers; [ ckie tie ];
+    mainProgram = "pufferpanel";
   };
 }
diff --git a/pkgs/servers/web-apps/kavita/default.nix b/pkgs/servers/web-apps/kavita/default.nix
index 81f07c21319..c7d6e7b9567 100644
--- a/pkgs/servers/web-apps/kavita/default.nix
+++ b/pkgs/servers/web-apps/kavita/default.nix
@@ -73,5 +73,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
     license = lib.licenses.gpl3Only;
     platforms = lib.platforms.linux;
     maintainers = with lib.maintainers; [ misterio77 ];
+    mainProgram = "kavita";
   };
 })
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index 9010d63d5c6..aebfc73c5c1 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -161,6 +161,9 @@ self: super:
     + lib.optionalString stdenv.hostPlatform.isStatic ''
       export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lXau -lXdmcp"
     '';
+    meta = attrs.meta // {
+      mainProgram = "xdpyinfo";
+    };
   });
 
   xdm = super.xdm.overrideAttrs (attrs: {
@@ -814,6 +817,7 @@ self: super:
         --replace '_X_NORETURN' '__attribute__((noreturn))' \
         --replace 'n_dirs--;' ""
     '';
+    meta.mainProgram = "lndir";
   });
 
   twm = super.twm.overrideAttrs (attrs: {
@@ -940,6 +944,12 @@ self: super:
     '';
   });
 
+  xset = super.xset.overrideAttrs (attrs: {
+    meta = attrs.meta // {
+      mainProgram = "xset";
+    };
+  });
+
   # convert Type1 vector fonts to OpenType fonts
   fontbitstreamtype1 = super.fontbitstreamtype1.overrideAttrs (attrs: {
     nativeBuildInputs = attrs.nativeBuildInputs ++ [ fontforge ];
diff --git a/pkgs/tools/backup/tarsnap/default.nix b/pkgs/tools/backup/tarsnap/default.nix
index 8a0e43b6008..ad7fc761d84 100644
--- a/pkgs/tools/backup/tarsnap/default.nix
+++ b/pkgs/tools/backup/tarsnap/default.nix
@@ -40,5 +40,6 @@ stdenv.mkDerivation rec {
     license     = lib.licenses.unfree;
     platforms   = lib.platforms.unix;
     maintainers = with lib.maintainers; [ thoughtpolice roconnor ];
+    mainProgram = "tarsnap";
   };
 }
diff --git a/pkgs/tools/misc/coreboot-utils/default.nix b/pkgs/tools/misc/coreboot-utils/default.nix
index 1ba4c0aee9e..b96ccfd6fe7 100644
--- a/pkgs/tools/misc/coreboot-utils/default.nix
+++ b/pkgs/tools/misc/coreboot-utils/default.nix
@@ -65,6 +65,7 @@ let
     nvramtool = generic {
       pname = "nvramtool";
       meta.description = "Read and write coreboot parameters and display information from the coreboot table in CMOS/NVRAM";
+      meta.mainProgram = "nvramtool";
     };
     superiotool = generic {
       pname = "superiotool";
diff --git a/pkgs/tools/misc/direnv/default.nix b/pkgs/tools/misc/direnv/default.nix
index 88a07cd07af..179e719528a 100644
--- a/pkgs/tools/misc/direnv/default.nix
+++ b/pkgs/tools/misc/direnv/default.nix
@@ -50,5 +50,6 @@ buildGoModule rec {
     homepage = "https://direnv.net";
     license = licenses.mit;
     maintainers = teams.numtide.members;
+    mainProgram = "direnv";
   };
 }
diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix
index 45f5ed90577..7fad2c381c3 100644
--- a/pkgs/tools/misc/file/default.nix
+++ b/pkgs/tools/misc/file/default.nix
@@ -50,5 +50,6 @@ stdenv.mkDerivation rec {
     maintainers = with maintainers; [ doronbehar ];
     license = licenses.bsd2;
     platforms = platforms.all;
+    mainProgram = "file";
   };
 }
diff --git a/pkgs/tools/misc/nurl/default.nix b/pkgs/tools/misc/nurl/default.nix
index 00b9e990a8d..16fec1445a5 100644
--- a/pkgs/tools/misc/nurl/default.nix
+++ b/pkgs/tools/misc/nurl/default.nix
@@ -57,5 +57,6 @@ rustPlatform.buildRustPackage rec {
     changelog = "https://github.com/nix-community/nurl/blob/v${version}/CHANGELOG.md";
     license = licenses.mpl20;
     maintainers = with maintainers; [ figsoda ];
+    mainProgram = "nurl";
   };
 }
diff --git a/pkgs/tools/misc/vector/default.nix b/pkgs/tools/misc/vector/default.nix
index b74bd1c9e3c..fd3a94298c6 100644
--- a/pkgs/tools/misc/vector/default.nix
+++ b/pkgs/tools/misc/vector/default.nix
@@ -126,5 +126,6 @@ rustPlatform.buildRustPackage {
     license = licenses.mpl20;
     maintainers = with maintainers; [ thoughtpolice happysalada ];
     platforms = with platforms; all;
+    mainProgram = "vector";
   };
 }
diff --git a/pkgs/tools/misc/xvfb-run/default.nix b/pkgs/tools/misc/xvfb-run/default.nix
index 7b58b9c2d93..fc87723208e 100644
--- a/pkgs/tools/misc/xvfb-run/default.nix
+++ b/pkgs/tools/misc/xvfb-run/default.nix
@@ -60,5 +60,6 @@ stdenvNoCC.mkDerivation rec {
     platforms = platforms.linux;
     license = licenses.gpl2;
     maintainers = [ maintainers.artturin ];
+    mainProgram = "xvfb-run";
   };
 }
diff --git a/pkgs/tools/misc/yt-dlp/default.nix b/pkgs/tools/misc/yt-dlp/default.nix
index 3fa7a9a8076..e274222b27b 100644
--- a/pkgs/tools/misc/yt-dlp/default.nix
+++ b/pkgs/tools/misc/yt-dlp/default.nix
@@ -77,5 +77,6 @@ buildPythonPackage rec {
     '';
     license = licenses.unlicense;
     maintainers = with maintainers; [ mkg20001 SuperSandro2000 marsam ];
+    mainProgram = "yt-dlp";
   };
 }
diff --git a/pkgs/tools/networking/clash-meta/default.nix b/pkgs/tools/networking/clash-meta/default.nix
index 244eab7809b..c7275db6c0a 100644
--- a/pkgs/tools/networking/clash-meta/default.nix
+++ b/pkgs/tools/networking/clash-meta/default.nix
@@ -40,5 +40,6 @@ buildGoModule rec {
     homepage = "https://github.com/MetaCubeX/Clash.Meta";
     license = licenses.gpl3Only;
     maintainers = with maintainers; [ oluceps ];
+    mainProgram = "clash-meta";
   };
 }
diff --git a/pkgs/tools/networking/clash/default.nix b/pkgs/tools/networking/clash/default.nix
index 6ddf423657f..7eba0e1f215 100644
--- a/pkgs/tools/networking/clash/default.nix
+++ b/pkgs/tools/networking/clash/default.nix
@@ -40,5 +40,6 @@ buildGoModule rec {
     changelog = "https://github.com/Dreamacro/clash/releases/tag/v${version}";
     license = licenses.gpl3Only;
     maintainers = with maintainers; [ contrun Br1ght0ne ];
+    mainProgram = "clash";
   };
 }
diff --git a/pkgs/tools/networking/sitespeed-io/default.nix b/pkgs/tools/networking/sitespeed-io/default.nix
index 40949e6725a..f7b71b2fb4c 100644
--- a/pkgs/tools/networking/sitespeed-io/default.nix
+++ b/pkgs/tools/networking/sitespeed-io/default.nix
@@ -87,5 +87,6 @@ buildNpmPackage rec {
     license = licenses.mit;
     maintainers = with maintainers; [ misterio77 ];
     platforms = lib.unique (geckodriver.meta.platforms ++ chromedriver.meta.platforms);
+    mainProgram = "sitespeed-io";
   };
 }
diff --git a/pkgs/tools/networking/wgautomesh/default.nix b/pkgs/tools/networking/wgautomesh/default.nix
index 823987888a3..a9843e2efa1 100644
--- a/pkgs/tools/networking/wgautomesh/default.nix
+++ b/pkgs/tools/networking/wgautomesh/default.nix
@@ -21,5 +21,6 @@ rustPlatform.buildRustPackage rec {
     homepage = "https://git.deuxfleurs.fr/Deuxfleurs/wgautomesh";
     license = licenses.agpl3Only;
     maintainers = [ maintainers.lx ];
+    mainProgram = "wgautomesh";
   };
 }
diff --git a/pkgs/tools/package-management/harmonia/default.nix b/pkgs/tools/package-management/harmonia/default.nix
index 5b815261fbc..cee9301d594 100644
--- a/pkgs/tools/package-management/harmonia/default.nix
+++ b/pkgs/tools/package-management/harmonia/default.nix
@@ -44,5 +44,6 @@ rustPlatform.buildRustPackage rec {
     homepage = "https://github.com/nix-community/harmonia";
     license = licenses.mit;
     maintainers = with maintainers; [ mic92 ];
+    mainProgram = "harmonia";
   };
 }
diff --git a/pkgs/tools/package-management/nix/common.nix b/pkgs/tools/package-management/nix/common.nix
index e79f0f5e3bb..609d0da08af 100644
--- a/pkgs/tools/package-management/nix/common.nix
+++ b/pkgs/tools/package-management/nix/common.nix
@@ -241,6 +241,7 @@ self = stdenv.mkDerivation {
     maintainers = with maintainers; [ eelco lovesegfault artturin ];
     platforms = platforms.unix;
     outputsToInstall = [ "out" ] ++ optional enableDocumentation "man";
+    mainProgram = "nix";
   };
 };
 in self
diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix
index b72ee7a6911..faa280575e1 100644
--- a/pkgs/tools/system/auto-cpufreq/default.nix
+++ b/pkgs/tools/system/auto-cpufreq/default.nix
@@ -43,5 +43,6 @@ python3Packages.buildPythonPackage rec {
     license = licenses.lgpl3Plus;
     platforms = platforms.linux;
     maintainers = [ maintainers.Technical27 ];
+    mainProgram = "auto-cpufreq";
   };
 }
diff --git a/pkgs/tools/system/htop/default.nix b/pkgs/tools/system/htop/default.nix
index 215818862cd..c00f2578083 100644
--- a/pkgs/tools/system/htop/default.nix
+++ b/pkgs/tools/system/htop/default.nix
@@ -55,5 +55,6 @@ stdenv.mkDerivation rec {
     platforms = platforms.all;
     maintainers = with maintainers; [ rob relrod SuperSandro2000 ];
     changelog = "https://github.com/htop-dev/htop/blob/${version}/ChangeLog";
+    mainProgram = "htop";
   };
 }
diff --git a/pkgs/tools/system/kanata/default.nix b/pkgs/tools/system/kanata/default.nix
index b1fdb87551d..6e86812ece4 100644
--- a/pkgs/tools/system/kanata/default.nix
+++ b/pkgs/tools/system/kanata/default.nix
@@ -29,5 +29,6 @@ rustPlatform.buildRustPackage rec {
     license = licenses.lgpl3Only;
     maintainers = with maintainers; [ linj ];
     platforms = platforms.linux;
+    mainProgram = "kanata";
   };
 }