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.
This commit is contained in:
Chua Hou 2022-07-06 19:25:58 +08:00 committed by GitHub
parent 278367ad80
commit 5d5d471409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,6 +356,14 @@ let
description = package.synopsis or "";
license = haskellLib.cabalToNixpkgsLicense package.license;
platforms = if platforms == null then lib.platforms.all else platforms;
} // lib.optionalAttrs (haskellLib.isExecutableType componentId) {
# Set main executable name for executable components, so that `nix run` in
# nix flakes will work correctly. When not set, `nix run` would (typically
# erroneously) deduce the executable name from the derivation name and
# attempt to run, for example,
# `/nix/store/...-project-exe-app-0.1.0.0/bin/project-exe-app` instead of
# `/nix/store/...-project-exe-app-0.1.0.0/bin/app`.
mainProgram = exeName;
};
propagatedBuildInputs =