summary refs log tree commit diff
path: root/pkgs/applications/networking/sync/celeste/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/sync/celeste/default.nix')
-rw-r--r--pkgs/applications/networking/sync/celeste/default.nix114
1 files changed, 114 insertions, 0 deletions
diff --git a/pkgs/applications/networking/sync/celeste/default.nix b/pkgs/applications/networking/sync/celeste/default.nix
new file mode 100644
index 00000000000..701172cbd28
--- /dev/null
+++ b/pkgs/applications/networking/sync/celeste/default.nix
@@ -0,0 +1,114 @@
+{ lib
+, stdenv
+, rust
+, rustPlatform
+, fetchFromGitHub
+, substituteAll
+, fetchpatch
+, pkg-config
+, wrapGAppsHook4
+, cairo
+, gdk-pixbuf
+, glib
+, graphene
+, gtk3
+, gtk4
+, libadwaita
+, libappindicator-gtk3
+, librclone
+, pango
+, rclone
+}:
+
+let
+  # https://github.com/trevyn/librclone/pull/8
+  librclone-mismatched-types-patch = fetchpatch {
+    name = "use-c_char-to-be-platform-independent.patch";
+    url = "https://github.com/trevyn/librclone/commit/91fdf3fa5f5eea0dfd06981ba72e09034974fdad.patch";
+    hash = "sha256-8YDyUNP/ISP5jCliT6UCxZ89fdRFud+6u6P29XdPy58=";
+  };
+in rustPlatform.buildRustPackage rec {
+  pname = "celeste";
+  version = "0.4.6";
+
+  src = fetchFromGitHub {
+    owner = "hwittenborn";
+    repo = "celeste";
+    rev = "v${version}";
+    hash = "sha256-VEyQlycpqsGKqtV/QvqBfVHqQhl/H6HsWPRDBtQO3qM=";
+  };
+
+  cargoHash = "sha256-fqt0XklJJAXi2jO7eo0tIwRo2Y3oM56qYwoaelKY8iU=";
+
+  patches = [
+    (substituteAll {
+      src = ./target-dir.patch;
+      rustTarget = rust.toRustTarget stdenv.hostPlatform;
+    })
+  ];
+
+  postPatch = ''
+    pushd $cargoDepsCopy/librclone-sys
+    oldHash=$(sha256sum build.rs | cut -d " " -f 1)
+    patch -p2 < ${./librclone-path.patch}
+    substituteInPlace build.rs \
+      --subst-var-by librclone ${librclone}
+    substituteInPlace .cargo-checksum.json \
+      --replace $oldHash $(sha256sum build.rs | cut -d " " -f 1)
+    popd
+    pushd $cargoDepsCopy/librclone
+    oldHash=$(sha256sum src/lib.rs | cut -d " " -f 1)
+    patch -p1 < ${librclone-mismatched-types-patch}
+    substituteInPlace .cargo-checksum.json \
+      --replace $oldHash $(sha256sum src/lib.rs | cut -d " " -f 1)
+    popd
+  '';
+
+  # Cargo.lock is outdated
+  preConfigure = ''
+    cargo update --offline
+  '';
+
+  # We need to build celeste-tray first because celeste/src/launch.rs reads that file at build time.
+  # Upstream does the same: https://github.com/hwittenborn/celeste/blob/765dfa2/justfile#L1-L3
+  cargoBuildFlags = [ "--bin" "celeste-tray" ];
+  postConfigure = ''
+    cargoBuildHook
+    cargoBuildFlags=
+  '';
+
+  RUSTC_BOOTSTRAP = 1;
+
+  nativeBuildInputs = [
+    pkg-config
+    rustPlatform.bindgenHook
+    wrapGAppsHook4
+  ];
+
+  buildInputs = [
+    cairo
+    gdk-pixbuf
+    glib
+    graphene
+    gtk3
+    gtk4
+    libadwaita
+    librclone
+    pango
+  ];
+
+  preFixup = ''
+    gappsWrapperArgs+=(
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libappindicator-gtk3 ]}"
+      --prefix PATH : "${lib.makeBinPath [ rclone ]}"
+    )
+  '';
+
+  meta = {
+    changelog = "https://github.com/hwittenborn/celeste/blob/${src.rev}/CHANGELOG.md";
+    description = "GUI file synchronization client that can sync with any cloud provider";
+    homepage = "https://github.com/hwittenborn/celeste";
+    license = lib.licenses.gpl3Only;
+    maintainers = with lib.maintainers; [ dotlambda ];
+  };
+}