Stream: beginners

Topic: nixos / nixpkgs


view this post on Zulip Georges Boris (May 18 2023 at 11:31):

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:

view this post on Zulip Zeljko Nesic (May 18 2023 at 21:40):

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?

view this post on Zulip RKB (May 19 2023 at 01:06):

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.

»

view this post on Zulip Anton (May 19 2023 at 08:43):

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?

A release on nix is a high priority task that I hope to get to soon

view this post on Zulip Georges Boris (May 19 2023 at 10:34):

just for reference, I ended up following the steps here and having roc set up on nixos was a breeze :heart:

view this post on Zulip Narek Asadorian (Oct 17 2023 at 16:49):

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
    '';
  };

view this post on Zulip Narek Asadorian (Oct 17 2023 at 16:50):

Also is there any interest in getting roc onto nixpkgs? Or too early in development to warrant this?

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:06):

definitely interested, that would be awesome! :grinning:

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:09):

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

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:10):

I'm not sure if the nightly binaries work on nixos at the moment btw

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:11):

that may have gotten fixed, but I don't remember

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:11):

I think there was a libc issue because we build them against glibc right now?

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:12):

Runtime issue or installation?

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:12):

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

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:12):

there's no installation, it's just a roc binary

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:13):

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

view this post on Zulip Brendan Hansknecht (Oct 17 2023 at 17:14):

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

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:15):

fwiw building from source using our nix flakes should work

view this post on Zulip Richard Feldman (Oct 17 2023 at 17:15):

that's what I use for macOS dev

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:16):

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..

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:17):

Is the move to use nix develop _then_ build the default.nix?

view this post on Zulip Anton (Oct 17 2023 at 17:17):

I plan to look into a release on nixpkgs this week using the (fixed) default.nix file

view this post on Zulip Anton (Oct 17 2023 at 17:18):

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

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:25):

Got it, yeah that works

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:27):

@Anton maybe a Nix overlay could be considered instead of nixpkgs itself?

view this post on Zulip Anton (Oct 17 2023 at 17:28):

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

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:29):

Yeah exactly I'm using that for Rust, and my friends over at Unison are using it for their lang too

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:30):

Happy to get involved in this effort, will idle here

view this post on Zulip Anton (Oct 17 2023 at 17:37):

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.

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:42):

Btw I couldn't get the build to work from nix flakes

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:42):

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

view this post on Zulip Anton (Oct 17 2023 at 17:44):

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.

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:46):

Got it, as mentioned in the docs too

view this post on Zulip Anton (Oct 17 2023 at 17:47):

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

view this post on Zulip Anton (Oct 17 2023 at 17:48):

Our upgrade could also be done soon though...

view this post on Zulip Anton (Oct 17 2023 at 17:52):

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 :)

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:56):

Sure let me try that branch. But good point.. would need to build from source to work on an overlay

view this post on Zulip Narek Asadorian (Oct 17 2023 at 17:58):

Yup that branch works just fine

view this post on Zulip Anton (Oct 17 2023 at 17:59):

Awesome :)


Last updated: Jul 06 2025 at 12:14 UTC