Compare commits

...

7 commits

13 changed files with 75 additions and 252 deletions

View file

@ -3,6 +3,8 @@
# Automated script to install my dotfiles # Automated script to install my dotfiles
# Clone dotfiles # Clone dotfiles
# TODO make ~/.dotfiles path arbitrary and make all other scripts conform to this
# using SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
nix-shell -p git --command "git clone https://gitlab.com/librephoenix/nixos-config ~/.dotfiles" nix-shell -p git --command "git clone https://gitlab.com/librephoenix/nixos-config ~/.dotfiles"
# Generate hardware config for new system # Generate hardware config for new system

View file

@ -10,7 +10,6 @@
imports = [ imports = [
../../user/shell/sh.nix # My zsh and bash config ../../user/shell/sh.nix # My zsh and bash config
../../user/bin/phoenix.nix # My nix command wrapper
../../user/app/ranger/ranger.nix # My ranger file manager config ../../user/app/ranger/ranger.nix # My ranger file manager config
../../user/app/git/git.nix # My git config ../../user/app/git/git.nix # My git config
]; ];

View file

@ -14,7 +14,6 @@
(./. + "../../../user/wm"+("/"+userSettings.wm+"/"+userSettings.wm)+".nix") # My window manager selected from flake (./. + "../../../user/wm"+("/"+userSettings.wm+"/"+userSettings.wm)+".nix") # My window manager selected from flake
../../user/shell/sh.nix # My zsh and bash config ../../user/shell/sh.nix # My zsh and bash config
../../user/shell/cli-collection.nix # Useful CLI apps ../../user/shell/cli-collection.nix # Useful CLI apps
../../user/bin/phoenix.nix # My nix command wrapper
../../user/app/doom-emacs/doom.nix # My doom emacs config ../../user/app/doom-emacs/doom.nix # My doom emacs config
../../user/app/ranger/ranger.nix # My ranger file manager config ../../user/app/ranger/ranger.nix # My ranger file manager config
../../user/app/git/git.nix # My git config ../../user/app/git/git.nix # My git config

View file

@ -13,7 +13,6 @@
stylix.homeManagerModules.stylix stylix.homeManagerModules.stylix
../../user/shell/sh.nix # My zsh and bash config ../../user/shell/sh.nix # My zsh and bash config
../../user/shell/cli-collection.nix # Useful CLI apps ../../user/shell/cli-collection.nix # Useful CLI apps
../../user/bin/phoenix.nix # My nix command wrapper
../../user/app/doom-emacs/doom.nix # My doom emacs config ../../user/app/doom-emacs/doom.nix # My doom emacs config
../../user/app/ranger/ranger.nix # My ranger file manager config ../../user/app/ranger/ranger.nix # My ranger file manager config
../../user/app/git/git.nix # My git config ../../user/app/git/git.nix # My git config

21
pull.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
# Automated script to update my non-primary systems
# to be in sync with upstream git repo while
# preserving local edits to dotfiles via git stash
# Relax permissions temporarily so git can work
sudo ~/.dotfiles/soften.sh ~/.dotfiles;
# Stash local edits, pull changes, and re-apply local edits
pushd ~/.dotfiles;
git stash;
git pull;
git stash apply;
popd;
# Permissions for files that should be owned by root
sudo ~/.dotfiles/harden.sh ~/.dotfiles;
# Synchronize system
~/.dotfiles/sync.sh;

21
sync-posthook.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
# Post hooks to be called after a
# configuration sync
# Mainly just to reload stylix
# xmonad
pgrep xmobar &> /dev/null && echo "Killing old xmobar instances" && echo "Running killall xmobar" && killall xmobar &> /dev/null; # xmonad will restart xmobar
pgrep xmonad &> /dev/null && echo "Recompiling xmonad" && echo "Running xmonad --recompile && xmonad --restart" && xmonad --recompile && xmonad --restart;
pgrep .dunst-wrapped &> /dev/null && echo "Restarting dunst" && killall .dunst-wrapped && echo "Running dunst" && dunst &> /dev/null & disown;
pgrep xmonad &> /dev/null && echo "Reapplying background from stylix via feh" && echo "Running ~/.fehbg-stylix" && ~/.fehbg-stylix & disown;
# hyprland
pgrep Hyprland &> /dev/null && echo "Reloading hyprland" && hyprctl reload
pgrep .waybar-wrapped &> /dev/null && echo "Restarting waybar" && killall .waybar-wrapped && echo "Running waybar" && waybar &> /dev/null & disown;
pgrep fnott &> /dev/null && echo "Restarting fnott" && killall fnott && echo "Running fnott" && fnott &> /dev/null & disown;
pgrep Hyprland &> /dev/null && echo "Reapplying background from stylix via swaybg" && echo "Running ~/.swaybg-stylix" && ~/.swaybg-stylix & disown;
# emacs
pgrep emacs &> /dev/null && echo "Reloading emacs stylix theme" && echo "Running emacsclient --no-wait --eval \"(load-theme 'doom-stylix t nil)\"" && emacsclient --no-wait --eval "(load-theme 'doom-stylix t nil)";

13
sync.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
# Script to synchronize system state
# with configuration files for nixos system
# and home-manager
# Rebuild system
sudo nixos-rebuild switch --flake ~/.dotfiles#system;
# Install and build home-manager configuration
home-manager switch --flake ~/.dotfiles#user;
~/.dotfiles/sync-posthook.sh

View file

@ -1,23 +1,7 @@
#!/bin/sh #!/bin/sh
# Automated script to update my non-primary systems # Script to update my flake without
# to be in sync with upstream git repo while # synchronizing configuration
# preserving local edits to dotfiles via git stash
# Relax permissions temporarily so git can work
sudo ~/.dotfiles/soften.sh ~/.dotfiles;
# Stash local edits, pull changes, and re-apply local edits
git stash
git pull
git stash apply
# Permissions for files that should be owned by root
sudo ~/.dotfiles/harden.sh ~/.dotfiles;
# Rebuild system
sudo nixos-rebuild switch --flake ~/.dotfiles#system;
# Install and build home-manager configuration
home-manager --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake ~/.dotfiles#user;
# Update flake
sudo nix flake update ~/.dotfiles;

10
upgrade.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# Script to update system and sync
# Does not pull changes from git
# Update flake
~/.dotfiles/update.sh;
# Synchronize system
~/.dotfiles/sync.sh;

View file

@ -973,6 +973,7 @@ If FULL-MODE is not null, run full krita."
org-agenda-skip-scheduled-if-deadline-is-shown t org-agenda-skip-scheduled-if-deadline-is-shown t
org-agenda-skip-timestamp-if-deadline-is-shown t) org-agenda-skip-timestamp-if-deadline-is-shown t)
;; Custom styles for dates in agenda ;; Custom styles for dates in agenda
(custom-set-faces! (custom-set-faces!
'(org-agenda-date :inherit outline-1 :height 1.15) '(org-agenda-date :inherit outline-1 :height 1.15)
@ -980,7 +981,7 @@ If FULL-MODE is not null, run full krita."
'(org-agenda-date-weekend :ineherit outline-2 :height 1.15) '(org-agenda-date-weekend :ineherit outline-2 :height 1.15)
'(org-agenda-date-weekend-today :inherit outline-4 :height 1.15) '(org-agenda-date-weekend-today :inherit outline-4 :height 1.15)
'(org-super-agenda-header :inherit custom-button :weight bold :height 1.05) '(org-super-agenda-header :inherit custom-button :weight bold :height 1.05)
'(link :foreground unspecified :underline nil :background "#46354a") `(link :foreground unspecified :underline nil :background ,(nth 1 (nth 7 doom-themes--colors)))
'(org-link :foreground unspecified) '(org-link :foreground unspecified)
) )

View file

@ -1130,6 +1130,7 @@ On Wayland, EAF doesn't work.
org-agenda-skip-scheduled-if-deadline-is-shown t org-agenda-skip-scheduled-if-deadline-is-shown t
org-agenda-skip-timestamp-if-deadline-is-shown t) org-agenda-skip-timestamp-if-deadline-is-shown t)
;; Custom styles for dates in agenda ;; Custom styles for dates in agenda
(custom-set-faces! (custom-set-faces!
'(org-agenda-date :inherit outline-1 :height 1.15) '(org-agenda-date :inherit outline-1 :height 1.15)
@ -1137,7 +1138,7 @@ On Wayland, EAF doesn't work.
'(org-agenda-date-weekend :ineherit outline-2 :height 1.15) '(org-agenda-date-weekend :ineherit outline-2 :height 1.15)
'(org-agenda-date-weekend-today :inherit outline-4 :height 1.15) '(org-agenda-date-weekend-today :inherit outline-4 :height 1.15)
'(org-super-agenda-header :inherit custom-button :weight bold :height 1.05) '(org-super-agenda-header :inherit custom-button :weight bold :height 1.05)
'(link :foreground unspecified :underline nil :background "#46354a") `(link :foreground unspecified :underline nil :background ,(nth 1 (nth 7 doom-themes--colors)))
'(org-link :foreground unspecified) '(org-link :foreground unspecified)
) )
@ -1180,17 +1181,6 @@ On Wayland, EAF doesn't work.
#+END_SRC #+END_SRC
#+RESULTS:
| Teaching.p | () | nil | nil | :ascent | center |
| Family.s | () | nil | nil | :ascent | center |
| Producer.p | () | nil | nil | :ascent | center |
| Bard.p | () | nil | nil | :ascent | center |
| Stories.s | () | nil | nil | :ascent | center |
| Author.p | () | nil | nil | :ascent | center |
| Gamedev.s | () | nil | nil | :ascent | center |
| Knowledge.p | () | nil | nil | :ascent | center |
| Personal.p | () | nil | nil | :ascent | center |
*** Org Agenda Convenience Functions *** Org Agenda Convenience Functions
#+BEGIN_SRC emacs-lisp :tangle config.el #+BEGIN_SRC emacs-lisp :tangle config.el
(defun org-categorize-by-roam-db-on-save () (defun org-categorize-by-roam-db-on-save ()

View file

@ -1,212 +0,0 @@
{ pkgs, userSettings, ... }:
let
# This sets up my "phoenix" script with my configuration paths
# =phoenix= is just my wrapper script for easier access to nix/nixos commands
myPhoenixScript = ''
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
FRAMES="/ | \\ -"
function non_blocking_wait {
PID=$1
if [ ! -d "/proc/$PID" ]; then
wait $PID
CODE=$?
else
CODE=127
fi
return $CODE
}
function animate_msg {
pid=$!;
while ps -p $pid > /dev/null;
do
for frame in $FRAMES;
do
printf "\r$frame $1";
sleep 0.2;
done
non_blocking_wait $pid;
status=$?;
done
if [ $status = 0 ]; then
printf "\r$GREEN$NC $1$GREEN [Success!]$NC";
else
printf "\r$RED×$NC $1$RED [Failed!]$NC";
fi
printf "\n"
}
function sync_system {
echo -e "$ORANGE### Syncing system configuration ###$NC"
pushd ''+userSettings.dotfilesDir+'' &> /dev/null;
if [ "$1" = "verbose" ]; then
echo "Syncing system configuration (stack traces will be shown):"
sudo systemd-run --no-ask-password --uid=0 --system --scope -p MemoryLimit=16000M -p CPUQuota=60% nixos-rebuild switch --flake .#system --show-trace;
else
sudo bash -c '
RED="\033[0;31m";
GREEN="\033[0;32m";
NC="\033[0m"
FRAMES="/ | \\ -";
systemd-run --no-ask-password --uid=0 --system --scope -p MemoryLimit=16000M -p CPUQuota=60% nixos-rebuild switch --flake .#system &> /dev/null &
pid=$!;
while ps -p $pid > /dev/null;
do
for frame in $FRAMES;
do
printf "\r$frame Syncing system configuration...";
sleep 0.2;
done
if [ ! -d "/proc/$pid" ]; then
wait $pid
status=$?
else
status=127
fi
done
if [ $status = 0 ]; then
printf "\r$GREEN$NC Syncing system configuration...$GREEN [Success!]$NC";
else
printf "\r$RED×$NC Syncing system configuration...$RED [Failed!]$NC";
fi
printf "\n"'
fi
popd &> /dev/null;
echo -e "$ORANGE### System configuration sync finished ###$NC"
}
function sync_user {
echo -e "$BLUE### Syncing user configuration ###$NC"
pushd ''+userSettings.dotfilesDir+'' &> /dev/null;
if [ "$1" = "verbose" ]; then
echo "Syncing user configuration (stack traces will be shown):"
echo "Running home-manager switch --flake .#user --show-trace"
systemd-run --no-ask-password --uid=1000 --user --scope -p MemoryLimit=16000M -p CPUQuota=60% home-manager switch --flake .#user --show-trace;
which xmobar &> /dev/null && echo "Killing old xmobar instances" && echo "Running killall xmobar" && killall xmobar &> /dev/null;
which xmonad &> /dev/null && echo "Recompiling xmonad" && echo "Running xmonad --recompile && xmonad --restart" && xmonad --recompile && xmonad --restart;
which emacsclient &> /dev/null && echo "Reloading emacs stylix theme" && echo "Running emacsclient --no-wait --eval \"(load-theme 'doom-stylix t nil)\"" && emacsclient --no-wait --eval "(load-theme 'doom-stylix t nil)";
[ -f ~/.fehbg-stylix ] &> /dev/null && echo "Reapplying background from stylix via feh" && echo "Running ~/.fehbg-stylix" && ~/.fehbg-stylix;
[ -f ~/.swaybg-stylix ] &> /dev/null && echo "Reapplying background from stylix via swaybg" && echo "Running ~/.swaybg-stylix" && ~/.swaybg-stylix;
else
systemd-run --no-ask-password --uid=1000 --user --scope -p MemoryLimit=16000M -p CPUQuota=60% home-manager switch --flake .#user &> /dev/null &
animate_msg "Syncing user configuration..."
which xmobar &> /dev/null && killall xmobar &> /dev/null &
which xmonad &> /dev/null && xmonad --recompile &> /dev/null &
animate_msg "Refreshing xmonad..."
which emacsclient &> /dev/null && emacsclient --no-wait --eval "(load-theme 'doom-stylix t nil)" &> /dev/null &
animate_msg "Reloading stylix theme..."
[ -f ~/.fehbg-stylix ] &> /dev/null && ~/.fehbg-stylix &> /dev/null &
[ -f ~/.swaybg-stylix ] &> /dev/null && ~/.swaybg-stylix &> /dev/null &
fi
popd &> /dev/null;
echo -e "$BLUE### User configuration sync finished ###$NC"
}
function update_flake {
echo -e "$CYAN### Updating flake and other package managers$NC";
pushd ''+userSettings.dotfilesDir+'' &> /dev/null;
if [ "$1" = "verbose" ]; then
echo "Updating flake inputs";
echo "Running nix flake update";
nix flake update;
if [ -d ~/.emacs.d/eaf/app/browser ] &> /dev/null;
then
echo "Updating npm dependencies for eaf"
echo "Navigating to ~/.emacs.d/eaf/app/browser"
pushd ~/.emacs.d/eaf/app/browser;
echo "Running rm package*.json";
rm package*.json;
echo "Running npm install darkreader @mozilla/readability";
npm install darkreader @mozilla/readability;
echo "Running rm package*.json";
rm package*.json;
echo "Returning to ''+userSettings.dotfilesDir+''"
popd &> /dev/null;
fi
echo ""
echo "Updating flatpaks";
echo "Running sudo flatpak update -y";
sudo flatpak update -y;
else
nix flake update &> /dev/null &
animate_msg "Updating flake inputs..."
if [ -d ~/.emacs.d/eaf/app/browser ] &> /dev/null;
then
pushd ~/.emacs.d/eaf/app/browser &> /dev/null;
rm package*.json &> /dev/null;
npm install darkreader @mozilla/readability &> /dev/null &
animate_msg "Updating npm dependencies for eaf...";
rm package*.json &> /dev/null;
popd;
fi
echo "Reqesting authentication for flatpak update.."
sudo bash -c '
RED="\033[0;31m";
GREEN="\033[0;32m";
NC="\033[0m"
FRAMES="/ | \\ -";
flatpak update -y &> /dev/null &
pid=$!;
while ps -p $pid > /dev/null;
do
for frame in $FRAMES;
do
printf "\r$frame Updating flatpaks...";
sleep 0.2;
done
if [ ! -d "/proc/$pid" ]; then
wait $pid
status=$?
else
status=127
fi
done
if [ $status = 0 ]; then
printf "\r$GREEN$NC Updating flatpaks...$GREEN [Success!]$NC";
else
printf "\r$RED×$NC Updating flatpaks...$RED [Failed!]$NC";
fi
printf "\n"'
fi
popd &> /dev/null;
echo -e "$CYAN### Flake and other updates finished ###$NC";
echo -e "Please run$GREEN git$NC diff HEAD flake.lock inside ''+userSettings.dotfilesDir+(" "+'' to see flake input changes";'')+
''}
if [ "$1" = "sync" ]; then
if [ "$#" = 1 ]; then
sync_system;
sync_user;
elif [ "$2" = "user" ]; then
sync_user;
elif [ "$2" = "system" ]; then
sync_system;
else
echo "Please pass 'system' or 'user' if supplying a second argument"
fi
elif [ "$1" = "update" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'update' command has no subcommands (no $2 subcommand)"
fi
update_flake;
elif [ "$1" = "gc" ]; then
if [ "$2" = "full" ]; then
sudo nix-collect-garbage --delete-old;
nix-collect-garbage --delete-old;
elif [ "$2" ]; then
sudo nix-collect-garbage --delete-older-than $2;
nix-collect-garbage --delete-older-than $2;
else
sudo nix-collect-garbage --delete-older-than 30d;
nix-collect-garbage --delete-older-than 30d;
fi
fi
'';
in
{
home.packages = [
(pkgs.writeScriptBin "phoenix" myPhoenixScript)
];
}

View file

@ -37,8 +37,4 @@
'') '')
vim neovim vim neovim
]; ];
imports = [
../bin/phoenix.nix # My nix command wrapper
];
} }