I think I’ve got the basics of overlays and overriding packages down, but I’m still running into a couple issues. I wanted to downgrade my version of sway due to a crash on master. I’m using sway from nixpkgs-wayland
’s overlay: nixpkgs.overlays = [ inputs.nixpkgs-wayland.overlay ];
and decide to apply overrideAttrs
to my sway package. This is inside my home-manager config, but AFAIK it shouldn’t be an issue.
wayland.windowManager.sway.package = pkgs.sway.overrideAttrs (previousAttrs: {
src = pkgs.fetchFromGitHub {
owner = "swaywm";
repo = "sway";
rev = "4a2210577c7c4f84a99ca03386b8910d2f419ab6";
sha256 = "sha256-CZ4BkQ5JfrpTu+nyFmZygYYd69182uSPH2Q2M5YSLY8=";
};
});
Unfortunately, nothing happens, and I always have the latest version of sway, not the revision I’ve tried to pin here.
I wondered if this might be occurring because I already have an overlay affecting that passage, so I tried placing it next to that overlay:
nixpkgs.overlays = [
inputs.nixpkgs-wayland.overlay
(self: super: {
sway = super.sway.overrideAttrs (previousAttrs: {
src = pkgs.fetchFromGitHub {
owner = "swaywm";
repo = "sway";
rev = "4a2210577c7c4f84a99ca03386b8910d2f419ab6";
sha256 = "sha256-CZ4BkQ5JfrpTu+nyFmZygYYd69182uSPH2Q2M5YSLY8=";
};
});
})
];
Again, no issues building this, but my overlay is completely ignored. I have no idea how overlays are prioritized, and I thought I might need to do something like [(inputs.nixpkgs-wayland.overlay.extend (self: super: ...))];
but that does throw an error: error: value is a function while a set was expected
. Makes sense: the manual says " the nixpkgs.overlays
option, if present, is passed to the system Nixpkgs directly as an argument" but the way extend
works is nixpkgs.extend overlay1.extend overlay2.extend ...
. I’m still not sure, however, how to make sure one overlay takes priority over another.
I wondered if there was some sort of upstream issue in the sway package causing the issue. I had previously had overrideAttrs
fail to do anything because src
was defined by variable interpolation, so my override of version
wasn’t applied to src
. I took a look at the derivation. and see that it has some finalAttrs
argument I’m unsure about, but after a bit of research and skimming https://github.com/NixOS/nixpkgs/pull/119942 I think this is actually the best practice which should make overrides easier. Good to know, but doesn’t help me diagnose my issue.
While reading through that issue, I also came across Make fetchFromGitHub & friends overridable by piegamesde · Pull Request #158968 · NixOS/nixpkgs · GitHub and wondered if I needed to apply two overrides, like so:
package = pkgs.sway.overrideAttrs (previousAttrs: {
src = previousAttrs.src.override {
rev = "4a2210577c7c4f84a99ca03386b8910d2f419ab6";
sha256 = "sha256-CZ4BkQ5JfrpTu+nyFmZygYYd69182uSPH2Q2M5YSLY8=";
};
This also gives me an error, saying error: attribute 'src' missing
from previousAttrs
. While this is kind of annoying, it feels like progress, because now I’ve run into something that should work and is giving me an error instead of silently failing. I’m pretty sure the way I’ve structured this code should work based on Make fetchFromGitHub & friends overridable by piegamesde · Pull Request #158968 · NixOS/nixpkgs · GitHub.
Would anyone mind letting me know if there are errors in my understanding (since this has also been a learning exercise) and also how I might be able to resolve my problem? To make it clear, the goal of this is just to easily go back to an old version of software (in this case for easy git bisect
ing), so I’m happy with any solution that lets me do that with the matryoshka of overlays, home-manager, etc. that’s been working well for me.