From 3440c6ce07a0bc5ec1892cdc6be8475567a9e6db Mon Sep 17 00:00:00 2001 From: blenderfreaky Date: Mon, 31 Mar 2025 15:16:53 +0200 Subject: [PATCH] kopia-ui: init at 0.19.0 Co-authored-by: emaryn <197520219+emaryn@users.noreply.github.com> --- pkgs/by-name/ko/kopia-ui/fix-paths.patch | 42 +++++++++++ pkgs/by-name/ko/kopia-ui/package.nix | 94 ++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 pkgs/by-name/ko/kopia-ui/fix-paths.patch create mode 100644 pkgs/by-name/ko/kopia-ui/package.nix diff --git a/pkgs/by-name/ko/kopia-ui/fix-paths.patch b/pkgs/by-name/ko/kopia-ui/fix-paths.patch new file mode 100644 index 000000000000..22744100099e --- /dev/null +++ b/pkgs/by-name/ko/kopia-ui/fix-paths.patch @@ -0,0 +1,42 @@ +diff --git a/public/utils.js b/public/utils.js +index 3cd38b63..54152694 100644 +--- a/public/utils.js ++++ b/public/utils.js +@@ -17,7 +17,7 @@ const osShortName = function () { + + export function iconsPath() { + if (!app.isPackaged) { +- return path.join(__dirname, "..", "resources", osShortName, "icons"); ++ return path.join(__dirname, "..", "..", "icons"); + } + + return path.join(process.resourcesPath, "icons"); +@@ -25,26 +25,14 @@ export function iconsPath() { + + export function publicPath() { + if (!app.isPackaged) { +- return path.join(__dirname, "..", "public"); ++ return path.join(__dirname, "..", "..", "public"); + } + + return process.resourcesPath; + } + + export function defaultServerBinary() { +- if (!app.isPackaged) { +- return { +- "mac": path.join(__dirname, "..", "..", "dist", "kopia_darwin_amd64", "kopia"), +- "win": path.join(__dirname, "..", "..", "dist", "kopia_windows_amd64", "kopia.exe"), +- "linux": path.join(__dirname, "..", "..", "dist", "kopia_linux_amd64", "kopia"), +- }[osShortName] +- } +- +- return { +- "mac": path.join(process.resourcesPath, "server", "kopia"), +- "win": path.join(process.resourcesPath, "server", "kopia.exe"), +- "linux": path.join(process.resourcesPath, "server", "kopia"), +- }[osShortName] ++ return "KOPIA" + } + export function selectByOS(x) { + return x[osShortName] diff --git a/pkgs/by-name/ko/kopia-ui/package.nix b/pkgs/by-name/ko/kopia-ui/package.nix new file mode 100644 index 000000000000..0a74ec1bc8c5 --- /dev/null +++ b/pkgs/by-name/ko/kopia-ui/package.nix @@ -0,0 +1,94 @@ +{ + lib, + buildNpmPackage, + fetchFromGitHub, + electron, + copyDesktopItems, + makeDesktopItem, + nix-update-script, + makeWrapper, + kopia, +}: +let + version = "0.19.0"; + src = fetchFromGitHub { + owner = "kopia"; + repo = "kopia"; + tag = "v${version}"; + hash = "sha256-PfxMs9MwoI+4z8vZ1sVlIEal3TOmA06997jWwShNfrE="; + }; +in +buildNpmPackage { + pname = "kopia-ui"; + inherit version src; + + sourceRoot = "${src.name}/app"; + + npmDepsHash = "sha256-3K5dwAQeAo98rz2gxGw3k/D+VkDJNe5pmAyEo4boetU="; + makeCacheWritable = true; + + nativeBuildInputs = [ + copyDesktopItems + makeWrapper + ]; + + env = { + ELECTRON_SKIP_BINARY_DOWNLOAD = 1; + }; + + patches = [ ./fix-paths.patch ]; + + postPatch = '' + substituteInPlace public/utils.js --replace-fail KOPIA ${lib.getExe kopia} + ''; + + buildPhase = '' + runHook preBuild + cp -r ${electron.dist} electron-dist + chmod -R u+w .. + npm exec electron-builder -- \ + --dir \ + -c.electronDist=electron-dist \ + -c.electronVersion=${electron.version} \ + -c.extraMetadata.version=v${version} + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/kopia + cp -r ../dist/kopia-ui/*-unpacked/{locales,resources{,.pak}} $out/share/kopia + install -Dm644 $src/icons/kopia.svg $out/share/icons/hicolor/scalable/apps/kopia.svg + makeWrapper ${lib.getExe electron} $out/bin/kopia-ui \ + --prefix PATH : ${lib.makeBinPath [ kopia ]} \ + --add-flags $out/share/kopia/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ + --inherit-argv0 + runHook postInstall + ''; + + desktopItems = [ + (makeDesktopItem { + name = "kopia-ui"; + type = "Application"; + desktopName = "KopiaUI"; + comment = "Fast and secure open source backup."; + icon = "kopia-ui"; + exec = "kopia-ui"; + categories = [ "Utility" ]; + }) + ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Cross-platform backup tool with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication"; + mainProgram = "kopia-ui"; + homepage = "https://kopia.io"; + downloadPage = "https://github.com/kopia/kopia"; + changelog = "https://github.com/kopia/kopia/releases/tag/v${version}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ blenderfreaky ]; + platforms = lib.platforms.linux; + }; +}