powerful but friendly backup program that runs in your tray, powered by restic
devins.page/restray
go
restic
system-tray
1{
2 description = "Powerful but friendly backup program, powered by restic, that runs in your tray";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6 flake-utils.url = "github:numtide/flake-utils";
7 };
8
9 outputs = {
10 self,
11 nixpkgs,
12 flake-utils,
13 }: let
14 nixosModules.default = import ./nix/nixos-module.nix self;
15 homeManagerModules.default = import ./nix/hm-module.nix self;
16 in
17 {
18 inherit nixosModules homeManagerModules;
19 }
20 // flake-utils.lib.eachDefaultSystem (system: let
21 pkgs = nixpkgs.legacyPackages.${system};
22 isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
23 in {
24 packages.default = pkgs.buildGoModule {
25 pname = "restray";
26 version = "0.23.0";
27 src = ./.;
28 vendorHash = "sha256-SeXluece3RKPrmbv90E3H4Trj6loS3Y3IYLJexBeFBU=";
29 subPackages = ["cmd/restray"];
30
31 ldflags = ["-s" "-w" "-X" "main.resticBuiltinPath=${pkgs.restic}/bin/restic" "-X" "main.rusticBuiltinPath=${pkgs.rustic}/bin/rustic"];
32
33 env = pkgs.lib.optionalAttrs isDarwin {
34 CGO_CFLAGS = "-mmacosx-version-min=12.0";
35 CGO_LDFLAGS = "-mmacosx-version-min=12.0";
36 MACOSX_DEPLOYMENT_TARGET = "12.0";
37 };
38
39 nativeBuildInputs = [pkgs.installShellFiles];
40
41 postInstall = ''
42 ${
43 if isDarwin
44 then ''
45 mkdir -p $out/Applications/Restray.app/Contents/{MacOS,Resources}
46 mv $out/bin/restray $out/Applications/Restray.app/Contents/MacOS/Restray
47 cp packaging/darwin/Info.plist $out/Applications/Restray.app/Contents/Info.plist
48 cp packaging/darwin/restray.icns $out/Applications/Restray.app/Contents/Resources/restray.icns
49 mkdir -p $out/bin
50 ln -s $out/Applications/Restray.app/Contents/MacOS/Restray $out/bin/restray
51 ''
52 else ''
53 install -Dm644 packaging/linux/restray.desktop $out/share/applications/restray.desktop
54 install -Dm644 packaging/linux/restray.png $out/share/icons/hicolor/1024x1024/apps/restray.png
55 substituteInPlace $out/share/applications/restray.desktop \
56 --replace-fail "Exec=restray" "Exec=$out/bin/restray"
57 install -Dm644 packaging/linux/restray-user.service $out/lib/systemd/user/restray.service
58 substituteInPlace $out/lib/systemd/user/restray.service \
59 --replace-fail "ExecStart=restray daemon" "ExecStart=$out/bin/restray daemon"
60 install -Dm644 packaging/linux/restray.service $out/lib/systemd/system/restray.service
61 substituteInPlace $out/lib/systemd/system/restray.service \
62 --replace-fail "ExecStart=restray --config /etc/restray --state /var/lib/restray daemon" "ExecStart=$out/bin/restray --config /etc/restray --state /var/lib/restray daemon"
63 ''
64 }
65 installShellCompletion --cmd restray \
66 --bash <($out/bin/restray completion bash) \
67 --zsh <($out/bin/restray completion zsh) \
68 --fish <($out/bin/restray completion fish)
69 '';
70
71 meta = {
72 description = "A powerful but friendly backup program powered by restic";
73 license = pkgs.lib.licenses.gpl3Only;
74 platforms = pkgs.lib.platforms.linux ++ pkgs.lib.platforms.darwin;
75 mainProgram = "restray";
76 };
77 };
78
79 devShells.default = pkgs.mkShell {
80 packages = with pkgs; [
81 go
82 gotools # goimports
83 go-tools # staticcheck
84
85 gcc
86 zig
87
88 # only needed for packaging and icon gen
89 just
90 nsis
91 perl
92 libicns
93 imagemagick
94 oxipng
95 ];
96 };
97 });
98}