-
Notifications
You must be signed in to change notification settings - Fork 22
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
nix flakes #111
Comments
The flake way appears to be to expose them all as attributes in the root flake, so: # from flake.nix devShells."<system>".${attr}
nix develop .
nix develop .#cpp
# could also probably be nix develop .#cpp.lto
nix develop .#cpp-lto
nix develop .#php
# etc
# from flake.nix packages."<system>".${attr}
nix build .
nix build .#cpp
nix build .#cpp-lto
nix build .#php
# etc
# from flake.nix apps."<system>".${attr}
nix run .
nix run .#cpp
nix run .#cpp-lto
nix run .#php
# etc
# Or from a URL:
nix run github.com:shish/rosettaboy#php Although there isn't currently an implementation for Although there's probably better examples, I flake-ified this recently as an example. |
In general, you can actually re-use most already-written nix scripts in either direction, as long as they are pure. From flake-style to old-style: just call e.g. From old-style to flake-style: https://github.com/edolstra/flake-compat |
I think I would recommend starting by adding old-style build derivations for each language in e.g. You also get most of a devShell for free when you implement the build derivation. (edit) or maybe not, will end up with a bunch of unnecessary pinned dependencies in the old-style scripts (/edit) |
I mentioned in #57 that I started putting together a flake for rosettaboy way back when. It's definitely fallen out of date by now but hopefully it's still a useful starting point. In addition to what you described in the OP:
I was also aiming to:
@jbboehr is correct; the idiomatic way to expose separate devShells/packages/etc. is with attributes; i.e. I believe it's possible to get Using
For the former ( I think the bulk of the work here will be getting each language's impl to build in the sandbox (and then to run in the sandbox if you want to have A good first step is probably to add a flake with just Lines 8 to 39 in 453043b
(branch here; if the above looks okay, let me know and I can open a PR) |
This seems fine to me - I'm happy to adjust myself to do things the idiomatic way, rather than trying to force nix to conform to my idea of how I'd do it if I were building from scratch :) |
I've been looking into writing derivations for some of the other languages and a lot of the nix language tooling is moving to flakes, so I think it would be good to get a basic flake up and running. I can make it work without flakes, but it's ugly. @rrbutani's rec {
packages = {
go = pkgs.callPackage ./go/derivation.nix { inherit gomod2nix; };
rust = pkgs.callPackage ./rust/derivation.nix { inherit naersk; };
rust-debug = pkgs.callPackage ./rust/derivation.nix { inherit naersk; debugSupport = true; };
rust-lto = pkgs.callPackage ./rust/derivation.nix { inherit naersk; ltoSupport = true; };
};
} Some of the ones I looked into briefly so far: Rust via https://github.com/nix-community/naersk |
Nix flakes appear to have a bunch of benefits over the current
shell.nix
approach, but they also seem more complicated to set up and I haven't got my head around them yet...I think in my ideal world:
nix develop
runs a shell with all the development tools necessary to build things./utils/bench.py --default --frames 10 --threads 4
should report everything passingnix build
builds binaries for the current language / all languagesbin/rosettaboy-<language>-<variant>
instead of<language>/rosettaboy-<variant>
?nix shell github:shish/rosettaboy
will build and install all the versions?nix shell
a specific language version without needing to pull in hundreds of megs of dev tools for all languages?The text was updated successfully, but these errors were encountered: