| 5 Jan 2024 |
@qbit:tapenet.org | what i am describing does the "pre-fetch" so to speak | 15:16:42 |
Vladislav Vasilev | Here is a strange package btw | 15:16:42 |
@qbit:tapenet.org | how so? | 15:17:04 |
Vladislav Vasilev | For example, first trouble that I got was hard coded go version | 15:17:47 |
Vladislav Vasilev | So, buildGo120Module using 1.20.12 version, but package requiring from Makefile exactly 1.20 version | 15:18:17 |
@qbit:tapenet.org | you shouldn't need to use the makefile | 15:18:37 |
@qbit:tapenet.org | link to the repo in question? | 15:18:50 |
Vladislav Vasilev | Probably, you can quickly help me, because I spent a lot of time with that
I have this default.nix config:
{ stdenv
, pkgs
, lib
}: pkgs.buildGoModule rec {
name = "neutrond";
version = "v2.0.0";
src = (fetchTarball {
url = "https://github.com/neutron-org/neutron/archive/refs/tags/v2.0.0.tar.gz";
sha256 = "sha256:04na3ympacdqhk8wbfcq2hk5i2d905ac4fzhgzvf4192nyb0xsin";
});
vendorHash = "sha256-uLInKbuL886cfXCyQvIDZJHUC8AK9fR39yNBHDO+Qzc=";
# vendorHash = lib.fakeSha256;
doCheck = false;
meta = with lib; {
description = "Neutron node";
longDescription = ''
Neutron node to interact with neutron blockchain
'';
homepage = "https://github.com/neutron-org/neutron";
license = licenses.asl20; # Apache license
maintainers = with maintainers; [
pr0n00gler
foxpy
];
platforms = platforms.all;
};
nativeBuildInputs = with pkgs; [
patchelf
git
which
gnumake
];
installPhase = ''
mkdir -p $out/bin
go build -mod=readonly -o $out/bin/neutrond ./cmd/neutrond
'';
}
So, repo https://github.com/neutron-org/neutron/ have a go.mod, which have listed go modules to prefetch. All that stuff we need to build cmd/neutrond dir. But, inside of main.go here we have module that we should fetch again. So, I have troubles with that "post-fetch" during building
| 15:23:07 |
Vladislav Vasilev | * Probably, you can quickly help me, because I spent a lot of time with that
I have this default.nix config:
{ stdenv
, pkgs
, lib
}: pkgs.buildGoModule rec {
name = "neutrond";
version = "v2.0.0";
src = (fetchTarball {
url = "https://github.com/neutron-org/neutron/archive/refs/tags/v2.0.0.tar.gz";
sha256 = "sha256:04na3ympacdqhk8wbfcq2hk5i2d905ac4fzhgzvf4192nyb0xsin";
});
vendorHash = "sha256-uLInKbuL886cfXCyQvIDZJHUC8AK9fR39yNBHDO+Qzc=";
# vendorHash = lib.fakeSha256;
doCheck = false;
meta = with lib; {
description = "Neutron node";
longDescription = ''
Neutron node to interact with neutron blockchain
'';
homepage = "https://github.com/neutron-org/neutron";
license = licenses.asl20; # Apache license
maintainers = with maintainers; [
pr0n00gler
foxpy
];
platforms = platforms.all;
};
nativeBuildInputs = with pkgs; [
patchelf
git
which
gnumake
];
installPhase = ''
mkdir -p $out/bin
go build -mod=readonly -o $out/bin/neutrond ./cmd/neutrond
'';
}
So, repo https://github.com/neutron-org/neutron/ have a go.mod, which have listed go modules to prefetch. All that stuff we need to build cmd/neutrond dir. But, inside of main.go here we have module that forcing us to fetch other modules during build. So, I have troubles with that "post-fetch" during building
| 15:24:15 |
Vladislav Vasilev | Of course, if I need to skip post fetching and skip that needness of fetching additional packages, I should list all deps in go.mod, as I suppose | 15:26:07 |
Vladislav Vasilev | Smells like this repo need cleaning | 15:26:43 |
@qbit:tapenet.org | so your vendorHash means you are already getting the deps | 15:26:51 |
@qbit:tapenet.org | you shouldn't need to specify an installPhase | 15:27:02 |
Vladislav Vasilev | nativeBuildInputs, as I suppose, also | 15:27:27 |
Vladislav Vasilev | What is a vendor hash at all ? It's nix-hash for src + fetched content aka go modules ? | 15:28:15 |
@qbit:tapenet.org | vendorHash is the hash of all the dependent modules | 15:28:38 |
@qbit:tapenet.org | if you look in /nix/store you should see a *-neutrond-go-modules* | 15:29:03 |
@qbit:tapenet.org | at build that gets tied into the neutrond derivation as a vendor directory | 15:29:34 |
Vladislav Vasilev | Ye, I see this | 15:29:34 |
Vladislav Vasilev | So, its drv for deps | 15:29:50 |
@qbit:tapenet.org | your installPhase is probably blocking that from happening | 15:30:06 |
@qbit:tapenet.org | what happens when you remove your installPhase? | 15:30:13 |
Vladislav Vasilev | Now it fetching deps, I started it, one moment | 15:30:30 |
@qbit:tapenet.org | i'd probably switch to fetchFromGithub | 15:31:17 |
@qbit:tapenet.org | also version = shouldn't contain the v | 15:31:28 |
@qbit:tapenet.org | and you can use ${version} and other vars in the derivation in place of the hard-coded strings | 15:31:49 |
@qbit:tapenet.org | (you are using rec for that) | 15:31:54 |
Vladislav Vasilev | In reply to @qbit:tapenet.org i'd probably switch to fetchFromGithub It's like a good manner ? | 15:32:02 |
@qbit:tapenet.org | it's more common that fetch tarball - and i have seen tarballs change out (they are cached and get re-gen'd) | 15:32:43 |
Vladislav Vasilev | Okay, one moment | 15:33:09 |