hey folks - is it be possible to have roc available on a nixos system atm? not building it locally but just including it as a nixpkg derivation or something like that? I use nixos + home-manager fwiw and I wanted to try and build roc stuff without necessarily having roc repo cloned and built locally.
if what I'm asking doesn't make sense I apologize, tho I use nixos I'm not that much of an expert yet :grinning:
I mean talking about editor experience: huge step up would be if Roc had could be added to devenv
shell with just pkgs.roc-lang
.
What it would take to do it?
With Flakes enabled, running Roc is a one-liner:
[rkb@nixos:~]$ nix run github:roc-lang/roc -- repl
The rockin’ roc repl
────────────────────────
Enter an expression, or :help, or :q to quit.
»
I mean talking about editor experience: huge step up would be if Roc had could be added to
devenv
shell with justpkgs.roc-lang
.What it would take to do it?
A release on nix is a high priority task that I hope to get to soon
just for reference, I ended up following the steps here and having roc set up on nixos was a breeze :heart:️
I wrote a basic Nix derivation to install the roc
binaries from tarball. Does this look ok? It works on my end so far. The tar is unpinned because nightly.
roc = pkgs.stdenv.mkDerivation {
name = "roc";
src = fetchTarball {
url =
"https://github.com/roc-lang/roc/releases/download/nightly/" +
"roc_nightly-macos_apple_silicon-latest.tar.gz";
};
installPhase = ''
mkdir -p $out/bin
cp -r . $out/bin
'';
};
Also is there any interest in getting roc onto nixpkgs? Or too early in development to warrant this?
definitely interested, that would be awesome! :grinning:
I can put together a PR for nixpkgs and see if they'll accept. Presumably will need to generalize the above for all OS variants. I looked into the default.nix on roc's main GH repo but couldn't build it on my M1 Mac
I'm not sure if the nightly binaries work on nixos at the moment btw
that may have gotten fixed, but I don't remember
I think there was a libc issue because we build them against glibc right now?
Runtime issue or installation?
we want to build them with musl and statically link them, but to do that we need a llvm build that uses musl, which is nontrivial
there's no installation, it's just a roc
binary
I think the nixpkgs CI/CD tests on a variety of OSes including its own. Curious to see what happens if we just supply the pre built tarballs per OS
I think you would at a minimum need nix to update all of the dynamic dependencies. They will be pointing to files in the location expected in ubuntu, not nix
fwiw building from source using our nix flakes should work
that's what I use for macOS dev
Maybe my build failed because I wasn't using the flake. I just tried the shell.nix and nix-build default.nix
. Probably not repeatable..
Is the move to use nix develop
_then_ build the default.nix?
I plan to look into a release on nixpkgs this week using the (fixed) default.nix file
Is the move to use
nix develop
_then_ build the default.nix?
nix develop
then cargo build --release --bin roc
should be the most reliable
Got it, yeah that works
@Anton maybe a Nix overlay could be considered instead of nixpkgs itself?
Oh, that's interesting. I had not thought of that yet, rust-overlay handles rust nightlies so I could see that work for us too. Excellent suggestion! I'll look into that
Yeah exactly I'm using that for Rust, and my friends over at Unison are using it for their lang too
Happy to get involved in this effort, will idle here
Oh yeah sure, go ahead :)
I recommend testing stuff with a personal repo and once it's ready we can put it in roc-lang/roc or roc-lang/roc-nix-overlay.
Feel free to contact me for further questions or help with errors.
Btw I couldn't get the build to work from nix flakes
This is on Mac M2 arch using the flake.nix and cargo
error: failed to run custom build command for `roc_bitcode_bc v0.0.1 (/Users/I568890/Github/roc/crates/compiler/builtins/bitcode/bc)`
Caused by:
process didn't exit successfully: `/Users/I568890/Github/roc/target/release/build/roc_bitcode_bc-9e9ce06b21ac5bc0/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/I568890/Github/roc/crates/compiler/builtins/bitcode/bc/../builtins-host.ll
Compiling 64-bit bitcode to: /Users/I568890/Github/roc/crates/compiler/builtins/bitcode/bc/../builtins-host.bc
--- stderr
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread 'main' panicked at 'zig build ir -Drelease=true failed with:
thread 8398749 panic: Darwin is handled separately via std.zig.system.darwin module
Unable to dump stack trace: debug info stripped
', crates/compiler/builtins/bitcode/bc/build.rs:126:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oh yes, that's due to #5590. We've been putting a lot of work in the upgrade that fixes this but we have a few more difficult bugs to solve there.
Got it, as mentioned in the docs too
I'm afraid that will make working on the overlay difficult unless you want to set up a VM or have another supported device/OS available
Our upgrade could also be done soon though...
Or, perhaps you could work on the overlay while using the zig-11-llvm-16 branch. All tests passed on an m1 macos12 CI server so that just might work for you :)
Sure let me try that branch. But good point.. would need to build from source to work on an overlay
Yup that branch works just fine
Awesome :)
Last updated: Jul 06 2025 at 12:14 UTC