Structured cmakeFlags / attrs

I am looking for a solution for luarocks to deal with cmake based packages. The best fix would be to have structured cmakeFlags which was mentioned in [RFC 0013] Ergonomic `cmakeFlags` by aneeshusa · Pull Request #13 · NixOS/rfcs · GitHub, with PRs like [WIP/RFC] Make `cmakeFlags` more ergonomic by aneeshusa · Pull Request #17886 · NixOS/nixpkgs · GitHub.

Seems like stdenv: enable __structuredAttrs by globin · Pull Request #72074 · NixOS/nixpkgs · GitHub is the way forward.
I tried to enable __structuredAttrs = true for just my derivation but it ended up with /setup: No such file or directory errors.
1/ any quickfix to address this error ?
2/ what’s the status of stdenv 2.0 ?

Cheers

4 Likes

stdenv: enable __structuredAttrs by globin · Pull Request #72074 · NixOS/nixpkgs · GitHub is the way forward. We need to clone @globin @jtojnar 5x each so we can finish it :).

I dont mind helping with the workload as it is a crucial feature that could really help clean nixpkgs. But I would need some guidance and I guess it might not be easy to split the load anyway.

In case anyone is interested, I opened a (draft) PR tackling this.

4 Likes

Here’s my second take:

6 Likes

Given the approvals, I’m planning to merge the `cmakeEntries` PR. Could someone help take a look at the documentation and the release note?

1 Like

Tangential topic (don’t feel like starting a separate thread) we on the cuda team were about to ping you on: now that we’re moving to __structuredAttrs, none of the setup-hook modified makeFlags, cmakeFlags, mesonFlags, &c are now available outside bash, i.e. in subprocesses, which is why in python3Packages.triton: 3.6.0 -> 3.7.0; python3Packages.torch: 2.11.0 -> 2.12.0 by GaetanLepage · Pull Request #519925 · NixOS/nixpkgs · GitHub we’re temporarily going to make the assumption that cmakeFlags are static.

As such, we’ll be now needing the stdenv hook to feature some logic for updating the env synchronously with updating NIX_ATTRS_JSON_FILE. Do you already have some ideas for how to tackle this?

CC @ConnorBaker @YorikSar @glepage

Per Someone’s request, NixOS/nixpkgs PR #42017 now updates $NIX_ATTRS_JSON_FILE and the cmakeEntries/cmakeFlags shell variables simultaneously, and observe the JSON file as the source of truth.

Nevertheless, the diff of this implementation is significantly larger, which mainly consists of four CMake scripts and various getters and setters.

Please take a look!

1 Like

Woah, libchdr looks way nicer :open_mouth:

2 Likes