on iko/ghcjs-patch-master help sign in
Set meta.mainProgram for executable components (#1539)

- This allows nix run to work correctly, so that it knows the correct name of the executable, as it would otherwise attempt to execute an executable named "project-name-exe-exeName", for example. - See #1231.

commit5d5d4714092704caf4459dc4c81abd2e82ab2bd7 authorChua Hou <human+github@chuahou.dev> dateWed 6 Jul 2022, 19:25 (4 years ago) parent278367a
1 file changed+8
builder/comp-builder.nix+8
builder/comp-builder.nix+8
@@ -356,6 +356,14 @@ let
356356 description = package.synopsis or "";
357357 license = haskellLib.cabalToNixpkgsLicense package.license;
358358 platforms = if platforms == null then lib.platforms.all else platforms;
359+ } // lib.optionalAttrs (haskellLib.isExecutableType componentId) {
360+ # Set main executable name for executable components, so that `nix run` in
361+ # nix flakes will work correctly. When not set, `nix run` would (typically
362+ # erroneously) deduce the executable name from the derivation name and
363+ # attempt to run, for example,
364+ # `/nix/store/...-project-exe-app-0.1.0.0/bin/project-exe-app` instead of
365+ # `/nix/store/...-project-exe-app-0.1.0.0/bin/app`.
366+ mainProgram = exeName;
359367 };
360368
361369 propagatedBuildInputs =