Experimental arbitrary directory dotfiles install + re-added simplified phoenix wrapper script + updated readme with these changes

This commit is contained in:
Emmet 2024-04-14 09:40:46 -05:00
parent 3148ea5ab7
commit 7c457d29de
14 changed files with 189 additions and 46 deletions

View file

@ -11,6 +11,8 @@ imports = [ import1.nix
My system-level Nix modules are organized into this directory:
- [[./hardware-configuration.nix][hardware-configuration]] - Default hardware config generated for my system
- [[./bin][bin]] - My own scripts
- [[./bin/phoenix.nix][phoenix]] - My nix command wrapper
- [[./app][app]] - Necessary system-level configuration to get various apps working
- [[./hardware][hardware]] - Hardware configurations I may need to use
- [[./security][security]] - System-level security stuff
@ -18,6 +20,7 @@ My system-level Nix modules are organized into this directory:
- [[./wm][wm]] - Necessary system-level configuration to get various window managers, wayland compositors, and/or desktop environments working
** Variables imported from flake.nix
# TODO update this
Variables can be imported from [[../flake.nix][flake.nix]] by setting the =specialArgs= block inside the flake (see [[../flake.nix][my flake]] for more details). This allows variables to merely be managed in one place ([[../flake.nix][flake.nix]]) rather than having to manage them in multiple locations.
I currently import the following variables to the system config:

73
system/bin/phoenix.nix Normal file
View file

@ -0,0 +1,73 @@
{ pkgs, userSettings, ... }:
let myScript = ''
if [ "$1" = "sync" ]; then
if [ "$#" = 1 ]; then
''+userSettings.dotfilesDir+''/sync.sh;
exit 0;
elif [ "$2" = "user" ]; then
''+userSettings.dotfilesDir+''/sync-user.sh;
exit 0;
elif [ "$2" = "system" ]; then
''+userSettings.dotfilesDir+''/sync-system.sh;
exit 0;
else
echo "Please pass 'system' or 'user' if supplying a second argument"
fi
elif [ "$1" = "refresh" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'refresh' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/sync-posthook.sh;
exit 0;
elif [ "$1" = "update" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'update' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/update.sh;
exit 0;
elif [ "$1" = "upgrade" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'update' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/upgrade.sh;
exit 0;
elif [ "$1" = "pull" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'upgrade' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/pull.sh;
exit 0;
elif [ "$1" = "harden" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'harden' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/harden.sh;
exit 0;
elif [ "$1" = "soften" ]; then
if [ "$#" -gt 1 ]; then
echo "Warning: The 'soften' command has no subcommands (no $2 subcommand)";
fi
''+userSettings.dotfilesDir+''/soften.sh;
exit 0;
elif [ "$1" = "gc" ]; then
if [ "$#" -gt 2 ]; then
echo "Warning: The 'gc' command only accepts one argument (collect_older_than)";
fi
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
{
environment.systemPackages = [
(pkgs.writeScriptBin "phoenix" myScript)
];
}