This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/ipfs/kubo/default.nix
Charlotte 🦝 Delenk 901489102b
All checks were successful
Hydra papermc Hydra build #48037 of nix-packages:x86_64-linux-master-pr259:papermc
Hydra mautrix-discord Hydra build #48041 of nix-packages:x86_64-linux-master-pr259:mautrix-discord
Hydra mautrix-whatsapp Hydra build #48033 of nix-packages:aarch64-linux-master-pr259:mautrix-whatsapp
Hydra woodpecker-agent Hydra build #48031 of nix-packages:aarch64-linux-master-pr259:woodpecker-agent
Hydra woodpecker-frontend Hydra build #48032 of nix-packages:aarch64-linux-master-pr259:woodpecker-frontend
Hydra element-web Hydra build #48034 of nix-packages:aarch64-linux-master-pr259:element-web
Hydra woodpecker-cli Hydra build #48035 of nix-packages:aarch64-linux-master-pr259:woodpecker-cli
Hydra woodpecker-server Hydra build #48030 of nix-packages:aarch64-linux-master-pr259:woodpecker-server
update
2023-06-08 20:02:25 +01:00

71 lines
2.5 KiB
Nix

{
buildGoApplication,
fetchFromGitHub,
gnumake,
stdenv,
openssl,
pkg-config,
writeScript,
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
src = stdenv.mkDerivation {
pname = "kubo-source";
version = source.date;
src = fetchFromGitHub {
owner = "ipfs";
repo = "kubo";
inherit (source) rev sha256;
};
buildPhase = "";
installPhase = ''
cp -r $src $out
chmod -R +w $out
cd $out
cp ${./go.mod} go.mod
cp ${./go.sum} go.sum
echo -e "\nstorjds storj.io/ipfs-go-ds-storj/plugin 0" >> plugin/loader/preload_list
patchShebangs .
'';
};
in
buildGoApplication rec {
pname = "kubo";
version = source.date;
inherit src;
modules = ./gomod2nix.toml;
buildInputs = [openssl];
nativeBuildInputs = [gnumake pkg-config];
subPackages = ["cmd/ipfs"];
tags = ["openssl"];
postPatch = ''
substituteInPlace 'misc/systemd/ipfs.service' \
--replace '/usr/bin/ipfs' "$out/bin/ipfs"
substituteInPlace 'misc/systemd/ipfs-hardened.service' \
--replace '/usr/bin/ipfs' "$out/bin/ipfs"
'';
outputs = ["out" "systemd_unit" "systemd_unit_hardened"];
buildPhase = ''
make build
'';
installPhase = ''
GOBIN=$out/bin make install
install --mode=444 -D 'misc/systemd/ipfs-api.socket' "$systemd_unit/etc/systemd/system/ipfs-api.socket"
install --mode=444 -D 'misc/systemd/ipfs-gateway.socket' "$systemd_unit/etc/systemd/system/ipfs-gateway.socket"
install --mode=444 -D 'misc/systemd/ipfs.service' "$systemd_unit/etc/systemd/system/ipfs.service"
install --mode=444 -D 'misc/systemd/ipfs-api.socket' "$systemd_unit_hardened/etc/systemd/system/ipfs-api.socket"
install --mode=444 -D 'misc/systemd/ipfs-gateway.socket' "$systemd_unit_hardened/etc/systemd/system/ipfs-gateway.socket"
install --mode=444 -D 'misc/systemd/ipfs-hardened.service' "$systemd_unit_hardened/etc/systemd/system/ipfs.service"
'';
passthru.updateScript' = writeScript "update-matrix-media-repo" ''
${../../scripts/update-git.sh} "https://github.com/ipfs/kubo" ipfs/kubo/source.json
if [ "$(git diff -- ipfs/kubo/source.json)" ]; then
SRC_PATH=$(nix-build -E '(import ./. {}).${pname}.src')
${../../scripts/add-go-module.sh} $SRC_PATH ipfs/kubo "storj.io/ipfs-go-ds-storj/plugin@latest"
fi
'';
passthru.repoVersion = "13"; # Also update kubo-migrator when changing the repo version
}