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

Draft: Add Nix Language #6198

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Draft: Add Nix Language #6198

wants to merge 3 commits into from

Conversation

Rucadi
Copy link

@Rucadi Rucadi commented Feb 26, 2024

This PR tries to add NIX EVAL as a possible target for compiler-explorer.

image

This is a Draft, since I can't figure out yet how to add syntax highlighting to nix or the output.

For nix-language evaluation, I used: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-eval with output to json file.

@github-actions github-actions bot added the ui label Feb 26, 2024
@dkm
Copy link
Member

dkm commented Feb 26, 2024

Oh, that's nice!

compilerType=nix

group.nix.compilers=nixdefault
compiler.nixdefault.exe=/home/node/.nix-profile/bin/nix
Copy link
Member

Choose a reason for hiding this comment

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

This looks incorrect... I don't think we can default to ~node. Is there a better location where this is usually installed system-wide? I guess that on NixOS this is somewhere else

Copy link
Author

Choose a reason for hiding this comment

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

This is a little bit of a problem.

In Single-user nix installation, it gets installed in ~/.nix-profile/bin/nix.
In nixos, it gets symlinked to : /run/current-system/sw/bin/nix -> which is a symlink to the nix store nix
In multi-user nix installation, it gets installed in /nix/var/nix/profiles/default/bin/nix

I put there the path of the codespace where I was, but it could be a little tricky to select a safe default.

@@ -0,0 +1,62 @@
// Copyright (c) 2023, Compiler Explorer Authors
Copy link
Member

Choose a reason for hiding this comment

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

2024

@dkm
Copy link
Member

dkm commented Feb 26, 2024

You'll need a way to have the compiler installed without requiring to have nix installed in $HOME/.nix-profile. That will be the most difficult task I think.

@dkm
Copy link
Member

dkm commented Feb 26, 2024

For syntax highlighting, you can have a look at what the recent Spice support does in 54dda76#diff-9ba956095db84c8673973ef74862cf5ec230c54bc0a7feb703f387bbbb52a05a
But knowing the Nix community, I have no doubt someone already has a monaco config for this language.

@Rucadi
Copy link
Author

Rucadi commented Feb 26, 2024

You'll need a way to have the compiler installed without requiring to have nix installed in $HOME/.nix-profile. That will be the most difficult task I think.

This is quite easy, for this you actually don't need nix setup at 100%, you can use nixStatic, which is a statically-compiled nix binary ~25MB which is more than capable of using nix eval, since you don't actually want to build any derivation.

So this can run on any linux distribution without needing nix groups/paths/permissions setup at all :) (Also, nix doesn't really care of the path you are calling it from)

https://search.nixos.org/packages?channel=23.11&show=nixStatic&from=0&size=50&sort=relevance&type=packages&query=nixstatic

@mattgodbolt mattgodbolt marked this pull request as draft April 13, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants