@@ -356,6 +356,14 @@ let
356 description = package.synopsis or "";
356 description = package.synopsis or "";
357 license = haskellLib.cabalToNixpkgsLicense package.license;
357 license = haskellLib.cabalToNixpkgsLicense package.license;
358 platforms = if platforms == null then lib.platforms.all else platforms;
358 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;
361 propagatedBuildInputs =
369 propagatedBuildInputs =