diff options
-rw-r--r-- | pkgs/applications/networking/sync/celeste/default.nix | 114 | ||||
-rw-r--r-- | pkgs/applications/networking/sync/celeste/librclone-path.patch | 31 | ||||
-rw-r--r-- | pkgs/applications/networking/sync/celeste/target-dir.patch | 16 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
4 files changed, 163 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 ]; + }; +} diff --git a/pkgs/applications/networking/sync/celeste/librclone-path.patch b/pkgs/applications/networking/sync/celeste/librclone-path.patch new file mode 100644 index 00000000000..21af74dfde5 --- /dev/null +++ b/pkgs/applications/networking/sync/celeste/librclone-path.patch @@ -0,0 +1,31 @@ +diff --git a/librclone-sys/build.rs b/librclone-sys/build.rs +index 10e45bc..7d04c08 100644 +--- a/librclone-sys/build.rs ++++ b/librclone-sys/build.rs +@@ -16,15 +16,8 @@ fn main() { + println!("cargo:rerun-if-changed=go.mod"); + println!("cargo:rerun-if-changed=go.sum"); + +- Command::new("go") +- .args(["build", "--buildmode=c-archive", "-o"]) +- .arg(&format!("{}/librclone.a", out_dir)) +- .arg("github.com/rclone/rclone/librclone") +- .status() +- .expect("`go build` failed. Is `go` installed and latest version?"); +- +- println!("cargo:rustc-link-search=native={}", out_dir); +- println!("cargo:rustc-link-lib=static=rclone"); ++ println!("cargo:rustc-link-search=native={}", "@librclone@/lib"); ++ println!("cargo:rustc-link-lib=dylib=rclone"); + + if target_triple.ends_with("darwin") { + println!("cargo:rustc-link-lib=framework=CoreFoundation"); +@@ -32,7 +25,7 @@ fn main() { + } + + let bindings = bindgen::Builder::default() +- .header(format!("{}/librclone.h", out_dir)) ++ .header(format!("{}/librclone.h", "@librclone@/include")) + .allowlist_function("RcloneRPC") + .allowlist_function("RcloneInitialize") + .allowlist_function("RcloneFinalize") diff --git a/pkgs/applications/networking/sync/celeste/target-dir.patch b/pkgs/applications/networking/sync/celeste/target-dir.patch new file mode 100644 index 00000000000..a8da72e77f7 --- /dev/null +++ b/pkgs/applications/networking/sync/celeste/target-dir.patch @@ -0,0 +1,16 @@ +diff --git a/celeste/src/launch.rs b/celeste/src/launch.rs +index 5227170..e3cf189 100644 +--- a/celeste/src/launch.rs ++++ b/celeste/src/launch.rs +@@ -172,10 +172,7 @@ impl TrayApp { + perms.set_mode(0o755); + file.set_permissions(perms).unwrap(); + +- #[cfg(debug_assertions)] +- let tray_file = include_bytes!("../../target/debug/celeste-tray"); +- #[cfg(not(debug_assertions))] +- let tray_file = include_bytes!("../../target/release/celeste-tray"); ++ let tray_file = include_bytes!(concat!("../../target/@rustTarget@/", env!("cargoBuildType"), "/celeste-tray")); + + file.write_all(tray_file).unwrap(); + drop(file); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 82085373e9a..ac5d63845a5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28895,6 +28895,8 @@ with pkgs; inherit (darwin.apple_sdk.frameworks) Carbon; }; + celeste = callPackage ../applications/networking/sync/celeste { }; + cyan = callPackage ../applications/graphics/cyan {}; cyanrip = callPackage ../applications/audio/cyanrip { }; |