Skip to content

Add Nix compatible build files.#61

Merged
orhun merged 16 commits into
orhun:mainfrom
DarthPJB:jb/flake-it
Jun 8, 2026
Merged

Add Nix compatible build files.#61
orhun merged 16 commits into
orhun:mainfrom
DarthPJB:jb/flake-it

Conversation

@DarthPJB

Copy link
Copy Markdown
Contributor

I am a user of NixOS a nightmarish hellscape of declarative builds and absolute mathematical derivations.

It's a odd place, but for the purposes of easily using your software the inclusion of a flake.nix build-pattern allows me great ease of consumption.

As such, I've added (and will do my best to maintain) the flake.nix required to build under the Nix Package manager; and hopefully wish that you will accept this addition upstream.

@orhun

orhun commented May 17, 2026

Copy link
Copy Markdown
Owner

Hello, thanks for the PR!

Have you seen #25? I think it's also doing the same thing there.
I think I was waiting that one primarily (the comments/feedback needs to be resolved etc.)

@DarthPJB

Copy link
Copy Markdown
Contributor Author

Hello, thanks for the PR!

Have you seen #25? I think it's also doing the same thing there. I think I was waiting that one primarily (the comments/feedback needs to be resolved etc.)

You know, I swear I looked.

I'll see if I can see the diff/contribute today.

@orhun

orhun commented May 22, 2026

Copy link
Copy Markdown
Owner

Haha no worries.

Would be nice to get either this PR or the other one in :)

@DarthPJB

Copy link
Copy Markdown
Contributor Author

Ok; so I've looked over the other and there's some fundamental differences in how we have packaged it that are somewhat esoteric.

I don't want to play me v.s. them, but I will present my reasoning as to my structure and differences.

  • Not all Nix/NixOS users are flake based; for this I provided a 'default.nix' that can be potentially used by a maintainer to upstream ratty to nixpkgs proper (though I have no intention to do this).
  • I have attempted to avoid dependence (such as flake-utils, home-manager, etc), this is a leaf-package, such configuration adds further evaluation burden that is not required for 'a binary executable' (users might do this easily in their own configuration

Cons:

  • I didn't even give a damn about anything but x86-linux as an environment
  • I made it work right but paid no heed to future-proofing.

@orhun I'm going to use some skill an an LLM to blatantly copy anything i consider valuable from the other PR to ensure feature parity; I don't intend to compete or disrespect, just contribute.

As the developer is there anything you feel such a packaging should be aware of or expose?
If you are not familiar with nix, we often expose tunable parameters at the top level of packages, so one can provide a json-like structure to parameterize features or settings.

@DarthPJB DarthPJB force-pushed the jb/flake-it branch 2 times, most recently from aed3db9 to 999e568 Compare May 28, 2026 17:52
@DarthPJB

Copy link
Copy Markdown
Contributor Author

@orhun I have updated my PR with changes, these include support for home-manager and darwin (though I admit I have not fully tested these, and invite contribution on the underlying basis provided.

I have also provided some (admitedly LLM generated) documentation on usage.

I feel this incorporates the competing branches functionality and provides a clear upstream path.

@orhun orhun mentioned this pull request May 29, 2026
@orhun

orhun commented May 29, 2026

Copy link
Copy Markdown
Owner

Can anyone who's well-versed in Nix help reviewing this?

@matthiasbeyer matthiasbeyer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think I am in no position to request changes here or approve either.

I have some questions here whether the package could be improved, one nitpick about the Cargo.lock change, but overall this looks good to me.

Comment thread nix/default.nix Outdated
Comment thread Cargo.lock
@orhun

orhun commented May 31, 2026

Copy link
Copy Markdown
Owner

Let me know if this is ready for a final review. I don't have much experience with Nix but I think I can test this locally

@DarthPJB

DarthPJB commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

So; although I have the changes incorporated into a near working state; the rebuild times have been a real workflow impediment.

I'm going to refactor slightly to use 'crane' a tool I've some experience with in the Nix ecosystem that lifts cargo-builds into discrete nix-builds; there's huge caching improvements - and I'm a bit of a perfectionist, bare with me a little.

John Bargman added 8 commits June 4, 2026 13:16
Replace Nix-unfriendly ${placeholder "out"} with idiomatic
'''\''' escaping to prevent evaluation-time interpolation
in the bash --run wrapper.
Replace rustPlatform.buildRustPackage with crane's buildDepsOnly +
buildPackage pattern. This splits the build into two derivations:
- buildDepsOnly: caches ~678 Bevy/transitive crates (keyed on Cargo.lock)
- buildPackage: builds only ratty source against cached artifacts

Subsequent source-only builds will skip the expensive Bevy compilation.
The triple-single-quotes (''') in Nix evaluate to a literal quote
character, wrapping the bash store path in single quotes and making
it unresolvable at runtime. Use ${placeholder "out"} and ${bash}
directly for clean store path interpolation.
Nix ''…'' strings don't support nesting — the inner ''…'' in the
--run block closed the outer postInstall string prematurely,
exposing 'in' as bare Nix syntax. Extract the script to a top-level
runScript variable and interpolate it via "…" syntax.
Without quotes, the shell splits the multiline runScript into separate
arguments. makeWrapper only consumed the first line as --run's value
and tried to parse the rest as additional wrapper args (e.g. 'postInstall').
Wrapping in single quotes ensures the entire script is one shell word.
@DarthPJB

DarthPJB commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

I've just taken the opportunity to pull the main branch; the rebuild was somewhat faster than before and worked as expected.

As such, I'm considering this ready for merge assuming there are no further suggestions.

@orhun orhun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

@orhun

orhun commented Jun 8, 2026

Copy link
Copy Markdown
Owner

thanks @DarthPJB @matthiasbeyer :)

@orhun orhun merged commit 26181fc into orhun:main Jun 8, 2026
11 checks passed
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.

3 participants