nixos-config/user/bin/phoenix.nix

48 lines
1.6 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, username, dotfilesDir, ... }:
2023-05-14 07:18:39 +05:30
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 = ''
if [ "$1" = "sync" ]; then
if [ "$2" != "user" ]; then
pushd ''+dotfilesDir+'';
2023-05-14 07:18:39 +05:30
sudo nixos-rebuild switch --flake .#;
popd;
elif [ "2" != "system" ]; then
pushd ''+dotfilesDir+'';
home-manager switch --flake .#''+username+'';
2023-05-14 07:18:39 +05:30
popd;
2023-06-21 04:01:49 +05:30
which xmobar &> /dev/null && killall xmobar;
which xmonad &> /dev/null && xmonad --recompile && xmonad --restart;
which emacsclient &> /dev/null && emacsclient --no-wait --eval "(load-theme 'doom-stylix t nil)";
[ -f ~/.fehbg-stylix ] &> /dev/null && ~/.fehbg-stylix;
2023-05-14 07:18:39 +05:30
fi
elif [ "$1" = "update" ]; then
pushd ''+dotfilesDir+'';
2023-05-14 07:18:39 +05:30
nix flake update;
popd;
2023-06-21 04:01:49 +05:30
if [ -d ~/.emacs.d/eaf/app/browser ]
then
pushd ~/.emacs.d/eaf/app/browser;
rm package*.json;
npm install darkreader @mozilla/readability && rm package*.json;
popd;
fi
elif [ "$1" = "gc" ]; then
if [ "$2" = "full" ]; then
sudo nix-collect-garbage --delete-old;
elif [ "$2" ]; then
sudo nix-collect-garbage --delete-older-than $2;
else
sudo nix-collect-garbage --delete-older-than 30d;
fi
2023-05-14 07:18:39 +05:30
fi
'';
in
{
home.packages = [
(pkgs.writeScriptBin "phoenix" myPhoenixScript)
];
}