With nix and the home manager it is a lot different.
All programs and configurations can be written down in nix files to be reproducible and persistent.
I can use lf
in my home.nix
like that:
programs.lf = {
enable = true;
# further configuration (eg preview script)
};
But that will use the master branch at gokcehan/lf
and not the fork with sixel support.
That’s where overlays come into play!
I can create a file called overlay/lf.nix
which looks like that:
self: super:
{
lf = super.lf.overrideAttrs (oldAttrs: rec {
src = super.fetchFromGitHub {
owner = "horriblename";
repo = "lf";
rev = "1bb0b43feafba0d5dbc40d4cf71a4f22b547be00";
sha256 = "sha256-CoWF3virzel8TbW79xc6xXxh6K6r9mCeoaAUYcE7VHc=";
};
});
}
As you can see, it overrides attributes. But it really only overrides one attribute: The source that is fetched.
All other package attributes stay the same. I can still use further configuration options that are already parameterized like the preview script.
And then I can add this overlay to my list of overlays at my home.nix
:
let
#...
lf-overlay = import ./overlay/lf.nix; (1)
in
{
nixpkgs.overlays = [
#...
lf-overlay (2)
];
}
-
Line (1)
imports the overlay as a variable into the configuration.
-
Line (2)
adds the overlay to the list of active overlays. If this single line is removed, the overlay isn’t used anymore and I would be using the main branch again.
Now I’m using a fork of a program.
The fact, that I’m using that fork, is fully visible and transparent in the configuration files.
Everything else acts like it used to before I used the overlay.
And once the PR gets merged, I can simply remove the overlay and go with the main branch again.