Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskellPackages: add mechanism to add meta.mainProgram #171895

Closed
wants to merge 1 commit into from

Conversation

malob
Copy link
Member

@malob malob commented May 7, 2022

Description of changes

Continuing on my personal mini-crusade to get nix run working with more packages in nixpkgs (e.g., #171863). I've added a mechanism to easily add meta.mainProgram to packages in haskellPackages.

I then use this to add meta.mainProgram to all Haskell packages available for x86_64-darwin and aarch64-darwin that provide a single binary where the name of that binary doesn't match the package's name or pname. Some of the binaries provided aren't really that relevant to anyone who would be using nix run, e.g., some libraries provide a binary called example. I elected to leave these in since I don't think it does any harm, and reviewing all the binaries individually would be a ton of work, and greatly increase the cost of maintaining this list. (Right now I can update the list by running a script and pasting the output into the file, then sorting it.)

I'm not super well versed in the nixpkgs Haskell ecosystem, so this should definitely be properly reviewed by someone who does before merging to ensure there aren't any bad/unintended consequences.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

and add meta.mainProgram to all packages available for x86_64-darwin and
aarch64-darwin that provide a single binary and the name of that binary
doesn't match the packages name or pname.
@malob
Copy link
Member Author

malob commented May 7, 2022

Result of nixpkgs-review pr 171895 run on aarch64-darwin 1

@sternenseemann
Copy link
Member

sternenseemann commented May 7, 2022

I think we should reject this PR. This adds a lot of data to be manually maintained when this task can completely automated away by adding it as a feature to cabal2nix which has all the necessary data available, since the cabal files list all available executables.

With this solution, updating the list requires building / downloading all packages that have isExecutable set and checking manually or looking at the respective cabal files. This is much less maintainable than having not to worry about it as all because it is set in the automatically generated package set.

(As a side note: overrideAttrs should not be used here, since subsequent overrideCabal calls would revert its changes.)

@sternenseemann
Copy link
Member

I've started to work on this, doesn't seem too hard. It should be no problem to add this feature in the next cabal2nix release.

@malob
Copy link
Member Author

malob commented May 9, 2022

I've started to work on this, doesn't seem too hard. It should be no problem to add this feature in the next cabal2nix release.

That sounds like a much better solution. Thanks!

With this solution, updating the list requires building / downloading all packages that have isExecutable set and checking manually or looking at the respective cabal files. This is much less maintainable than having not to worry about it as all because it is set in the automatically generated package set.

FWIW, this isn't actually the case. I've got got a nix expression that outputs the name, pname, and outPath, for everything in haskellPackages (or any part of nixpkgs) and uses nix store ls --store https://cache.nixos.org to check whether each package has a single binary that isn't named the same as the package's name/pname. Takes about 5 mins to run, and doesn't require building/downloading the packages.

@malob malob closed this May 9, 2022
@malob malob deleted the haskellPackages-mainProgram branch May 9, 2022 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants