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
This commit is contained in:
Evie Litherland-Smith 2024-10-22 11:36:21 +01:00
parent 4734368f0c
commit a52ccf7ef4
10 changed files with 16 additions and 159 deletions

View file

@ -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

View file

@ -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 = {

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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;

View file

@ -5,7 +5,7 @@
...
}:
{
services.git-sync.enable = true;
home.packages = [ pkgs.git-sync ];
programs.git =
let
package = pkgs.git.override {

View file

@ -1,6 +1,7 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
rclone
sshfs
(writeShellScriptBin "ssh-keygen-defaults" ''ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)"'')
];