From fd57aa3657ef49b030de953d483c0ee60f26389f Mon Sep 17 00:00:00 2001 From: uku Date: Wed, 29 Jan 2025 16:08:06 +0100 Subject: [PATCH] feat(mottarone): add urbackup --- exprs/overlay.nix | 10 +++++++++ exprs/urbackup-client-install.patch | 31 ++++++++++++++++++++++++++++ systems/mottarone/default.nix | 4 ++++ systems/mottarone/urbackup.nix | 32 +++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 exprs/urbackup-client-install.patch create mode 100644 systems/mottarone/urbackup.nix diff --git a/exprs/overlay.nix b/exprs/overlay.nix index 566bb41..a45d2af 100644 --- a/exprs/overlay.nix +++ b/exprs/overlay.nix @@ -1,6 +1,16 @@ inputs: final: prev: { idea-ultimate-fixed = prev.callPackage ./idea-fixed.nix { }; + urbackup-client = prev.urbackup-client.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ prev.autoreconfHook ]; + + patches = old.patches or [ ] ++ [ ./urbackup-client-install.patch ]; + + configureFlags = old.configureFlags or [ ] ++ [ + "--localstatedir=/var/lib" + ]; + }); + vencord = prev.vencord.overrideAttrs (old: rec { version = "${old.version}+git.${inputs.vencord.shortRev}"; src = inputs.vencord; diff --git a/exprs/urbackup-client-install.patch b/exprs/urbackup-client-install.patch new file mode 100644 index 0000000..723b0f9 --- /dev/null +++ b/exprs/urbackup-client-install.patch @@ -0,0 +1,31 @@ +diff --git a/Makefile.am b/Makefile.am +index 7e661f60..73fb2827 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -161,7 +161,7 @@ if !WITH_ASSERTIONS + blockalign_CXXFLAGS +=-DNDEBUG + endif + +-install-exec-local: defaults_client init.d_client init.d_client_rh ++disable-install-exec-local: defaults_client init.d_client init.d_client_rh + if INSTALL_DEBIAN_INITD + $(INSTALL) -D "$(srcdir)/init.d_client" "$(sysconfdir)/init.d/urbackupclientbackend" + if ! test -e "$(sysconfdir)/default/urbackupclientbackend"; then $(INSTALL) -D "$(srcdir)/defaults_client" "$(sysconfdir)/default/urbackupclientbackend"; fi +@@ -205,7 +205,7 @@ install-data-local: urbackupclient/backup_scripts/list urbackupclient/backup_scr + client/version.txt client/data/urbackup_ecdsa409k1.pub client/data/updates_h.dat + endif + +- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/urbackup/" ++ echo WARNING: disabled running command "(MKDIR_P) \"$(DESTDIR)$(localstatedir)/urbackup/\"" + $(MKDIR_P) "$(DESTDIR)$(datadir)/urbackup/scripts" + $(MKDIR_P) "$(DESTDIR)$(sysconfdir)/urbackup" + +@@ -231,7 +231,7 @@ endif + for script in "$(DESTDIR)$(datadir)/urbackup/scripts/"*; do sed "s|SYSCONFDIR|$(sysconfdir)/urbackup|g" "$$script" > "$$script.r"; mv "$$script.r" "$$script"; done + chmod 700 "$(DESTDIR)$(datadir)/urbackup/scripts/"* + chmod 700 "$(DESTDIR)$(sysconfdir)/urbackup/"* +- $(INSTALL_DATA) "$(srcdir)/client/version.txt" "$(DESTDIR)$(localstatedir)/urbackup/version.txt" ++ echo WARNING: disabled running command "$(INSTALL_DATA) \"$(srcdir)/client/version.txt\" \"$(DESTDIR)$(localstatedir)/urbackup/version.txt\"" + $(INSTALL_DATA) "$(srcdir)/client/data/urbackup_ecdsa409k1.pub" "$(DESTDIR)$(datadir)/urbackup/" + $(INSTALL_DATA) "$(srcdir)/client/data/updates_h.dat" "$(DESTDIR)$(datadir)/urbackup/" + \ No newline at end of file diff --git a/systems/mottarone/default.nix b/systems/mottarone/default.nix index f970f23..7d50bc9 100644 --- a/systems/mottarone/default.nix +++ b/systems/mottarone/default.nix @@ -8,6 +8,10 @@ let inherit (pkgs.stdenv.hostPlatform) system; in { + imports = [ + ./urbackup.nix + ]; + environment.systemPackages = with pkgs; [ gtkterm remmina diff --git a/systems/mottarone/urbackup.nix b/systems/mottarone/urbackup.nix new file mode 100644 index 0000000..d49a2ec --- /dev/null +++ b/systems/mottarone/urbackup.nix @@ -0,0 +1,32 @@ +{ lib, pkgs, ... }: +{ + # requires overlay, see exprs/overlay.nix + environment.systemPackages = [ pkgs.urbackup-client ]; + + systemd.services."urbackup-client" = { + after = [ + "syslog.target" + "network.target" + ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${lib.getExe' pkgs.urbackup-client "urbackupclientbackend"} --config /etc/default/urbackupclient --no-consoletime"; + # these paths are hardcoded in the binary, see overlay + StateDirectory = "urbackup urbackup/data"; + WorkingDirectory = "/var/lib/urbackup"; + }; + }; + + networking.firewall = { + allowedTCPPorts = [ + # "Sending files during file backups (file server)" + 35621 + # "Commands and image backups" + 35623 + ]; + allowedUDPPorts = [ + # "UDP broadcasts for discovery" + 35622 + ]; + }; +}