From a52ccf7ef4cb5f8b7af2777155d6b8953bb1846c Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 22 Oct 2024 11:36:21 +0100 Subject: [PATCH] Remove git-sync service, use gsync.sh script again instead Delete some unused (test) scripts Reduce what is sync'd by rsync-local-config: remove fonts, bat config and zellij config --- system/home/emacs/default.nix | 26 ++----- system/home/password-store/default.nix | 4 -- system/home/scripts/lua/sync-all.lua | 38 ----------- system/home/scripts/python/sync-all.py | 68 ------------------- system/home/scripts/shell/low-battery.sh | 4 -- .../home/scripts/shell/rsync-local-config.sh | 12 +--- .../home/scripts/shell/xdg-query-program.sh | 4 +- system/home/shell/default.nix | 16 ++--- system/home/shell/git.nix | 2 +- system/home/shell/ssh.nix | 1 + 10 files changed, 16 insertions(+), 159 deletions(-) delete mode 100755 system/home/scripts/lua/sync-all.lua delete mode 100755 system/home/scripts/python/sync-all.py delete mode 100644 system/home/scripts/shell/low-battery.sh diff --git a/system/home/emacs/default.nix b/system/home/emacs/default.nix index 6db6346b..2b7358e2 100644 --- a/system/home/emacs/default.nix +++ b/system/home/emacs/default.nix @@ -6,25 +6,13 @@ ../gpg/default.nix ]; stylix.targets.emacs.enable = false; - services = { - git-sync.repositories = { - org = { - path = "${config.xdg.userDirs.documents}/org"; - uri = "git+https://git.xenia.me.uk/pixelifytica/org.git"; - }; - library = { - path = "${config.xdg.userDirs.documents}/library"; - uri = "git+https://git.xenia.me.uk/pixelifytica/library.git"; - }; - }; - emacs = { - enable = true; - package = config.programs.emacs.finalPackage; - defaultEditor = true; - client.enable = true; - socketActivation.enable = true; - startWithUserSession = false; - }; + services.emacs = { + enable = true; + package = config.programs.emacs.finalPackage; + defaultEditor = true; + client.enable = true; + socketActivation.enable = true; + startWithUserSession = false; }; programs.emacs = { # Clone emacs config from https://git.xenia.me.uk/pixelifytica/emacs.git diff --git a/system/home/password-store/default.nix b/system/home/password-store/default.nix index 2a250fbe..b98a591d 100644 --- a/system/home/password-store/default.nix +++ b/system/home/password-store/default.nix @@ -4,10 +4,6 @@ ../gpg/default.nix ../shell/git.nix ]; - services.git-sync.repositories.password-store = { - path = config.programs.password-store.settings.PASSWORD_STORE_DIR; - uri = "git+https://git.xenia.me.uk/pixelifytica/pass.git"; - }; programs = { gpg.enable = true; password-store = { diff --git a/system/home/scripts/lua/sync-all.lua b/system/home/scripts/lua/sync-all.lua deleted file mode 100755 index 36eda130..00000000 --- a/system/home/scripts/lua/sync-all.lua +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env nix-shell ---[[ -#!nix-shell -i lua -p git git-sync -]] -local config_home -if os.getenv("XDG_CONFIG_HOME") then - config_home = os.getenv("XDG_CONFIG_HOME") -else - config_home = "~/.config/" -end - -local sync_mapping = { - ["~/.password-store"] = "https://git.xenia.me.uk/pixelifytica/pass.git", - ["~/.elfeed"] = "https://git.xenia.me.uk/pixelifytica/elfeed.git", - ["~/Documents/Org"] = "https://git.xenia.me.uk/pixelifytica/org.git", - ["~/Documents/References"] = "https://git.xenia.me.uk/pixelifytica/references.git", -} - -local pull_mapping = { - ["/etc/nixos"] = "https://git.xenia.me.uk/pixelifytica/nixos.git", - [config_home .. "/emacs"] = "https://git.xenia.me.uk/pixelifytica/emacs.git", -} - -local function git_sync(directory, url) - print("--- sync: " .. directory .. " ---") -end - -local function git_pull(directory, url, ff_only) - print("--- pull: " .. directory .. " ---") -end - -for directory, url in pairs(sync_mapping) do - git_sync(directory, url) -end - -for directory, url in pairs(pull_mapping) do - git_pull(directory, url, true) -end diff --git a/system/home/scripts/python/sync-all.py b/system/home/scripts/python/sync-all.py deleted file mode 100755 index 4171ea67..00000000 --- a/system/home/scripts/python/sync-all.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i python3 -p git git-sync - -import os -import queue -import subprocess -from pathlib import Path -from typing import Dict - -HOME = Path("~").expanduser().resolve() - -SYNC_MAPPING: Dict[Path, str] = { - Path( - "~/.password-store" - ).expanduser(): "https://git.xenia.me.uk/pixelifytica/pass.git", - Path("~/.elfeed").expanduser(): "https://git.xenia.me.uk/pixelifytica/elfeed.git", - Path( - "~/Documents/Org" - ).expanduser(): "https://git.xenia.me.uk/pixelifytica/org.git", - Path( - "~/Documents/References" - ).expanduser(): "https://git.xenia.me.uk/pixelifytica/references.git", -} - -PULL_MAPPINGS: Dict[Path, str] = { - Path("/etc/nixos"): "https://git.xenia.me.uk/pixelifytica/nixos.git", - Path(os.getenv("XDG_CONFIG_HOME", "~/.config")).expanduser() - / "emacs": "https://git.xenia.me.uk/pixelifytica/emacs.git", -} - - -def git_set_url(directory: Path, url: str) -> None: - """Set url for directory""" - comp = subprocess.run(f"git remote set-url origin {url}".split(), cwd=directory) - if comp.returncode != 0: - raise UserWarning(f"{comp.returncode} from {' '.join(comp.args)}") - subprocess.run("git remote -v".split(), cwd=directory) - - -def git_sync(directory: Path, url: str) -> subprocess.CompletedProcess: - """Sync status of repository""" - print(f"--- sync: ${directory} ---") - if not directory.exists(): - return subprocess.run("exit 1".split()) # TODO - git_set_url(directory, url) - return subprocess.run("git-sync -ns".split(), cwd=directory) - - -def git_pull( - directory: Path, url: str, ff_only: bool = True -) -> subprocess.CompletedProcess: - """Pull updates for directory from url""" - print(f"--- pull: {directory} ---") - if not directory.exists(): - return subprocess.run("exit 1".split()) # TODO - git_set_url(directory, url) - return subprocess.run("git pull --ff-only".split(), cwd=directory) - - -def main(*args, **kwargs) -> None: - for directory, url in SYNC_MAPPING.items(): - print(git_sync(directory, url)) - for directory, url in PULL_MAPPINGS.items(): - print(git_pull(directory, url)) - - -if __name__ == "__main__": - main() diff --git a/system/home/scripts/shell/low-battery.sh b/system/home/scripts/shell/low-battery.sh deleted file mode 100644 index 08bf3039..00000000 --- a/system/home/scripts/shell/low-battery.sh +++ /dev/null @@ -1,4 +0,0 @@ -battery_level=$(acpi -b | grep -P -o '[0-9]+(?=%)') -if [ "$battery_level" -le 20 ]; then - notify-send -u critical "Battery low" "Battery level is ${battery_level}%!" -fi diff --git a/system/home/scripts/shell/rsync-local-config.sh b/system/home/scripts/shell/rsync-local-config.sh index f5c8823a..b00bef8d 100755 --- a/system/home/scripts/shell/rsync-local-config.sh +++ b/system/home/scripts/shell/rsync-local-config.sh @@ -1,6 +1,6 @@ HOSTS=("$@") # Config files -for TARGET in ".inputrc" ".config/bat/" ".config/zellij" ".config/starship.toml"; do +for TARGET in ".inputrc" ".config/starship.toml"; do SOURCE="$HOME/$TARGET" echo "--- $SOURCE ---" TMP_TARGET=/tmp/rsync-local-config @@ -21,13 +21,3 @@ for TARGET in ".inputrc" ".config/bat/" ".config/zellij" ".config/starship.toml" rm -rf $TMP_SOURCE fi done - -# Fonts -IOSEVKA_FLAKE_URL="git+https://git.xenia.me.uk/pixelifytica/iosevka.git?ref=main" -IOSEVKA_CUSTOM_NERDFONT=$(nix path-info "$IOSEVKA_FLAKE_URL#packages.x86_64-linux.iosevka-custom-nerdfont") -IOSEVKA_CUSTOM_AILE=$(nix path-info "$IOSEVKA_FLAKE_URL#packages.x86_64-linux.iosevka-custom-aile") -echo "--- Fonts ---" -for HOST in "${HOSTS[@]}"; do - rsync -avzL --delete --exclude=".git*" --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r "$IOSEVKA_CUSTOM_NERDFONT/share/fonts/truetype/" "$HOST:.fonts/IosevkaCustomNerdFont" - rsync -avzL --delete --exclude=".git*" --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r "$IOSEVKA_CUSTOM_AILE/share/fonts/truetype/" "$HOST:.fonts/IosevkaCustomAile" -done diff --git a/system/home/scripts/shell/xdg-query-program.sh b/system/home/scripts/shell/xdg-query-program.sh index 54c696ca..cced3d36 100755 --- a/system/home/scripts/shell/xdg-query-program.sh +++ b/system/home/scripts/shell/xdg-query-program.sh @@ -1,3 +1,3 @@ -FILETYPE=$(xdg-mime query filetype $@) -DEFAULT=$(xdg-mime query default $FILETYPE) +FILETYPE=$(xdg-mime query filetype "$@") +DEFAULT=$(xdg-mime query default "$FILETYPE") echo "$FILETYPE -> $DEFAULT" diff --git a/system/home/shell/default.nix b/system/home/shell/default.nix index 0340c059..08797a67 100644 --- a/system/home/shell/default.nix +++ b/system/home/shell/default.nix @@ -10,18 +10,10 @@ ./ssh.nix ./starship.nix ]; - home = { - packages = with pkgs; [ - rclone - git-sync - du-dust - ]; - shellAliases = { - update = "sudo nixos-rebuild switch"; - sync-all = "gsync; esync; vdirsyncer sync; mbsync -a"; - protonup = "sudo wg-quick up protonvpn && sudo wg"; - protondown = "sudo wg-quick down protonvpn"; - }; + home.shellAliases = { + sync-all = "gsync; esync; vdirsyncer sync; mbsync -a"; + protonup = "sudo wg-quick up protonvpn && sudo wg"; + protondown = "sudo wg-quick down protonvpn"; }; programs = { bash.enable = true; diff --git a/system/home/shell/git.nix b/system/home/shell/git.nix index a9897081..f1a51572 100644 --- a/system/home/shell/git.nix +++ b/system/home/shell/git.nix @@ -5,7 +5,7 @@ ... }: { - services.git-sync.enable = true; + home.packages = [ pkgs.git-sync ]; programs.git = let package = pkgs.git.override { diff --git a/system/home/shell/ssh.nix b/system/home/shell/ssh.nix index 5bd8ee26..45999c6e 100644 --- a/system/home/shell/ssh.nix +++ b/system/home/shell/ssh.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { home.packages = with pkgs; [ + rclone sshfs (writeShellScriptBin "ssh-keygen-defaults" ''ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)"'') ];