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

crystal: change all crystal programs to use buildCrystalPackage and update pkgs #83054

Merged
merged 9 commits into from Apr 22, 2020

Conversation

peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 21, 2020

Motivation for this change

See the last comments for more details.

The icr change is straight forward and only included here to showcase the change in how we build crystal packages.

The crystal builder will now use a Makefile if one is included by the project, shards if we have the required files in place and otherwise build the specified binaries (the old behaviour).

Couple of other things to note:

  1. we add a few more things to nativeBuildInputs that are required by several crystal programs.
  2. upstream recommends not building with --no-debug so rip that out
  3. support copying in a lockfile if the program doesn't have one (lucky-cli I'm looking at you)

The way I've done the conditionals where we combine bash conditionals with nix conditionals is very ugly and I'm not proud of that at all but it works.

Cc @manveru as the person we have to thank for having the crystal build infrastructure in the first place.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@manveru manveru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@peterhoeg
Copy link
Member Author

Thanks for the feedback. I just made the build and install targets configurable, but otherwise this version is the same. I have nixpkgs-fmt running in a save hook, so that's the reason for all the noise.

@peterhoeg
Copy link
Member Author

@GrahamcOfBorg build crystal2nix mint scry gitAndTools.thicket

@manveru
Copy link
Contributor

manveru commented Apr 17, 2020

Shards now depend on buildCrystalPackage to build, since they have introduced a shard as a dependency... so now we get infinite recursion with this.

@peterhoeg
Copy link
Member Author

now we get infinite recursion with this.

I saw that last night as well. Upstream was discussing distributing shards with the dependency vendored to avoid having to depend on itself. Maybe we could just do that to avoid the problem until they figure out what they want. I'm open to ideas.

@manveru
Copy link
Contributor

manveru commented Apr 19, 2020

It'd be nice if we allowed an attrset instead of a path for the shardsFile. That way you could inject your own versions of shards more easily. Maybe also allowing JSON format for the shards file, so the generator can be simpler and faster...

@peterhoeg
Copy link
Member Author

I'm just seeing your comment about the attrset now, so that has not been addressed.

I hijacked my own PR to clean up the various crystal bits we carry to have them all up to date and using buildCrystalPackage. Few things to note:

  1. we now run tests unless disabled
  2. instead of the fugly bash/nix combo that tries to find the right thing to build, we simply make it configurable similar to how it works for python using a format attr.
  3. I have a vendored version of shards which I think we should stick under the nixos/nix-community org for the future.
  4. some of them are pinned against older crystal versions. I did that directly with each program instead of all-packages.nix to avoid forgetting about it at the next update cycle. I don't use mint, so I haven't tried that. But it compiles and the tests pass.
  5. I had initially undone your work to move shards to buildCrystalPackage but with the configurable format we avoid the cyclical dependency.

@peterhoeg peterhoeg changed the title icr: 0.6.0 -> 0.8.0 and use shards to build crystal packages crystal: change all crystal programs to use buildCrystalPackage Apr 19, 2020
@peterhoeg peterhoeg changed the title crystal: change all crystal programs to use buildCrystalPackage crystal: change all crystal programs to use buildCrystalPackage and update pkgs Apr 19, 2020
@peterhoeg
Copy link
Member Author

If nobody has any objections (@manveru @kimburgess @filalex77) I'll be merging this soonish.

@kimburgess
Copy link
Member

Changes to Ameba look good 👍

I've only had time for a shallow read so am not familiar with the current limitations, but working to move away from using that vendored shards repo seems like a neater long term. Possibly worth spinning up a separate issue for tracking / resolving that.

repo = "shards";
rev = "v${version}";
sha256 = "1bjy3hcdqq8769bx73f3pwn26rnkj23dngyfbw4iv32bw23x1d49";
owner = "peterhoeg";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you the new maintainer of shards?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. This is the vendored version. Maybe nix-community would be a better place for this, so we can add more contributors easier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think we can do without the vendored version. Let me take a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can. Plus we now get man pages as well.

@peterhoeg peterhoeg force-pushed the u/icr branch 2 times, most recently from 9c9c565 to 1047042 Compare April 22, 2020 07:36
@peterhoeg
Copy link
Member Author

@GrahamcOfBorg build ameba crystal2nix icr mint scry shards gitAndTools.thicket

1 similar comment
@peterhoeg
Copy link
Member Author

@GrahamcOfBorg build ameba crystal2nix icr mint scry shards gitAndTools.thicket

@manveru
Copy link
Contributor

manveru commented Apr 22, 2020

@peterhoeg seems like it still fails on missing installManPage.
If all builds pass, I'm all for merging this.

@peterhoeg
Copy link
Member Author

I was working against unstable but when rebasing against master, I got the error too. Ahhh, well. It's fixed now.

@peterhoeg
Copy link
Member Author

Thanks for your feedback guys, I'm merging this.

@peterhoeg peterhoeg merged commit f690b34 into NixOS:master Apr 22, 2020
@peterhoeg peterhoeg deleted the u/icr branch April 22, 2020 12:33
checkTarget = "test";
postFixup = ''
wrapProgram $out/bin/icr \
--prefix PATH : ${lib.makeBinPath [ crystal shards makeWrapper which ]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the makeWrapper here looks like a mistake so i'll remove it

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

5 participants