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 nix support #74

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

Add nix support #74

wants to merge 8 commits into from

Conversation

nxy7
Copy link

@nxy7 nxy7 commented Dec 18, 2024

Hi, I was interested in trying out roc-start but as I'm NixOS user I'd prefer to use flake over bash scripts.
I've added very crude buildRocPackage.nix file, flake and used that there.

As far as I know it might very well be the first thing doing something like buildRocPackage (I've browsed public roc repos and didn't find a single one distributing roc program as output of the flake).

I'm using roc-start distributed with this setup and it seems to be working
https://github.com/nxy7/dotfiles/blob/63efaa62e56125aed9d45555c5d088ac9f782f44/flake.nix#L87
https://github.com/nxy7/dotfiles/blob/63efaa62e56125aed9d45555c5d088ac9f782f44/home/packages.nix#L4

image

flake.nix Outdated
roc-start = import ./buildRocPackage.nix {
inherit pkgs roc-cli;
src = ./.;
outputHash = "sha256-huhu+fXYoxxf8WT2eQ5teGM6t1ziWyaTVdUAz6mBaTo=";
Copy link
Author

Choose a reason for hiding this comment

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

If I'm getting Roc right dependencies will always be declared in main.roc and if any single one of them is updated/removed/added this hash should be updated.

@nxy7 nxy7 marked this pull request as draft December 19, 2024 00:21
@nxy7
Copy link
Author

nxy7 commented Dec 19, 2024

Actually it might need some small fix because the app is not getting arguments from the CLI (for some reason. I'll try to fix it soon, but you can tell me if you're interested in adding flake.nix to the repo.
EDIT. It seems like it might be some other issue not related to nix, as this happens even if I try to run it from CLI (not nix derivation)
image

@nxy7
Copy link
Author

nxy7 commented Dec 19, 2024

I've added printing of arguments passed in
https://github.com/nxy7/roc-start/blob/d67a6c1d84d62ec45463e733d387da61878eb850/src/main.roc#L43

For some reason arguments aren't parsed at all, doesn't seem to be nix issue at all..
image

@imclerran
Copy link
Owner

imclerran commented Dec 19, 2024

Thanks for working on Nix support. What you are running into is #68 which actually is roc-lang/basic-cli#82, which causes cli args to be empty. This is an issue when using the legacy linker.

The filer for #68 tried using the surgical linker, which does not have the basic-cli args issue, but the surgical linker did not work in his case.

Have you tried building with --linker=surgical? I know the surgical linker still has issues on Linux, but I believe that varies by distro.

@nxy7
Copy link
Author

nxy7 commented Dec 20, 2024

Surgical linker also doesn't seem to be working. I've actually refactored buildRocPackage out from this PR and will try to get it into main Roc repo. Once new release fixes issues with the linker I'll open this PR and ping you.

@nxy7 nxy7 force-pushed the add-nix-support branch from f300395 to 7b75f0c Compare January 2, 2025 15:56
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.

2 participants