diff --git a/modules/system/phoenix/default.nix b/modules/system/phoenix/default.nix index 70ae27f4..f5a0d97f 100644 --- a/modules/system/phoenix/default.nix +++ b/modules/system/phoenix/default.nix @@ -24,27 +24,46 @@ exit 1 fi if [ "$1" = "sync" ]; then - if [ "$#" = 1 ]; then - exit 0; - fi - elif [ "$1" = "update" ]; then if [ "$#" -gt 1 ]; then - echo "Warning: The 'update' command has no subcommands (no $2 subcommand)"; + echo "Warning: The 'sync' command has no subcommands (no $2 subcommand)"; fi + chown -R 0:0 ${config.systemSettings.dotfilesDir}; + chown -R 0:0 ${config.systemSettings.secretsFlakeDir}; + pushd ${config.systemSettings.dotfilesDir} &> /dev/null; + nix flake update secrets; + nixos-rebuild switch; + exit 0; + popd &> /dev/null; + elif [ "$1" = "update" ]; then pushd ${config.systemSettings.dotfilesDir} &> /dev/null; nix flake update "''${@:2}"; popd &> /dev/null; + if [ "$#" -eq 1 ]; then + pushd ${config.systemSettings.secretsFlakeDir} &> /dev/null; + nix flake update; + popd &> /dev/null; + fi exit 0; elif [ "$1" = "pull" ]; then if [ "$#" -gt 1 ]; then echo "Warning: The 'pull' command has no subcommands (no $2 subcommand)"; fi exit 0; + chown -R $DOAS_USER:users ${config.systemSettings.dotfilesDir}; + chown -R $DOAS_USER:users ${config.systemSettings.secretsFlakeDir}; pushd ${config.systemSettings.dotfilesDir} &> /dev/null; - git stash; - git pull; - git stash apply; + sudo -u $DOAS_USER git stash; + sudo -u $DOAS_USER git pull; + sudo -u $DOAS_USER git stash apply; popd &> /dev/null; + pushd ${config.systemSettings.secretsFlakeDir} &> /dev/null; + sudo -u $DOAS_USER git stash; + sudo -u $DOAS_USER git pull; + sudo -u $DOAS_USER git stash apply; + popd &> /dev/null; + chown -R 0:0 ${config.systemSettings.dotfilesDir}; + chown -R 0:0 ${config.systemSettings.secretsFlakeDir}; + # TODO allow specifying host with $2 in build subcommand elif [ "$1" = "build" ]; then if [ "$#" -gt 1 ]; then echo "Warning: The 'build' command has no subcommands (no $2 subcommand)"; diff --git a/modules/user/shell/default.nix b/modules/user/shell/default.nix index 79daedf0..9e1d714f 100644 --- a/modules/user/shell/default.nix +++ b/modules/user/shell/default.nix @@ -16,6 +16,7 @@ in { syntaxHighlighting.enable = true; enableCompletion = true; shellAliases = { + phoenix = "sudo phoenix"; ls = "eza --icons -l -T -L=1"; cat = "bat"; htop = "btm";