1.2 Patch any nixpkgs package without forking it
Lesson 2 of 3 · 6:05
Up next in 5s…
About this lesson
You need one line changed in a program you did not write. The usual answer is to fork the repository, patch it, build it, and keep the fork alive forever. In Nix it takes about a minute in a REPL, and what you end up with is a handful of lines you can paste into a real project later. This demo patches GNU hello so that it greets somebody else, and then shows how to get the source code of any package in nixpkgs.
In this video
- Running a program straight out of nixpkgs without installing it, then changing what it prints
- The two REPL commands that build a package and drop you into a shell where the result is already on your
PATH overrideAttrs: changing parts of somebody else's recipe without copying the recipe- Rewriting a string in the source before it compiles, with a tool that fails loudly instead of silently doing nothing when your pattern is not there
nix developplus one phase name: unpacking the source of any package into a folder you can read, grep and poke at
After this lesson
Patching a dependency stops being a project and turns into a small edit you can try before you commit to it. You also know where the line runs between an experiment in the REPL and the version that belongs in a repository.