Hi,
I’ve been trying to make a nix-ld NixOS module that supports 32-bit systems
NixOS:master
← KoviRobi:nix-ld-32bit
opened 10:39PM - 13 Jul 24 UTC
This now supports arbitrary `nix-ld`
Notes for reviewers:
- Should I fix exi… sting tests to not emit a warning due to mkRenamedOptionModule? It's been useful to not do so currently to check backwards compatibility.
- I could not find a natural way to select the 32-bit equivalent of a 64-bit system, so no `support32Bit` currently.
- Defaults for `libraries` do now get selected from the corresponding `pkgs`
Cross-referencing
- https://github.com/Mic92/nix-ld/issues/28
- https://github.com/nix-community/nix-ld-rs/issues/67
## Description of changes
<!--
For package updates please link to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->
## Things done
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [x] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2411.section.md) (or backporting [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) and [24.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [x] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
I have ran into the issue that I cannot merge a default list of values the way t is previously done (by providing a config.programs.nix-ld.libraries
), because that would need to do it for each of the systems in attrValues config.programs.nix-ld.systems
, which then creates an infinite loop (see my comment on PR )
Just putting the value into the option’s default isn’t very useful, because it isn’t merged, so is thrown away as soon as the user tries to specify additional libraries.
I have thought of a few poor options
Merge defaults when building the pkgs.buildEnv { name = "ld-library-path"; ...}
package. Issue is that these defaults then are not visible or overridable.nix-ld-libraries =
system: cfg:
cfg.pkgs.buildEnv {
name = "ld-library-path";
pathsToLink = [ "/lib" ];
paths = map lib.getLib (cfg.libraries ++ defaultLibraries);
# TODO make glibc here configurable?
postBuild = ''
ln -s ${cfg.pkgs.stdenv.cc.bintools.dynamicLinker} $out/${share-path system}/lib/ld.so
'';
extraPrefix = "/${share-path system}";
ignoreCollisions = true;
};
Have a config.programs.nix-ld.defaultLibraries
, a list of strings. Then as above, merge when building the library path package. Defaults now visible but need to be strings not packages. Maybe this is as good as we can do.nix-ld-libraries =
system: cfg':
cfg'.pkgs.buildEnv {
name = "ld-library-path";
pathsToLink = [ "/lib" ];
paths = map lib.getLib (
cfg'.libraries ++
(builtins.map (name: cfg'.pkgs.${name}) cfg.defaultLibraries)
);
# TODO make glibc here configurable?
postBuild = ''
ln -s ${cfg'.pkgs.stdenv.cc.bintools.dynamicLinker} $out/${share-path system}/lib/ld.so
'';
extraPrefix = "/${share-path system}";
ignoreCollisions = true;
};
Any better options?
Thank you,
Robert