nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildNpmPackage,
4 fetchFromGitHub,
5 electron,
6 copyDesktopItems,
7 makeDesktopItem,
8 nix-update-script,
9 makeWrapper,
10 kopia,
11}:
12let
13 version = "0.22.3";
14 src = fetchFromGitHub {
15 owner = "kopia";
16 repo = "kopia";
17 tag = "v${version}";
18 hash = "sha256-5oNam99Mij78snSO6jiGPYzeD68sXEBKM2dGQtTUrww=";
19 };
20in
21buildNpmPackage {
22 pname = "kopia-ui";
23 inherit version src;
24
25 sourceRoot = "${src.name}/app";
26
27 npmDepsHash = "sha256-DRsPiIiikp0pCAo0np0E3TYT1L6HGKXAXwKuB1jX6lw=";
28 makeCacheWritable = true;
29
30 nativeBuildInputs = [
31 copyDesktopItems
32 makeWrapper
33 ];
34
35 env = {
36 ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
37 };
38
39 patches = [ ./fix-paths.patch ];
40
41 postPatch = ''
42 substituteInPlace public/utils.js --replace-fail KOPIA ${lib.getExe kopia}
43 '';
44
45 buildPhase = ''
46 runHook preBuild
47 cp -r ${electron.dist} electron-dist
48 chmod -R u+w ..
49 npm exec electron-builder -- \
50 --dir \
51 -c.electronDist=electron-dist \
52 -c.electronVersion=${electron.version} \
53 -c.extraMetadata.version=v${version}
54 runHook postBuild
55 '';
56
57 installPhase = ''
58 runHook preInstall
59 mkdir -p $out/share/kopia
60 cp -r ../dist/kopia-ui/*-unpacked/{locales,resources{,.pak}} $out/share/kopia
61 install -Dm644 $src/icons/kopia.svg $out/share/icons/hicolor/scalable/apps/kopia.svg
62 makeWrapper ${lib.getExe electron} $out/bin/kopia-ui \
63 --prefix PATH : ${lib.makeBinPath [ kopia ]} \
64 --add-flags $out/share/kopia/resources/app.asar \
65 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
66 --inherit-argv0
67 runHook postInstall
68 '';
69
70 desktopItems = [
71 (makeDesktopItem {
72 name = "kopia-ui";
73 type = "Application";
74 desktopName = "KopiaUI";
75 comment = "Fast and secure open source backup.";
76 icon = "kopia";
77 exec = "kopia-ui";
78 categories = [ "Utility" ];
79 })
80 ];
81
82 passthru.updateScript = nix-update-script { };
83
84 meta = {
85 description = "Cross-platform backup tool with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication";
86 mainProgram = "kopia-ui";
87 homepage = "https://kopia.io";
88 downloadPage = "https://github.com/kopia/kopia";
89 changelog = "https://github.com/kopia/kopia/releases/tag/v${version}";
90 license = lib.licenses.asl20;
91 maintainers = with lib.maintainers; [ blenderfreaky ];
92 platforms = lib.platforms.linux;
93 };
94}