This allows users to put zig in their `mkShell` without ending up with a
ZIG_GLOBAL_CACHE_DIR value set that points back to a location that only
would exist in the sandbox.
This setup hook discovers glycin loaders in the inputs list it is placed into, and adds them to `gappsWrapperArgs`. This should simplify glycin-dependent programs’ expressions.
Just add `libglycin.setupHook` (for Rust programs) or `libglycin` (for other languages) to `buildInputs`. The latter will also pull in the setup hook.
Note, the setup hook needs to go to the `buildInputs` since we cannot have a different offset when used as standalone hook instead of propagated from `libglycin`. We chose `hostOffset` to make it work with the proper placement of `libglycin` in `buildInputs`.
Co-authored-by: Seth Flynn <getchoo@tuta.io>
Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
Glycin rust library searches `bwrap` on path. This would require every reverse dependency to add `bubblewrap` to its `PATH`, which would be quite annoying to ensure. Especially when libraries start using glycin.
We provide `passthru.glycinPathsPatch` to perform source-level hardcoding but that doesn't work with apps that use `rustPlatform.cargoSetupHook` since it assumes a setup where snapshots of GNOME sources already contain vendored Rust dependencies under `vendor/`.
The setup hook instead provides a much more flexible approach that uses the `$cargoDepsCopy` variable provided by `cargoSetupHook`, which points to the local, modifiable copy of Cargo dependencies, to patch `src/sandbox.rs` just like `glycinPathsPatch`. If `$cargoDepsCopy` is not found, then the old behavior is used where Cargo dependencies are assumed to be under `vendor/`.
Additionally, the patch requires modifying `Cargo.lock` when using `rustPlatform.fetchCargoVendor`. The setup hook fixes that as well.
Rust programs just need to add `libglycin.patchVendorHook` and it should take care of this.
Co-authored-by: Seth Flynn <getchoo@tuta.io>
Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
By moving the zig setup hook to the zig derivation itself, we allow for
zig to splice correctly with `callPackage`, meaning that the correct zig
can be pulled in during builds when zig is in `nativeBuildInputs` (for
example).
This change retains the `zig.hook` attribute for backward compatibility
by just pointing to the zig derivation. This also removes
`zig_default_flags`, since now the setup hook is not a derivation that
can be overridden. Overriding the build flags can now be done by setting
`dontSetZigDefaultFlags = true`.
This replaces the `versionCheckDontIgnoreEnvironment` parameter. Keeping
all environment variables is still possible by using
`versionCheckKeepEnvironment = "*";`.
Motivation for this hook is simple: there's no single documented
way to do trivial things with ctest:
1. Pass additional flags to ctest invocation.
2. Selectively disable tests in a mechanism similar to python's
`disabledTests` or rust's composable skips in `checkFlags`.
3. Disable parallel checking.
Current state of things has lead to several different solutions:
1. Completely overriding `checkPhase` [1] and invoking ctest manually
with the necessary flags. This is most often coupled with `-E` for
disabling test or setting parallel level.
2. Wrangling with weird double string/regex escaping and trying to stuff
additional parameters and/or exclusion regex via `CMAKE_CTEST_ARGUMENTS`.
This approach is especially painful when test names have spaces. This is
the reason I originally decided to implement this hook after wrangling with
failing darwin tests here [2].
3. Stuffing additional arguments into `checkFlagsArray` with the
`ARGS` makefile parameter [3].
I don't see any reason to keep the status-quo. Doing something along these
lines has been suggested [4] for both `ctest` and `meson`. Meson setup-hook
has switched from `ninja` to `meson` in [5] with little friction. Doing
the same for cmake in a single sweep would prove problematic due to the
aforementioned zoo of workarounds and hacks for `ctest`. Doing it via
a separate hook would allow us to refactor things piecemeal and without
going through staging. The benefit of the hook is immediately clear and it
would allow to drive the refactor tractor at a comfortable pace.
[1]: pd/pdal/package.nix:117, cc/ccache/package.nix:108, gl/glog/package.nix:79
[2]: https://www.github.com/NixOS/nixpkgs/pull/375955
[3]: op/open62541/package.nix:114
[4]: https://www.github.com/NixOS/nixpkgs/issues/113829
[5]: https://www.github.com/NixOS/nixpkgs/pull/213845