3 ms·
Customizing packages is something I do occasionally to debug FOSS. I don’t recall which package I wanted to debug, but I remember that I gave up after my laptop
by secure 8y ago
Customizing packages is something I do occasionally to debug FOSS. I don’t recall which package I wanted to debug, but I remember that I gave up after my laptop was compiling for many hours. Any changes to one NixOS package automatically invalidate all of its reverse-dependencies, which isn’t the case with e.g. Debian, where I can, when deeming it safe, rebuild a package and install it over the currently installed version.
- mbrock 8y agoYeah, although you have a lot of flexibility regarding how much of your system will be rebuilt. Like, if you add a little patch to libpng as an overlay over your entire system, then you'll recompile a lot of stuff, but you can also choose to only use that custom libpng with a specific package. Even in the latter case, it's true that Nix will always recompile the package that depends on libpng, instead of using dynamic linking and only recompiling libpng. This is because Nix has no way of knowing how your libpng patch will affect its reverse dependency, and because link paths are always content-addressed in Nix for reproducibility.
- secure 8y agoIt wasn’t apparent to me from the docs (back then?) how to use the custom libpng only with a specific package. Do you have a pointer to the documentation on that please?
- Ralith 8y agoYou just pass it in explicitly: https://nixos.org/nixpkgs/manual/#sec-pkg-override https://nixos.org/nixpkgs/manual/#sec-pkg-override
- mbrock 8y agohttps://nixos.org/nixpkgs/manual/#sec-pkg-override https://nixos.org/nixpkgs/manual/#sec-pkg-override https://nixos.org/nixos/nix-pills/override-design-pattern.html https://nixos.org/nixos/nix-pills/override-design-pattern.ht... https://nixos.org/nixos/nix-pills/nixpkgs-overriding-packages.html https://nixos.org/nixos/nix-pills/nixpkgs-overriding-package... Those are the documentation pages I found right now... It's basically two steps: constructing the patched libpng derivation, and then overriding the libpng derivation in the specific program. The first step would be something like let myLibpng = pkgs.libpng.overrideAttrs (old: { patches = old.patches ++ [~/libpng.patch]; }); and the second step would be something like let myProgram = pkgs.program.override { libpng = myLibpng; }; and then you could include "myProgram" in your system package list. If you have an "overlay" set up in your system then you could also do this as part of that overlay.
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]