4 ms·
Another approach is not to patch nixpkgs at all, but just to "override" packages in Nixpkgs outside of the repository, and build them from your own project dire
by gmfawcett 8y ago
Another approach is not to patch nixpkgs at all, but just to "override" packages in Nixpkgs outside of the repository, and build them from your own project directories.
A simple example: I wanted to build FFMPEG, but with non-free libraries enabled (which is not the default). Rather than edit "ffmpeg-full" in the nixpkgs repo, I just overrode it:
# default.nix (in some project directory; call "nix build -f ." to run it)
with nixpkgs;
{
my-ffmpeg =
let overrides = {
nonfreeLicensing = true;
fdkaacExtlib = true;
ffplayProgram = false;
qtFaststartProgram = false;
};
attrs = {
name="my-ffmpeg-" + ffmpeg.version;
};
in
ffmpeg-full.override overrides // attrs;
}
- kreetx 8y agoYou are ahead of me! Thank you for the example :)
- gmfawcett 8y agoYou're welcome! One last tip... If you build this way, it will write everything to /nix/store, but it won't install it into your local profile. However, the 'nix-build' process creates a 'result' symlink in your project directory which points at the package you just built. So Calling 'nix-env -i ./result' ought to install it into your profile as well.
- Nullabillity 8y agoYou can also just call `nix-env -i .` to build and install in one go.
- gmfawcett 8y agoAh! thanks for that.
- Stammon 8y agoYou can also use an overlay
- gmfawcett 8y agoThanks, I've heard the term 'overlay' but I haven't learned quite that much yet. I'll look into this.
- lilyball 8y agoI haven't ever tried this myself, but I was under the impression that the `--arg` and `--argstr` arguments to nix-env were supposed to let you change build options. So could you not say `nix-env -iA nixpkgs.ffmpeg-full --arg nonfreeLicensing true --arg fdkaacExtlib true --arg ffplayProgram false --arg qtFaststartProgram false`?
- gmfawcett 8y agoYou may well be right. In my first attempts, I did try various combinations of `--arg` and `--argstr`, but I never succeeded in getting a proper build. That's why I ended up using the override approach instead. I understand a little bit more (very little!) about Nix now, so perhaps I should give it another try.