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

Add Crystal Language #82

Merged
merged 1 commit into from
Jan 27, 2023
Merged

Add Crystal Language #82

merged 1 commit into from
Jan 27, 2023

Conversation

bcardiff
Copy link
Contributor

This attempts to re-add crystal support. Based on #53, the compiler was missing.

Since crystal compiler support is based on nixpkgs currently building the package on some distros might fail.

The latest release of crystal in nixpkg is 1.2.2, yet in https://github.com/crystal-lang/crystal is 1.6.2 .

I hope this will help to push the support of crystal in nixpkg.

If the state of the art of crystal in nixpkg is not good enough, please close the PR and we can discuss either

  1. how to improve crystal in nixpkg
  2. alternative routes to support the crystal compiler (maybe by a hosted flake somewhere else)?

If accepted, should I update some documentation/examples artifacts also?

@domenkozar
Copy link
Member

Hey! Thanks a lot for this work - before we can merge this Crystal needs to build in nixpkgs.

I'd suggest bumping it to the latest version and making sure it builds on linux/darwin (remove broken flag in its source).

Let me know if you need more guidance :)

@domenkozar
Copy link
Member

@manveru
Copy link

manveru commented Jan 2, 2023

I'm maintaining https://github.com/manveru/crystal-flake for some time now, because building Crystal from source on all the different platforms seems to be a never-ending time sink and it breaks in nixpkgs constantly. Not sure if you'd consider using this?

@bcardiff
Copy link
Contributor Author

bcardiff commented Jan 5, 2023

I'm not sure if flakes can be used for first class citizen languages in devenv.

Yet I got errors in x86_64-darwin and aarch64-darwin so we are still blocked in the nixpkgs PR :-(

x86_64-darwin

% nix shell github:manveru/crystal-flake#crystal
error: builder for '/nix/store/g1cig0252m9971pgn2fdksdjaffrih32-crystal-1.6.2.drv' failed with exit code 2;
       last 10 log lines:
       > configuring
       > no configure script, doing nothing
       > building
       > build flags: -j16 -l16 SHELL=/nix/store/fn6kkg71q3wb6px5n3b89z14rhvii1xn-bash-5.1-p16/bin/bash all docs
       > Using /nix/store/0vc47k3375w8nil6cm2zggq8rkghvwzn-llvm-11.1.0-dev/bin/llvm-config [version= 11.1.0]
       > clang++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/nix/store/0vc47k3375w8nil6cm2zggq8rkghvwzn-llvm-11.1.0-dev/include -std=c++14 -stdlib=libc++  -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
       > CRYSTAL_CONFIG_BUILD_COMMIT="" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1672946257"  CRYSTAL_CONFIG_LIBRARY_PATH='$ORIGIN/../lib/crystal' ./bin/crystal build --threads=16 -D strict_multi_assign -Dwithout_interpreter  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
       > ./bin/crystal: line 169: /nix/store/8v02rw33b8pgs9hmfh98zrrmzmssvghk-crystal-bin-1.6.2/bin/crystal: cannot execute binary file
       > ./bin/crystal: line 169: /nix/store/8v02rw33b8pgs9hmfh98zrrmzmssvghk-crystal-bin-1.6.2/bin/crystal: Undefined error: 0
       > make: *** [Makefile:189: .build/crystal] Error 1
       For full logs, run 'nix log /nix/store/g1cig0252m9971pgn2fdksdjaffrih32-crystal-1.6.2.drv'.

aarch64-darwin:

% nix shell github:manveru/crystal-flake#crystal
error: builder for '/nix/store/60cawzxfj7csgci6acc09qkkmd72hb8j-crystal-bin-1.6.2.drv' failed with exit code 1;
       last 10 log lines:
       > source root is source
       > patching sources
       > updateAutotoolsGnuConfigScriptsPhase
       > configuring
       > no configure script, doing nothing
       > building
       > no Makefile, doing nothing
       > installing
       > cp: cannot stat 'lib': No such file or directory
       > cp: cannot stat 'share': No such file or directory
       For full logs, run 'nix log /nix/store/60cawzxfj7csgci6acc09qkkmd72hb8j-crystal-bin-1.6.2.drv'.
error: 1 dependencies of derivation '/nix/store/yf69jmlrn4g4vdbx0bw65qmkl3ixhy51-crystal-1.6.2.drv' failed to build
bcardiff@nimbus ~ % nix log /nix/store/60cawzxfj7csgci6acc09qkkmd72hb8j-crystal-bin-1.6.2.drv
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/mngy992ppgday0555kb03r770f45zblp-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
no Makefile, doing nothing
@nix { "action": "setPhase", "phase": "installPhase" }
installing
cp: cannot stat 'lib': No such file or directory
cp: cannot stat 'share': No such file or directory

@manveru
Copy link

manveru commented Jan 7, 2023

Thanks for trying, I have no macs around, so those attributes haven't seen any testing... mostly just added them because someone requested it.

@bcardiff
Copy link
Contributor Author

crystal package is no longer broken in nixpkgs :-)
I rebased this on master.

I would like to understand how in the future the multiple version of the compiler could be supported. Is there anywhere I can read about it?

So far I see that some languages offers a package option where one can override which expression provides the package. That would be limited by the versions available in the pinned nixpkgs version. Is that the initial idea? Can flakes be used so for example https://github.com/manveru/crystal-flake can be used when needed?

Finally, I don't see language packages offering default behaviors like pre-commit hooks for autoformat the code. At least having that opt-in would make sense in Crystal and Elm since their formatter are broadly used.

@domenkozar
Copy link
Member

Adding a package makes sense as a first step. Second step is something like https://github.com/bobvanderlinden/nixpkgs-ruby, where all versions of the language is built.

As for the pre-commit hooks, I haven't found a good solution yet. I don't want to turn them on by default. Maybe each language should have a documentation page suggesting these things.

@domenkozar domenkozar merged commit 12df8e7 into cachix:main Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants