about summary refs log tree commit diff
path: root/pkgs/by-name/ku/kubo
diff options
context:
space:
mode:
authorLuflosi <luflosi@luflosi.de>2023-12-14 23:14:34 +0100
committerLuflosi <luflosi@luflosi.de>2023-12-14 23:21:43 +0100
commit05b4972db0bf91462b1e01b0c1ad234ff29c37d7 (patch)
tree9a256f2e7f5abb54237c6ec3d38a2841c23f38ba /pkgs/by-name/ku/kubo
parent60781d9b2d23f1ca8c18d7d0582e5a2a54d32932 (diff)
downloadnixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar.gz
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar.bz2
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar.lz
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar.xz
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.tar.zst
nixlib-05b4972db0bf91462b1e01b0c1ad234ff29c37d7.zip
kubo: migrate to by-name
Diffstat (limited to 'pkgs/by-name/ku/kubo')
-rw-r--r--pkgs/by-name/ku/kubo/package.nix67
-rw-r--r--pkgs/by-name/ku/kubo/test-repoVersion.nix13
2 files changed, 80 insertions, 0 deletions
diff --git a/pkgs/by-name/ku/kubo/package.nix b/pkgs/by-name/ku/kubo/package.nix
new file mode 100644
index 000000000000..117fbc850d06
--- /dev/null
+++ b/pkgs/by-name/ku/kubo/package.nix
@@ -0,0 +1,67 @@
+{ lib
+, buildGoModule
+, fetchurl
+, nixosTests
+, callPackage
+}:
+
+buildGoModule rec {
+  pname = "kubo";
+  version = "0.24.0"; # When updating, also check if the repo version changed and adjust repoVersion below
+  rev = "v${version}";
+
+  passthru.repoVersion = "15"; # Also update kubo-migrator when changing the repo version
+
+  # Kubo makes changes to its source tarball that don't match the git source.
+  src = fetchurl {
+    url = "https://github.com/ipfs/kubo/releases/download/${rev}/kubo-source.tar.gz";
+    hash = "sha256-stSjLvg8G1EiXon3Qby4wLgbhX7Aaj9pnxcvE32/42k=";
+  };
+
+  # tarball contains multiple files/directories
+  postUnpack = ''
+    mkdir kubo-src
+    shopt -s extglob
+    mv !(kubo-src) kubo-src || true
+    cd kubo-src
+  '';
+
+  sourceRoot = ".";
+
+  subPackages = [ "cmd/ipfs" ];
+
+  passthru.tests = {
+    inherit (nixosTests) kubo;
+    repoVersion = callPackage ./test-repoVersion.nix {};
+  };
+
+  vendorHash = null;
+
+  outputs = [ "out" "systemd_unit" "systemd_unit_hardened" ];
+
+  postPatch = ''
+    substituteInPlace 'misc/systemd/ipfs.service' \
+      --replace '/usr/local/bin/ipfs' "$out/bin/ipfs"
+    substituteInPlace 'misc/systemd/ipfs-hardened.service' \
+      --replace '/usr/local/bin/ipfs' "$out/bin/ipfs"
+  '';
+
+  postInstall = ''
+    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"
+  '';
+
+  meta = with lib; {
+    description = "An IPFS implementation in Go";
+    homepage = "https://ipfs.io/";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    mainProgram = "ipfs";
+    maintainers = with maintainers; [ Luflosi fpletz ];
+  };
+}
diff --git a/pkgs/by-name/ku/kubo/test-repoVersion.nix b/pkgs/by-name/ku/kubo/test-repoVersion.nix
new file mode 100644
index 000000000000..25fd8fcfbf43
--- /dev/null
+++ b/pkgs/by-name/ku/kubo/test-repoVersion.nix
@@ -0,0 +1,13 @@
+{ runCommand, kubo }:
+
+runCommand "kubo-test-repoVersion" { } ''
+  export IPFS_PATH="$TMPDIR"
+  "${kubo}/bin/ipfs" init --empty-repo
+  declared_repo_version='${kubo.repoVersion}'
+  actual_repo_version="$(cat "$IPFS_PATH/version")"
+  if [ "$declared_repo_version" != "$actual_repo_version" ]; then
+    echo "kubo.repoVersion is not set correctly. It should be $actual_repo_version but is $declared_repo_version."
+    exit 1
+  fi
+  touch "$out"
+''