diff --git a/modules/services/wifibackup/default.nix b/modules/services/wifibackup/default.nix index d2d62a0..d98ab41 100644 --- a/modules/services/wifibackup/default.nix +++ b/modules/services/wifibackup/default.nix @@ -3,29 +3,7 @@ config, pkgs, ... -}: let - mergeNmConnections = pkgs.writeShellApplication { - name = "merge-nmconnections"; - text = '' - CURRENT1="$1" - CURRENT2="$2" - NEW="$3" - NEW1="$4" - NEW2="$5" - - sed -i -E '/^(uuid|interface-name)=/d' "$CURRENT1" - sed -i -E '/^(uuid|interface-name)=/d' "$CURRENT2" - - if cmp "$1" "$2"; then - mv "$CURRENT1" "$NEW" - else - mv "$CURRENT1" "$NEW1" - mv "$CURRENT2" "$NEW2" - exit 1 - fi - ''; - }; -in { +}: { options.mj.services.wifibackup = with lib.types; { enable = lib.mkEnableOption "enable wifi code backups to M-Active"; fromPath = lib.mkOption { @@ -55,18 +33,19 @@ in { Type = "oneshot"; User = "root"; SuccessExitStatus = [0 1]; - ExecStart = '' - ${pkgs.unison}/bin/unison \ - -sshcmd ${pkgs.openssh}/bin/ssh \ - -sshargs "-i /etc/ssh/ssh_host_ed25519_key" \ - -batch \ - -merge "Name *.nmconnection -> ${mergeNmConnections}/bin/merge-nmconnections CURRENT1 CURRENT2 NEW NEW1 NEW2" \ - -backuploc local \ - -backup "Name *" \ - ${fromPath} \ - ssh://${toUser}@localhost/${toPath}/ - ''; }; + script = '' + sed -i -E '/^(uuid|interface-name)=/d' ${fromPath}/*.nmconnection + + exec ${pkgs.unison}/bin/unison \ + -sshcmd ${pkgs.openssh}/bin/ssh \ + -sshargs "-i /etc/ssh/ssh_host_ed25519_key -o KnownHostsCommand=\"${pkgs.coreutils}/bin/cat /etc/ssh/ssh_host_ed25519_key.pub\"" \ + -batch \ + -backuploc local \ + -backup "Name *" \ + ${fromPath} \ + ssh://${toUser}@localhost/${toPath}/ + ''; }; }; }