diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7780ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.data/ +target/ \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index b630725..0000000 --- a/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Raine's Dotfiles - -## Crates -Everything is a crate. -If something is distro specific you should follow the following naming scheme: -`crate..sh` - -## Using it -Just use the script tbh -```sh -curl -L https://via.ixvd.net/sh | sh -``` \ No newline at end of file diff --git a/crates/00-system/crate.arch.sh b/crates/00-system/crate.arch.sh deleted file mode 100644 index 164fde4..0000000 --- a/crates/00-system/crate.arch.sh +++ /dev/null @@ -1,12 +0,0 @@ -super_apply() { - pacman -Syyu --noconfirm - pacman -S --needed --noconfirm sudo reflector - if ! grep -q "Reflector" /etc/pacman.d/mirrorlist; then - cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak - reflector -c NL -f 10 --threads 4 --save /etc/pacman.d/mirrorlist - else - echo "err: reflector already executed -- skipping..." - fi - - cp files/pacman.conf /etc/pacman.conf -} \ No newline at end of file diff --git a/crates/00-system/crate.debian.sh b/crates/00-system/crate.debian.sh deleted file mode 100644 index b866807..0000000 --- a/crates/00-system/crate.debian.sh +++ /dev/null @@ -1,5 +0,0 @@ -super_apply() { - apt update -y - apt install -y netselect-apt sudo - netselect-apt -} \ No newline at end of file diff --git a/crates/00-system/crate.sh b/crates/00-system/crate.sh deleted file mode 100644 index c5c5965..0000000 --- a/crates/00-system/crate.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -describe="Install stuff on the system!" -scripts="@distro @self" - -super_apply() { - if [ -f /usr/lib/security/pam_wheel.so ] && ! grep -q "# pam_wheel.so added" /etc/pam.d/su; then - echo "auth sufficient pam_wheel.so trust use_uid" > /etc/pam.d/su - echo "# pam_wheel.so added" > /etc/pam.d/su - fi -} \ No newline at end of file diff --git a/crates/00-system/files/pacman.conf b/crates/00-system/files/pacman.conf deleted file mode 100644 index e63be35..0000000 --- a/crates/00-system/files/pacman.conf +++ /dev/null @@ -1,31 +0,0 @@ -[options] -HoldPkg = pacman glibc yay -Architecture = auto - -Color -CheckSpace -ParallelDownloads = 5 - -SigLevel = Required DatabaseOptional -LocalFileSigLevel = Optional - -#[testing] -#Include = /etc/pacman.d/mirrorlist - -[core] -Include = /etc/pacman.d/mirrorlist - -[extra] -Include = /etc/pacman.d/mirrorlist - -#[community-testing] -#Include = /etc/pacman.d/mirrorlist - -[community] -Include = /etc/pacman.d/mirrorlist - -#[multilib-testing] -#Include = /etc/pacman.d/mirrorlist - -[multilib] -Include = /etc/pacman.d/mirrorlist diff --git a/crates/01-ssh/crate.sh b/crates/01-ssh/crate.sh deleted file mode 100644 index 6801c37..0000000 --- a/crates/01-ssh/crate.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -describe="setup ssh" - -apply() { - [ -e "$HOME/.ssh/authorized_keys" ] || ln files/authorized_keys $HOME/.ssh/authorized_keys - [ -e "$HOME/.ssh/config" ] || ln files/config $HOME/.ssh/config - if ! [ -f "$HOME/.ssh/id_rsa" ]; then - echo "Creating new ssh key for this device..." - ssh-keygen -f $HOME/.ssh/id_rsa -p "" -q - echo "Adding key to authorized_keys..." - cat $HOME/.ssh/id_rsa.pub > $HOME/.ssh/authorized_keys - fi -} - -undo() { - echo "Undoing ssh keys is not supported, please do this manually." -} diff --git a/crates/01-ssh/files/authorized_keys b/crates/01-ssh/files/authorized_keys deleted file mode 100644 index 7115b29..0000000 --- a/crates/01-ssh/files/authorized_keys +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCeNQfnbyyF3sht43vH5BcXDPca8nWu6bKPVGvAlWBOq4Av8ME2IQgwVe9nJ05r73ZY02/Vdqc01a8wyK5Hmw0XlPL0Cn6wc9QoiscOvq5lMUK87S2tr3EVLGkgl8o7nmVuWgLewyojiORjM02P1PZEiFhKPXVEQFxU0dFz9QtpAdm0u78Xn2HTukHpXSv44R3XDDMFZ3Ek/XRuS6J9dZVxGkgCLQhK8kpfbxuiYxaRC7MHgGlYuxjLuZ6P4i+V+SSSShfCGdm6U9bgeIAwftN6a8Pc9+OsBeZGSUrGjZjRlD35q0a7fbpoS8pKTfbwgf/ijYeu3JmAQUlY+H959mIpg4H9XOgRrKVJSYwx5/BGuhmWgVy6HIYpXCQfEbLE7QDmwC2C430KzAH6jCcrRNyurIUCuO4iq9dwoQTzboMccOK79S2Z+1B5fYgS3BZgaiTUBSME2G2FriM6utgleiBnvFu/p7oH2I8ZHL/aVcSWAw0gbzsr7ADywAuiDNZk18c= strix@ryuk \ No newline at end of file diff --git a/crates/01-ssh/files/config b/crates/01-ssh/files/config deleted file mode 100644 index 8c9646d..0000000 --- a/crates/01-ssh/files/config +++ /dev/null @@ -1,22 +0,0 @@ -## neb servers - -# hydrogen red helix -Host H - Hostname hydrogen.red.helix.saluco.nl - -# argon red helix -Host A - Hostname argon.red.helix.saluco.nl - -# iron red sphere -Host I - Hostname iron.red.sphere.saluco.nl - -## utility servers -Host git - Hostname git.saluco.nl - User git - -Host github - Hostname github.com - User git diff --git a/crates/05-i3/crate.arch.sh b/crates/05-i3/crate.arch.sh deleted file mode 100644 index 41e73a0..0000000 --- a/crates/05-i3/crate.arch.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -pkgs="i3 i3lock i3status libpulse brightnessctl xss-lock dex maim dmenu gnome-keyring feh picom" - -super_apply() { - pacman -S --needed --noconfirm $pkgs -} - -super_undo() { - pacman -R --noconfirm $pkgs -} diff --git a/crates/05-i3/crate.pop.sh b/crates/05-i3/crate.pop.sh deleted file mode 100644 index ccffa03..0000000 --- a/crates/05-i3/crate.pop.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -pkgs="i3 i3lock i3status libpulse-mainloop-glib brightnessctl xss-lock dex maim dmenu gnome-keyring feh picom" - -super_apply() { - apt install -y $pkgs -} - -super_undo() { - apt remove -y $pkgs -} diff --git a/crates/05-i3/crate.sh b/crates/05-i3/crate.sh deleted file mode 100644 index 09edde5..0000000 --- a/crates/05-i3/crate.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -describe="Installs i3" -scripts="@distro @self" - -apply() { - [ -d "$HOME/.config/i3" ] || mkdir -p $HOME/.config/i3 - [ -d "$HOME/.config/i3status" ] || mkdir -p $HOME/.config/i3status - [ -e "$HOME/.config/i3/config" ] || ln files/config $HOME/.config/i3/config - [ -e "$HOME/.config/i3status/config" ] || ln files/status_config $HOME/.config/i3status/config - [ -e "$HOME/.config/picom.conf" ] || ln files/picom.conf $HOME/.config/picom.conf -} - -undo() { - rm $HOME/.config/i3/config - rm $HOME/.config/i3status/config -} - -super_apply() { - [ -d "/etc/X11/xorg.conf.d" ] || mkdir -p /etc/X11/xorg.conf.d/ - cp files/40-proper-touchpad.conf /etc/X11/xorg.conf.d/40-proper-touchpad.conf -} - -super_undo() { - rm /etc/X11/xorg.conf.d/40-proper-touchpad.conf -} diff --git a/crates/05-i3/crate.void.sh b/crates/05-i3/crate.void.sh deleted file mode 100644 index 3f7f59b..0000000 --- a/crates/05-i3/crate.void.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -pkgs="i3 i3lock i3status pulseaudio-devel brightnessctl xss-lock dex maim dmenu gnome-keyring feh picom" - -super_apply() { - xbps-install -y $pkgs -} - -super_undo() { - xbps-remove -y $pkgs -} - diff --git a/crates/05-i3/files/40-proper-touchpad.conf b/crates/05-i3/files/40-proper-touchpad.conf deleted file mode 100644 index 80049de..0000000 --- a/crates/05-i3/files/40-proper-touchpad.conf +++ /dev/null @@ -1,8 +0,0 @@ -Section "InputClass" - Identifier "libinput touchpad catchall" - MatchIsTouchpad "on" - MatchDevicePath "/dev/input/event*" - Driver "libinput" - Option "NaturalScrolling" "True" - Option "Tapping" "on" -EndSection diff --git a/crates/05-i3/files/config b/crates/05-i3/files/config deleted file mode 100644 index d08481b..0000000 --- a/crates/05-i3/files/config +++ /dev/null @@ -1,206 +0,0 @@ -####################### -## Raine's i3 config ## -## Mar 22, 2023 ## -## mutation: 1m ## -####################### - -## Mostly similar to i3's config yet differs - -# Useful variables: -# This section probably gets changed a lot -# --- -set $terminal alacritty -set $screen_lock i3lock -c "#111111" --nofork -set $appmenu i3-dmenu-desktop - -set $screenshot maim -s | xclip -selection clipboard -t image/png - -set $font pango:monospace 8 - -# Startup Applications: -# Things that will startup when starting i3. -# --- -exec_always --no-startup-id dex --autostart --environment i3 -exec_always --no-startup-id nm-applet -exec_always --no-startup-id xss-lock --transfer-sleep-lock -- $screen_lock -exec_always --no-startup-id gnome-keyring-daemon --start --components=ssh,secrets,pkcs11 -exec_always --no-startup-id feh --bg-fill ~/Pictures/wallpaper.jpg -exec_always --no-startup-id picom - -# Gaps & Borders: -# --- -gaps inner 10 -smart_gaps on - -default_border pixel 1 -hide_edge_borders smart_no_gaps - -# Extra variables: -# Only need changing for very specific installations. -# --- -set $audio_volume_up XF86AudioRaiseVolume -set $audio_volume_down XF86AudioLowerVolume -set $audio_mute XF86AudioMute -set $audio_mute_mic XF86AudioMicMute - -set $brightness_up XF86MonBrightnessUp -set $brightness_down XF86MonBrightnessDown - -set $ws_1 "1:main" -set $ws_2 "2:term" -set $ws_3 "3:docs" -set $ws_4 "4:mail" -set $ws_5 "5" -set $ws_6 "6" -set $ws_7 "7" -set $ws_8 "8" -set $ws_9 "9:bg" -set $ws_10 "10:misc" - -set $meta_refresh_statusbar killall -SIGUSR1 i3status -bar { - strip_workspace_numbers yes - status_command i3status -} - -# END OF CONFIG - -set $mod Mod4 -set $alt Mod1 - -# Customization - -# class border backgr. text indic. child_border -client.focused #81A1C1 #81A1C1 #ffffff #D8DEE9 -client.focused_inactive #2E3440 #2E3440 #88C0D0 #454948 -client.unfocused #2E3440 #2E3440 #88C0D0 #454948 -client.urgent #D08770 #3B4252 #ffffff #268BD2 -client.placeholder #000000 #0c0c0c #ffffff #000000 -client.background #3B4252 - -# Generic -floating_modifier $mod -tiling_drag modifier titlebar -font $font - -# Open a terminal -bindsym $mod+Return exec $terminal - -# Kill current window -bindsym $mod+$alt+q kill - -# Open app menu -bindsym $mod+d exec --no-startup-id $appmenu - -# Lock screen -bindsym $mod+l exec --no-startup-id $screen_lock - -# Screenshots -bindsym Print exec --no-startup-id $screenshot - -# Audio -bindsym $audio_volume_up exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $meta_refresh_statusbar -bindsym $audio_volume_down exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $meta_refresh_statusbar -bindsym $audio_mute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $meta_refresh_statusbar -bindsym $audio_mute_mic exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $meta_refresh_statusbar - -# Brightness -bindsym $brightness_up exec --no-startup-id brightnessctl set +5% && $meta_refresh_statusbar -bindsym $brightness_down exec --no-startup-id brightnessctl set 5%- && $meta_refresh_statusbar - -# Change focused window -bindsym $mod+Up focus up -bindsym $mod+Down focus down -bindsym $mod+Left focus left -bindsym $mod+Right focus right - -# Move focused window -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Right move right - -# Splits -bindsym $mod+Shift+h split h -bindsym $mod+Shift+v split v - -# Change container layout -bindsym $mod+Shift+s layout stacking -bindsym $mod+Shift+t layout tabbed -bindsym $mod+Shift+d layout toggle split - -# Make current window fullscreen -bindsym $mod+Shift+f fullscreen toggle - -# Floating stuff -bindsym $mod+space focus mode_toggle -bindsym $mod+Shift+space floating toggle - -# Scratchpad -bindsym $mod+Shift+minus move scratchpad -bindsym $mod+minus scratchpad show - -# Switch to workspace -bindsym $mod+1 workspace $ws_1 -bindsym $mod+2 workspace $ws_2 -bindsym $mod+3 workspace $ws_3 -bindsym $mod+4 workspace $ws_4 -bindsym $mod+5 workspace $ws_5 -bindsym $mod+6 workspace $ws_6 -bindsym $mod+7 workspace $ws_7 -bindsym $mod+8 workspace $ws_8 -bindsym $mod+9 workspace $ws_9 -bindsym $mod+0 workspace $ws_10 - -# Move focused container to workspace -bindsym $mod+Shift+1 move container to workspace $ws_1 -bindsym $mod+Shift+2 move container to workspace $ws_2 -bindsym $mod+Shift+3 move container to workspace $ws_3 -bindsym $mod+Shift+4 move container to workspace $ws_4 -bindsym $mod+Shift+5 move container to workspace $ws_5 -bindsym $mod+Shift+6 move container to workspace $ws_6 -bindsym $mod+Shift+7 move container to workspace $ws_7 -bindsym $mod+Shift+8 move container to workspace $ws_8 -bindsym $mod+Shift+9 move container to workspace $ws_9 -bindsym $mod+Shift+0 move container to workspace $ws_10 - -# Move through workspaces -bindsym $mod+$alt+Left workspace prev -bindsym $mod+$alt+Right workspace next - -# WM stuff -# reload i3 config -bindsym $mod+$alt+c reload -# restart i3 -bindsym $mod+$alt+r restart -# exit i3 -bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'Exit i3?' -B 'Yes, exit i3' 'i3-msg exit'" - -# Modes -bindsym $mod+r mode resize -mode "resize" { - bindsym $nav_left resize shrink width 10 px or 10 ppt - bindsym $nav_down resize grow height 10 px or 10 ppt - bindsym $nav_up resize shrink height 10 px or 10 ppt - bindsym $nav_right resize grow width 10 px or 10 ppt - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Down resize grow height 10 px or 10 ppt - bindsym Up resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - bindsym Return mode "default" - bindsym Escape mode "default" - bindsym $mod+r mode "default" -} - -bindsym $mod+s mode "session" -mode "session" { - bindsym l exec --no-startup-id $lock, mode "default" - bindsym e exec --no-startup-id i3-msg exit, mode "default" - bindsym Shift+r exec --no-startup-id systemctl reboot, mode "default" - bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default" - - bindsym Return mode "default" - bindsym Escape mode "default" - bindsym $mod+s mode "default" -} diff --git a/crates/05-i3/files/picom.conf b/crates/05-i3/files/picom.conf deleted file mode 100644 index 5bff83a..0000000 --- a/crates/05-i3/files/picom.conf +++ /dev/null @@ -1,9 +0,0 @@ -inactive-opacity = 0.75; - -blur: { - method = "box"; - size = 10; - background = false; - background-frame = false; - background-fixed = false; -} diff --git a/crates/05-i3/files/status_config b/crates/05-i3/files/status_config deleted file mode 100644 index 3fce4a7..0000000 --- a/crates/05-i3/files/status_config +++ /dev/null @@ -1,57 +0,0 @@ -general { - output_format = "i3bar" - colors = true - interval = 5 -} - -order += "ipv6" -order += "wireless wlp58s0" -order += "battery 0" -order += "disk /" -order += "memory" -order += "load" -order += "tztime local" - -wireless wlp58s0 { - format_up = "W: (%quality at %essid, %bitrate) %ip" - format_down = "W: down" -} - -battery 0 { - format = "%status %percentage %remaining %emptytime" - format_down = "No battery" - status_chr = "⚡ CHR" - status_bat = "🔋 BAT" - status_unk = "? UNK" - status_full = "☻ FULL" - path = "/sys/class/power_supply/BAT%d/uevent" - low_threshold = 10 -} - -tztime local { - format = "%Y-%m-%d %H:%M:%S" - hide_if_equals_localtime = false -} - -tztime berlin { - format = "%Y-%m-%d %H:%M:%S %Z" - timezone = "Europe/Berlin" -} - -load { - format = "%5min" -} - -memory { - format = "%used" - threshold_degraded = "10%" - format_degraded = "MEMORY: %free" -} - -disk "/" { - format = "%free" -} - -read_file uptime { - path = "/proc/uptime" -} diff --git a/crates/10-zsh/crate.arch.sh b/crates/10-zsh/crate.arch.sh deleted file mode 100644 index 598a08c..0000000 --- a/crates/10-zsh/crate.arch.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - pacman -S --needed --noconfirm zsh -} - -super_undo() { - pacman -R --noconfirm zsh -} \ No newline at end of file diff --git a/crates/10-zsh/crate.debian.sh b/crates/10-zsh/crate.debian.sh deleted file mode 100644 index 33b0fcc..0000000 --- a/crates/10-zsh/crate.debian.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - apt install -y zsh -} - -super_undo() { - apt remove -y zsh -} diff --git a/crates/10-zsh/crate.pop.sh b/crates/10-zsh/crate.pop.sh deleted file mode 100644 index 33b0fcc..0000000 --- a/crates/10-zsh/crate.pop.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - apt install -y zsh -} - -super_undo() { - apt remove -y zsh -} diff --git a/crates/10-zsh/crate.sh b/crates/10-zsh/crate.sh deleted file mode 100644 index 2c06c84..0000000 --- a/crates/10-zsh/crate.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -describe="Install zsh and oh-my-zsh!" -scripts="@distro @self" - -super_apply() { - usermod $USER --shell /bin/zsh -} - -super_undo() { - usermod $USER --shell /bin/bash -} - -apply() { - if [ ! -d "$HOME/.oh-my-zsh" ]; then - sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended - - PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions - [ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-autosuggestions $PL_DIR - PL_DIR=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting - [ -d "$PL_DIR" ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $PL_DIR - fi - - [ -f "$HOME/.zshrc" ] && unlink $HOME/.zshrc - [ -e "$HOME/.zshrc" ] || ln files/.zshrc $HOME/.zshrc -} - -undo() { - unlink $HOME/.zshrc - rm -rf $HOME/.oh-my-zsh -} \ No newline at end of file diff --git a/crates/10-zsh/crate.void.sh b/crates/10-zsh/crate.void.sh deleted file mode 100644 index 19d54d1..0000000 --- a/crates/10-zsh/crate.void.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -super_apply() { - xbps-install -y zsh -} - -super_undo() { - xbps-remove -y zsh -} - diff --git a/crates/10-zsh/files/.zshrc b/crates/10-zsh/files/.zshrc deleted file mode 100644 index 4bbe248..0000000 --- a/crates/10-zsh/files/.zshrc +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/zsh - -# Raine's .zshrc - -if [ "$PROFILEINC" = "1" ]; then - . ~/.profile -fi - -export EDITOR=vim -export GPG_TTY=$(tty) -export PATH="$PATH:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/.local/bin" - -# oh-my-zsh init -if [ -f "$HOME/.oh-my-zsh/oh-my-zsh.sh" ]; then - export ZSH="$HOME/.oh-my-zsh" - ZSH_THEME="afowler" - plugins=(git docker docker-compose node zsh-autosuggestions zsh-syntax-highlighting zsh-cargo-completion) - source $ZSH/oh-my-zsh.sh -else - echo "oh-my-zsh not detected :(" - PS1="$(whoami)@${HOSTNAME:-$(hostname)} $ " -fi - -update_dotfiles() { - cd $HOME/.dotfiles - git pull - cd - &> /dev/null -} - -container() { - docker run \ - -ti \ - --rm \ - --name tmp-$(id -u)-$(openssl rand -hex 8) \ - --network ${CONTAINER_NETWORK:-internal} \ - alpine \ - ash -} - -[ -f "$HOME/.config/i3/shortcuts-i3.sh" ] && . ~/.config/i3/shortcuts-i3.sh - -alias q="exit" -alias vim="nvim" -alias vi="nvim" diff --git a/crates/20-vim/crate.arch.sh b/crates/20-vim/crate.arch.sh deleted file mode 100644 index 3d97b3c..0000000 --- a/crates/20-vim/crate.arch.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - pacman -S --needed --noconfirm neovim -} - -super_undo() { - echo "we never uninstall vim -_-" -} \ No newline at end of file diff --git a/crates/20-vim/crate.debian.sh b/crates/20-vim/crate.debian.sh deleted file mode 100644 index a6d8e34..0000000 --- a/crates/20-vim/crate.debian.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - apt install -y neovim -} - -super_undo() { - echo "we never uninstall vim -_-" -} \ No newline at end of file diff --git a/crates/20-vim/crate.sh b/crates/20-vim/crate.sh deleted file mode 100644 index b3b82e0..0000000 --- a/crates/20-vim/crate.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -describe="Install vim and it's stuff" -scripts="@distro @self" - -apply() { - [ -d "$HOME/.config/nvim" ] || mkdir -p "$HOME/.config/nvim" - [ -e "$HOME/.config/nvim/init.vim" ] || ln files/init.vim $HOME/.config/nvim/init.vim - [ -e "$HOME/.ideavimrc" ] || ln files/.ideavimrc $HOME/.ideavimrc -} - -undo() { - unlink $HOME/.config/nvim/init.vim - unlink $HOME/.ideavimrc -} \ No newline at end of file diff --git a/crates/20-vim/crate.void.sh b/crates/20-vim/crate.void.sh deleted file mode 100644 index 1b3e1e8..0000000 --- a/crates/20-vim/crate.void.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - xbps-install -y neovim -} - -super_undo() { - echo "we never uninstall vim -_-" -} \ No newline at end of file diff --git a/crates/20-vim/files/.ideavimrc b/crates/20-vim/files/.ideavimrc deleted file mode 100644 index 115e47f..0000000 --- a/crates/20-vim/files/.ideavimrc +++ /dev/null @@ -1,10 +0,0 @@ -source ~/.vimrc - -set scrolloff=5 -set incsearch - -map Q gq - -Plug 'machakann/vim-highlightedyank' -Plug 'tpope/vim-commentary' -Plug 'wellle/targets.vim' diff --git a/crates/20-vim/files/init.vim b/crates/20-vim/files/init.vim deleted file mode 100644 index d87f89e..0000000 --- a/crates/20-vim/files/init.vim +++ /dev/null @@ -1,27 +0,0 @@ -" vim preferences -set number -set relativenumber -syntax on - -" No arrow keys -noremap -noremap -noremap -noremap - -" ensure vim-plug -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -call plug#begin() - -Plug 'ThePrimeagen/vim-be-good' -Plug 'machakann/vim-highlightedyank' -Plug 'tpope/vim-commentary' -Plug 'wellle/targets.vim' -Plug 'vim-scripts/loremipsum' - -call plug#end() diff --git a/crates/30-alacritty/crate.arch.sh b/crates/30-alacritty/crate.arch.sh deleted file mode 100644 index cc95257..0000000 --- a/crates/30-alacritty/crate.arch.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - pacman -S --needed --noconfirm alacritty -} - -super_undo() { - pacman -R --noconfirm alacritty -} \ No newline at end of file diff --git a/crates/30-alacritty/crate.pop.sh b/crates/30-alacritty/crate.pop.sh deleted file mode 100644 index 27ea4e9..0000000 --- a/crates/30-alacritty/crate.pop.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - apt install -y alacritty -} - -super_undo() { - apt remove -y alacritty -} diff --git a/crates/30-alacritty/crate.sh b/crates/30-alacritty/crate.sh deleted file mode 100644 index 27f5762..0000000 --- a/crates/30-alacritty/crate.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -describe="Installs alacritty and configs" -scripts="@distro @self" - -apply() { - [ -d "$HOME/.config/alacritty" ] || mkdir -p $HOME/.config/alacritty - [ -e "$HOME/.config/alacritty/alacritty.yml" ] || ln files/alacritty.yml $HOME/.config/alacritty/alacritty.yml -} - -undo() { - unlink $HOME/.config/alacritty/alacritty.yml -} \ No newline at end of file diff --git a/crates/30-alacritty/crate.void.sh b/crates/30-alacritty/crate.void.sh deleted file mode 100644 index 4312e25..0000000 --- a/crates/30-alacritty/crate.void.sh +++ /dev/null @@ -1,7 +0,0 @@ -super_apply() { - xbps-install -y alacritty -} - -super_undo() { - xbps-remove -y alacritty -} \ No newline at end of file diff --git a/crates/30-alacritty/files/alacritty.yml b/crates/30-alacritty/files/alacritty.yml deleted file mode 100644 index 1a30120..0000000 --- a/crates/30-alacritty/files/alacritty.yml +++ /dev/null @@ -1,6 +0,0 @@ -cursor: - style: - shape: 'Block' - blinking: 'On' - blink_interval: 500 - diff --git a/crates/40-git/crate.sh b/crates/40-git/crate.sh deleted file mode 100644 index e9376ac..0000000 --- a/crates/40-git/crate.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -describe="Setup git" -scripts="@distro @self" - -apply() { - git config --global user.name Strix - git config --global user.email strix@saluco.nl -} diff --git a/crates/common/crate.toml b/crates/common/crate.toml new file mode 100644 index 0000000..45fc314 --- /dev/null +++ b/crates/common/crate.toml @@ -0,0 +1,23 @@ +name = "common" +description = "Common set of utilities" + +[pkgs] +openssh-server = {} +openssh-client = {} +git = {} +netselect = { distros = ["debian", "ubuntu"] } +reflector = { distros = ["arch"] } + +[actions] +setup_ssh = ["sh", "./scripts/%"] +reflector = { args = ["sh", "./scripts/setup_pm/%"], distro = ["arch"] } +netselect = { args = [ + "sh", + "./scripts/setup_pm/%", +], distro = [ + "debian", + "ubuntu", +] } + +[super_actions] +pam_wheel = ["sh", "./scripts/%"] diff --git a/crates/common/scripts/pam_wheel.sh b/crates/common/scripts/pam_wheel.sh new file mode 100644 index 0000000..e3adf88 --- /dev/null +++ b/crates/common/scripts/pam_wheel.sh @@ -0,0 +1,4 @@ +if [ -f /usr/lib/security/pam_wheel.so ] && ! grep -q "# pam_wheel.so added" /etc/pam.d/su; then + echo "auth sufficient pam_wheel.so trust use_uid" > /etc/pam.d/su + echo "# pam_wheel.so added" > /etc/pam.d/su +fi diff --git a/dot b/dot deleted file mode 100755 index 6a0f50d..0000000 --- a/dot +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -ask=0 - -is_function() { - type "$1" 2>/dev/null | sed "s/$1//" | grep -qwi function -} - -curr_distro() { - cat /etc/os-release | grep -G "^ID=" | sed 's/ID=//' -} - -include() { - [ -f "$1" ] || return 1 - . $1 - return 0 -} - -func() { - if is_function $(echo "super_$2"); then - [ "${DO_SUDO:-yes}" = "yes" ] || return 0 - ecmd=". $1 && super_$2" - [ "$(id -u)" = "0" ] && sh -c "$ecmd" || sudo sh -c "$ecmd" - unset ecmd - fi - is_function $2 && $2 -} - -# only run this *in crate dir* -run_crate() { - enabled=1 - include ./crate.sh || exit 1 - if [ -n "$describe" ]; then - echo "desc($(basename $PWD)): $describe" - fi - if [ $enabled -ne 1 ]; then - return - fi - cmd=$1 - scripts=${scripts:-"@self @distro"} - for s in $scripts; do - echo "exec($(basename $PWD)): $s/$cmd" - case $s in - @self) - func ./crate.sh $cmd - ;; - @distro) - unset -f super_$cmd - unset -f $cmd - include ./crate.$(curr_distro).sh - func ./crate.$(curr_distro).sh $cmd - unset -f super_$cmd - unset -f $cmd - include ./crate.sh - ;; - *) - sh $s - ;; - esac - done -} - -echo "# details:" -echo "# user: $USER (${UID:-$(id -u)})" -echo "# groups: $(groups)" -echo "# distro: $(curr_distro)" - -cmd=$1 -if [ -z "$cmd" ]; then - echo "usage: $0 [...args]" - exit 1 -else - shift -fi - -for c in ${@:-$(ls crates)}; do - [ -d crates/*$c ] || exit 1 - cd crates/*$c - case $cmd in - a | apply) - run_crate apply - ;; - u | undo) - run_crate undo - ;; - *) exit 1 ;; - esac - cd ../.. -done diff --git a/remote_script.sh b/remote_script.sh deleted file mode 100644 index 8866057..0000000 --- a/remote_script.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# this script is meant to be ran when .dotfiles is not present. -# -# example: -# curl https://git.saluco.nl/strix/dotfiles/raw/branch/main/remote_script.sh | sh - -set -e - -HOME=${HOME:-/home/${USER:-$(whomai)}} - -[ -d "$HOME/.dotfiles" ] || git clone https://git.saluco.nl/strix/dotfiles $HOME/.dotfiles -cd $HOME/.dotfiles -./dot a diff --git a/scripts/void.d/update-discord.sh b/scripts/void.d/update-discord.sh deleted file mode 100755 index 5c753c6..0000000 --- a/scripts/void.d/update-discord.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -echo "Downloading newest package..." -curl -Lo /tmp/discord.deb "https://discord.com/api/download?platform=linux&format=deb" -cd /tmp -echo "Extracting package..." -xdeb discord.deb -echo "Installing package..." -sudo xbps-install -R /tmp/binpkgs discord -rm -rf /tmp/binpkgs -cd - diff --git a/sync-runner/Cargo.lock b/sync-runner/Cargo.lock new file mode 100644 index 0000000..3493d48 --- /dev/null +++ b/sync-runner/Cargo.lock @@ -0,0 +1,1149 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "cc" +version = "1.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "colored" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "execute" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a82608ee96ce76aeab659e9b8d3c2b787bffd223199af88c674923d861ada10" +dependencies = [ + "execute-command-macro", + "execute-command-tokens", + "generic-array 1.2.0", +] + +[[package]] +name = "execute-command-macro" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dec53d547564e911dc4ff3ecb726a64cf41a6fa01a2370ebc0d95175dd08bd" +dependencies = [ + "execute-command-macro-impl", +] + +[[package]] +name = "execute-command-macro-impl" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8cd46a041ad005ab9c71263f9a0ff5b529eac0fe4cc9b4a20f4f0765d8cf4b" +dependencies = [ + "execute-command-tokens", + "quote", + "syn", +] + +[[package]] +name = "execute-command-tokens" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69dc321eb6be977f44674620ca3aa21703cb20ffbe560e1ae97da08401ffbcad" + +[[package]] +name = "fern" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" +dependencies = [ + "log", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "generic-array" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c8444bc9d71b935156cc0ccab7f622180808af7867b1daae6547d773591703" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "git2" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.170" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" + +[[package]] +name = "libgit2-sys" +version = "0.18.0+1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "libssh2-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "220e4f05ad4a218192533b300327f5150e809b54c4ec83b5a1d91833601811b9" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + +[[package]] +name = "log" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "serde" +version = "1.0.218" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.218" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-runner" +version = "0.1.0" +dependencies = [ + "clap", + "colored", + "execute", + "fern", + "git2", + "glob", + "hex", + "lazy_static", + "log", + "regex", + "serde", + "sha2", + "shellexpand", + "toml", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "toml" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" +dependencies = [ + "memchr", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/sync-runner/Cargo.toml b/sync-runner/Cargo.toml new file mode 100644 index 0000000..4eaa739 --- /dev/null +++ b/sync-runner/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "sync-runner" +version = "0.1.0" +edition = "2021" + +[dependencies] +clap = { version = "4.5.29", features = ["derive"] } +colored = "3.0.0" +execute = "0.2.13" +fern = "0.7.1" +git2 = "0.20.0" +glob = "0.3.2" +hex = "0.4.3" +lazy_static = "1.5.0" +log = "0.4.26" +regex = "1.11.1" +serde = { version = "1.0.218", features = ["serde_derive"] } +sha2 = "0.10.8" +shellexpand = "3.1.0" +toml = "0.8.20" diff --git a/sync-runner/package_manager.list b/sync-runner/package_manager.list new file mode 100644 index 0000000..e175111 --- /dev/null +++ b/sync-runner/package_manager.list @@ -0,0 +1,11 @@ +install(pacman): pacman -Sy %args +uninstall(pacman): pacman -Rn %args + +install(apt): apt install %args +uninstall(apt): apt remove %args + +install(dnf): dnf install %args +uninstall(dnf): dnf remove %args + +install(yum): yum install %args +uninstall(yum): yum remove %args diff --git a/sync-runner/src/action.rs b/sync-runner/src/action.rs new file mode 100644 index 0000000..667cbed --- /dev/null +++ b/sync-runner/src/action.rs @@ -0,0 +1,10 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub enum Action { + /// Sync your device with dotfiles repository + Sync { + #[arg(short, long)] + config_path: Option, + }, +} diff --git a/sync-runner/src/cfg/daemon.rs b/sync-runner/src/cfg/daemon.rs new file mode 100644 index 0000000..3d4a908 --- /dev/null +++ b/sync-runner/src/cfg/daemon.rs @@ -0,0 +1,7 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Daemon { + /// interval in minutes + pub interval: u64, +} diff --git a/sync-runner/src/cfg/mod.rs b/sync-runner/src/cfg/mod.rs new file mode 100644 index 0000000..1f56292 --- /dev/null +++ b/sync-runner/src/cfg/mod.rs @@ -0,0 +1,15 @@ + +#![allow(unused)] + +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +mod daemon; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Config { + pub title: String, + pub daemon: daemon::Daemon, + pub source: HashMap +} diff --git a/sync-runner/src/crates/mod.rs b/sync-runner/src/crates/mod.rs new file mode 100644 index 0000000..ec3d5dd --- /dev/null +++ b/sync-runner/src/crates/mod.rs @@ -0,0 +1,34 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +mod pm; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Package { + name: String, +} + +impl Package { + pub fn install(&self) { + todo!() + } + + pub fn uninstall(&self) { + todo!() + } +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CrateAction { + pub name: String, + pub command: String, + pub args: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Crate { + pub pkgs: HashMap, + pub actions: HashMap, + pub super_actions: HashMap, +} diff --git a/sync-runner/src/crates/pm.rs b/sync-runner/src/crates/pm.rs new file mode 100644 index 0000000..692ec15 --- /dev/null +++ b/sync-runner/src/crates/pm.rs @@ -0,0 +1,90 @@ +use lazy_static::lazy_static; +use regex::Regex; +use std::{process::Command, str::FromStr}; + +const pm_cfg: &str = include_str!("../../package_manager.list"); + +/// regex: `(?[a-z]+)>(?(?:un)?install+): (?.*)` +/// example: pacman>install: pacman -Sy %args + +lazy_static! { + static ref PM_REGEX: Regex = + Regex::new(r"(?P[a-z]+)>(?P(?:un)?install+): (?P.*)").unwrap(); +} + +#[derive(Debug)] +struct PackageManager { + name: String, + command: String, + args: Vec, +} + +impl PackageManager { + fn new(name: &str, command: &str, args: Vec) -> Self { + Self { + name: name.to_string(), + command: command.to_string(), + args, + } + } + + pub fn install(&self, packages: Vec) -> Result<(), Vec> { + Command::new(&self.command) + .args(&self.args) + .args(packages) + .spawn() + .expect("err"); + Ok(()) + } + pub fn uninstall(&self, packages: Vec) -> Result<(), Vec> { + todo!(); + } +} +impl FromStr for PackageManager { + type Err = String; + fn from_str(s: &str) -> Result { + let caps = PM_REGEX.captures(s).ok_or("invalid package manager")?; + let name = caps.name("pm").ok_or("invalid package manager")?.as_str(); + let command = caps + .name("command") + .ok_or("invalid package manager")? + .as_str(); + let args = caps + .name("args") + .ok_or("invalid package manager")? + .as_str() + .split_whitespace() + .map(|s| s.to_string()) + .collect(); + Ok(Self::new(name, command, args)) + } +} +#[derive(Debug)] +struct Package { + name: String, +} +impl FromStr for Package { + type Err = String; + fn from_str(s: &str) -> Result { + let caps = PM_REGEX.captures(s).ok_or("invalid package")?; + let name = caps.name("name").ok_or("invalid package")?.as_str(); + Ok(Self::new(name)) + } +} + +impl Package { + fn new(name: &str) -> Self { + Self { + name: name.to_string(), + } + } +} + +pub fn package_managers() -> Vec { + pm_cfg + .lines() + .map(|s| s.to_string()) + .map(|s| s.parse::()) + .collect::, String>>() + .expect("invalid package manager") +} diff --git a/sync-runner/src/logging.rs b/sync-runner/src/logging.rs new file mode 100644 index 0000000..6f6c082 --- /dev/null +++ b/sync-runner/src/logging.rs @@ -0,0 +1,64 @@ +use std::env; + +use colored::Colorize; +use fern::Dispatch; +use log::{Record, SetLoggerError}; + +fn format_regular>(log: S, record: &Record) -> String { + let log = log.into(); + let line_prefix = |line: String, extend: bool| { + let prefix = if extend { + match record.level() { + log::Level::Trace => " ]".bright_blue(), + log::Level::Debug => " ?".green(), + log::Level::Info => " >".blue(), + log::Level::Warn => " #".yellow(), + log::Level::Error => " !".red(), + }.to_string() + } else { + match record.level() { + log::Level::Trace => "[TRACE]".bright_blue().italic(), + log::Level::Debug => "??".green(), + log::Level::Info => "=>".blue(), + log::Level::Warn => "##".yellow(), + log::Level::Error => "!!".red().bold() + }.to_string() + }; + return format!("{} {}", prefix, line); + }; + + let mut lines = log.lines().peekable(); + let mut output = match lines.peek() { + Some(_line) => line_prefix(lines.next().unwrap().to_string(), false), + None => return "".to_string(), + }; + + for line in lines { + output.push_str(&*format!("\n{}", line_prefix(line.to_string(), true))); + } + + output +} + +pub fn setup_logger() -> Result<(), SetLoggerError> { + Dispatch::new() + .format(|out, message, record| { + match record.metadata().target() { + // command output logging + "command:stdout" => out.finish(format_args!("{} {}", ">>".cyan(), message.to_string())), + "command:stderr" => out.finish(format_args!("{} {}", ">>".red(), message.to_string())), + // this target means, it's an item and not a log. + "item" => out.finish(format_args!("{} {}", "*".blue(), message.to_string())), + // default logging + _ => out.finish(format_args!("{}", format_regular(message.to_string(), record))), + } + }) + .level( + env::var("SYNCR_LOG_LEVEL") + .unwrap_or_else(|_| "info".to_string()) + .parse() + .unwrap_or(log::LevelFilter::Info), + ) + .chain(std::io::stdout()) + .apply() +} diff --git a/sync-runner/src/main.rs b/sync-runner/src/main.rs new file mode 100644 index 0000000..539e733 --- /dev/null +++ b/sync-runner/src/main.rs @@ -0,0 +1,77 @@ +use std::{ + env::set_current_dir, + fs::{exists, read_to_string, File}, + path::{absolute, Path}, + process::{exit, Stdio}, +}; + +use action::Action; +use cfg::Config; +use clap::Parser; +use colored::Colorize; +use execute::{command_args, Execute}; +use log::{debug, error, info, trace, warn}; +use prelude::abspath; + +mod action; +mod cfg; +mod crates; +mod logging; +mod prelude; +mod source; + +fn main() -> Result<(), Box> { + logging::setup_logger()?; + + let git_sha1 = String::from_utf8( + command_args!("git", "rev-parse", "HEAD") + .stdout(Stdio::piped()) + .execute_output()? + .stdout, + )?; + + let action = Action::parse(); + match action { + Action::Sync { config_path } => { + trace!("fetching config dir... {config_path:?}"); + if let Some(config_path) = abspath(&config_path.unwrap_or("~/.syncr".into())) { + trace!("setting config dir as cwd... {config_path}"); + set_current_dir(config_path)?; + } + let config = + toml::from_str::(&read_to_string(abspath("./syncr.toml").unwrap())?)?; + info!("syncing \"{}\"...", config.title.bold()); + + info!("updating sources..."); + let mut available_sources = vec![]; + for (name, source) in &config.source { + debug!("checking {name}..."); + if !source.available() { + warn!("source \"{name}\" unavailable."); + } else { + info!("source \"{name}\" available!"); + available_sources.push(source); + } + } + + if available_sources.len() == 0 { + error!("{}", "sync impossible; no sources.".bold()); + exit(1); + } + + let oldpwd = absolute(".")?; + for source in available_sources { + // cd to source dir + source.go_to_dir()?; + for c in source.get_crates()? { + info!("{} pkgs", c.pkgs.len()) + } + } + } + _ => { + println!("{action:#?}"); + } + } + + Ok(()) +} diff --git a/sync-runner/src/prelude.rs b/sync-runner/src/prelude.rs new file mode 100644 index 0000000..0b1994b --- /dev/null +++ b/sync-runner/src/prelude.rs @@ -0,0 +1,5 @@ +pub fn abspath(p: &str) -> Option { + let exp_path = shellexpand::full(p).ok()?; + let can_path = std::fs::canonicalize(exp_path.as_ref()).ok()?; + can_path.into_os_string().into_string().ok() +} \ No newline at end of file diff --git a/sync-runner/src/source/git.rs b/sync-runner/src/source/git.rs new file mode 100644 index 0000000..8ad2389 --- /dev/null +++ b/sync-runner/src/source/git.rs @@ -0,0 +1,241 @@ +use std::{ + env::current_dir, fs::{self, create_dir_all, exists}, io::Write, path::{Path, PathBuf} +}; + +use git2::Repository; +use log::{debug, info, trace, warn}; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256, Sha512}; + +use crate::prelude::abspath; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Git { + pub url: String, + #[serde(default = "default_branch")] + pub branch: String, +} + +fn default_branch() -> String { + "main".to_string() +} + +impl Git { + fn url_hash(&self) -> String { + let mut hasher = Sha256::new(); + hasher.update(&self.url); + let hash = hasher.finalize(); + hex::encode(hash) + } + + fn branch_hash(&self) -> String { + let mut hasher = Sha256::new(); + hasher.update(&self.url); + let hash = hasher.finalize(); + hex::encode(hash) + } + + pub fn repository_path_str(&self) -> String { + format!(".data/git/{}{}", self.url_hash(), self.branch_hash()) + } + + pub fn repository_path(&self) -> Result { + fs::canonicalize(self.repository_path_str()) + } + + pub fn exists_on_fs(&self) -> bool { + self.repository_path().is_ok() + } + + pub fn clone_repository(&self) -> Result { + Repository::clone_recurse(&self.url, Path::new(&self.repository_path_str())) + } + + pub fn repository(&self) -> Result { + if !self.exists_on_fs() { + create_dir_all(self.repository_path_str()).unwrap(); + } + match Repository::open(self.repository_path().unwrap()) { + Ok(r) => Ok(r), + Err(_) => self.clone_repository(), + } + } + + fn up_to_date(&self) -> Result>{ + debug!("checking repo up to date..."); + let repo = self.repository()?; + let mut remote = repo.find_remote("origin")?; + + // Fetch latest references from remote + remote.fetch(&[self.branch.clone()], None, None)?; + + let fetch_head = repo.refname_to_id(&format!("refs/remotes/origin/{}", self.branch))?; + let local_head = repo.refname_to_id(&format!("refs/heads/{}", self.branch))?; + + + Ok(fetch_head == local_head) + } + + pub fn update(&self) -> Result> { + if self.up_to_date()? { + return Ok(true); + } + debug!("updating repository..."); + let repository = self.repository()?; + let mut remote = repository.find_remote("origin")?; + let mut cb = git2::RemoteCallbacks::new(); + + cb.transfer_progress(|stats| { + if stats.received_objects() == stats.total_objects() { + print!( + "resolving deltas {}/{}\r", + stats.indexed_deltas(), + stats.total_deltas() + ); + } else if stats.total_objects() > 0 { + print!( + "received {}/{} objects ({}) in {} bytes\r", + stats.received_objects(), + stats.total_objects(), + stats.indexed_objects(), + stats.received_bytes() + ); + } + std::io::stdout().flush().unwrap(); + true + }); + + let mut fo = git2::FetchOptions::new(); + fo.remote_callbacks(cb); + // Always fetch all tags. + // Perform a download and also update tips + fo.download_tags(git2::AutotagOption::All); + info!("fetching {}...", remote.name().unwrap()); + remote.fetch(&[self.branch.clone()], Some(&mut fo), None)?; + + let fetch_head = repository.find_reference("FETCH_HEAD")?; + + do_merge( + &repository, + &self.branch, + repository.reference_to_annotated_commit(&fetch_head)?, + )?; + + Ok(true) + } + + pub fn ensure(&self) -> Result<&Self, Box> { + if self.exists_on_fs() { + self.update(); + } else { + self.clone_repository()?; + } + Ok(self) + } +} + +fn do_merge<'a>( + repo: &'a Repository, + remote_branch: &str, + fetch_commit: git2::AnnotatedCommit<'a>, +) -> Result<(), git2::Error> { + // 1. do a merge analysis + let analysis = repo.merge_analysis(&[&fetch_commit])?; + + // 2. Do the appopriate merge + if analysis.0.is_fast_forward() { + info!("doing a fast forward..."); + // do a fast forward + let refname = format!("refs/heads/{}", remote_branch); + match repo.find_reference(&refname) { + Ok(mut r) => { + fast_forward(repo, &mut r, &fetch_commit)?; + } + Err(_) => { + // The branch doesn't exist so just set the reference to the + // commit directly. Usually this is because you are pulling + // into an empty repository. + repo.reference( + &refname, + fetch_commit.id(), + true, + &format!("Setting {} to {}", remote_branch, fetch_commit.id()), + )?; + repo.set_head(&refname)?; + repo.checkout_head(Some( + git2::build::CheckoutBuilder::default() + .allow_conflicts(true) + .conflict_style_merge(true) + .force(), + ))?; + } + }; + } else if analysis.0.is_normal() { + // do a normal merge + let head_commit = repo.reference_to_annotated_commit(&repo.head()?)?; + normal_merge(&repo, &head_commit, &fetch_commit)?; + } else { + info!("nothing to do..."); + } + Ok(()) +} + +fn fast_forward( + repo: &Repository, + lb: &mut git2::Reference, + rc: &git2::AnnotatedCommit, +) -> Result<(), git2::Error> { + let name = match lb.name() { + Some(s) => s.to_string(), + None => String::from_utf8_lossy(lb.name_bytes()).to_string(), + }; + let msg = format!("fast-forward: setting {} to id: {}", name, rc.id()); + info!("{}", msg); + lb.set_target(rc.id(), &msg)?; + repo.set_head(&name)?; + repo.checkout_head(Some( + git2::build::CheckoutBuilder::default() + // For some reason the force is required to make the working directory actually get updated + // I suspect we should be adding some logic to handle dirty working directory states + // but this is just an example so maybe not. + .force(), + ))?; + Ok(()) +} + +fn normal_merge( + repo: &Repository, + local: &git2::AnnotatedCommit, + remote: &git2::AnnotatedCommit, +) -> Result<(), git2::Error> { + let local_tree = repo.find_commit(local.id())?.tree()?; + let remote_tree = repo.find_commit(remote.id())?.tree()?; + let ancestor = repo + .find_commit(repo.merge_base(local.id(), remote.id())?)? + .tree()?; + let mut idx = repo.merge_trees(&ancestor, &local_tree, &remote_tree, None)?; + + if idx.has_conflicts() { + warn!("merge conficts detected..."); + repo.checkout_index(Some(&mut idx), None)?; + return Ok(()); + } + let result_tree = repo.find_tree(idx.write_tree_to(repo)?)?; + // now create the merge commit + let msg = format!("Merge: {} into {}", remote.id(), local.id()); + let sig = repo.signature()?; + let local_commit = repo.find_commit(local.id())?; + let remote_commit = repo.find_commit(remote.id())?; + // Do our merge commit and set current branch head to that commit. + let _merge_commit = repo.commit( + Some("HEAD"), + &sig, + &sig, + &msg, + &result_tree, + &[&local_commit, &remote_commit], + )?; + // Set working tree to match head. + repo.checkout_head(None)?; + Ok(()) +} diff --git a/sync-runner/src/source/mod.rs b/sync-runner/src/source/mod.rs new file mode 100644 index 0000000..7ab1dcd --- /dev/null +++ b/sync-runner/src/source/mod.rs @@ -0,0 +1,68 @@ +use std::{env::{current_dir, set_current_dir}, fs::{create_dir_all, read_to_string}, path::PathBuf}; + +use log::{debug, info, trace}; +use serde::{Deserialize, Serialize}; + +use crate::{crates::Crate, prelude::abspath}; + +pub mod git; + +#[derive(Serialize, Deserialize, Debug)] +#[serde(default)] +pub struct Source { + interval: u64, + git: Option, +} + +impl Default for Source { + fn default() -> Self { + Source { + interval: 60, + git: None, + } + } +} + +impl Source { + pub fn available(&self) -> bool { + if let Some(git) = &self.git { + trace!("checking git..."); + return git.ensure().is_ok(); + } + false + } + + pub fn go_to_dir(&self) -> Result<(), Box> { + if let Some(git) = &self.git { + if PathBuf::from(git.repository_path_str()) == current_dir()? { + return Ok(()) + } + let dir = git.ensure()?.repository_path()?; + trace!("setting git dir as cwd... ({}@{}, {})", git.url, git.branch, dir.display()); + set_current_dir(dir)?; + } + Ok(()) + } + + pub fn get_crates(&self) -> Result, Box> { + let mut crates = vec![]; + if let Some(git) = &self.git { + trace!("getting crates from git..."); + debug!("{}", current_dir()?.display()); + + // get crates (read dir, crates/*/crate.toml) + for crate_file in glob::glob("crates/*/crate.toml").expect("err") { + debug!("{crate_file:#?}"); + match crate_file { + Ok(cd) =>{ + debug!("{}", cd.display()); + crates.push(toml::from_str(&read_to_string(cd)?)?) + }, + _ => continue + } + } + } + debug!("{:#?}", crates); + Ok(crates) + } +} diff --git a/sync.sh b/sync.sh new file mode 100644 index 0000000..fd8e62d --- /dev/null +++ b/sync.sh @@ -0,0 +1 @@ +node sync-runner/index.js diff --git a/syncr.toml b/syncr.toml new file mode 100644 index 0000000..13e4343 --- /dev/null +++ b/syncr.toml @@ -0,0 +1,17 @@ +title = "strix's syncr config" + +[daemon] +# interval +# discription: how often to check for new updates, this is the default for syncs +# you can define a custom interval for specific sources +# unit = minutes +interval = 60 + +[source.personal.git] # default is the uid +url = "https://git.saluco.nl/strix/dotfiles.git" +crate_dir = "./crates" # default +cfg_toml = "./syncr.toml" # default + +[source.work.git] +url = "https://git.saluco.nl/dotfiles.git" +branch = "work" \ No newline at end of file