Algus
September 4, 2024, 1:30pm
1
Hi, as the title mentions it, I’m having some troubles to make a simple change for updating to a latest version of git-town.
The derivation definition is here:
{ lib, buildGoModule, fetchFromGitHub, installShellFiles, git, testers, git-town, makeWrapper }:
buildGoModule rec {
pname = "git-town";
version = "15.1.0";
src = fetchFromGitHub {
owner = "git-town";
repo = "git-town";
rev = "v${version}";
hash = "sha256-e4lOyYQHsVOmOYKQ+3B2EdneWL8NEzboTlRKtO8Wdjg=";
};
vendorHash = null;
nativeBuildInputs = [ installShellFiles makeWrapper ];
buildInputs = [ git ];
ldflags =
This file has been truncated. show original
And I can’t make it work with overrideAttrs
. I was able to do it with the following (in home-manager):
nixpkgs.overlays = [
(self: super: {
git-town = super.git-town.overrideDerivation (oldAttrs: {
src = super.fetchFromGitHub {
owner = "git-town";
repo = "git-town";
rev = "v16.0.0";
hash =
"sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
};
});
})
];
The problem is that I see a warning in using overrideDerivation
. I’m suspecting that the problem with overrideAttrs
is because of the buildGoModule
but I can’t figure out. Any easy way to just change version
and sha
under:
buildGoModule rec {
version = "15.1.0";
src = fetchFromGitHub {
hash = "sha256-e4lOyYQHsVOmOYKQ+3B2EdneWL8NEzboTlRKtO8Wdjg=";
};
}
eljamm
September 4, 2024, 1:39pm
2
You probably have to add version
as well since it’s used in the derivation. This works for me:
nixpkgs.overlays = [
(final: prev: {
git-town = prev.git-town.overrideAttrs (
finalAttrs: oldAttrs: {
version = "16.0.0";
src = final.fetchFromGitHub {
owner = "git-town";
repo = "git-town";
rev = "v${finalAttrs.version}";
hash = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
};
}
);
})
];
Algus
September 4, 2024, 1:55pm
3
Ohh, wow, thanks, this indeeds works. So there isn’t a way to just update version
and src.hash
?
I was trying to check if there was any way to merge the oldAttrs.src
like:
(final: prev: {
git-town = prev.git-town.overrideAttrs (oldAttrs: {
version = "16.0.0";
src = oldAttrs.src // {
sha256 = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
};
});
})
But I was getting the same previous version
eljamm
September 4, 2024, 2:04pm
4
This seems to be working:
nixpkgs.overlays = [
(final: prev: {
git-town = prev.git-town.overrideAttrs (oldAttrs: {
version = "16.0.0";
src = oldAttrs.src // {
outputHash = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
};
});
})
];
But I personally don’t know what the consequences are of just overriding the hash.
Algus
September 5, 2024, 12:32am
5
Actually, that “doesn’t mark an error”, but the final version is the previous 15.1.0:
$git-town --version
Git Town 15.1.0
My guess is that maybe oldAttrs.src.rev
is using oldAttrs.version
instead of finalAttrs
like in the previous one you shared.
Thanks!
1 Like