2024-05-02 09:05:00 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
hoenn = pkgs.writeShellScriptBin "hoenn" ''
|
2024-05-02 20:52:08 -04:00
|
|
|
FLAKE=''${2:-"github:alyraffauf/nixcfg"}
|
2024-05-02 19:57:29 -04:00
|
|
|
HOST=''${HOST:-${config.networking.hostName}}
|
2024-05-02 20:52:08 -04:00
|
|
|
GIT=https://''${FLAKE//:/\.com\/}.git
|
2024-05-02 09:05:00 -04:00
|
|
|
|
2024-05-02 20:52:08 -04:00
|
|
|
if [ "$1" == "sync" ]; then
|
2024-05-05 19:44:51 -04:00
|
|
|
sudo ${lib.getExe pkgs.nixos-rebuild} switch --flake $FLAKE#$HOST
|
2024-05-02 20:52:08 -04:00
|
|
|
exit 0;
|
|
|
|
elif [ "$1" == "boot" ]; then
|
2024-05-05 19:44:51 -04:00
|
|
|
sudo ${lib.getExe pkgs.nixos-rebuild} boot --flake $FLAKE#$HOST
|
2024-05-02 20:52:08 -04:00
|
|
|
exit 0;
|
2024-05-02 09:05:00 -04:00
|
|
|
elif [ "$1" == "gc" ]; then
|
2024-05-05 19:44:51 -04:00
|
|
|
sudo ${lib.getExe' pkgs.nix "nix-collect-garbage"} -d
|
2024-05-02 09:05:00 -04:00
|
|
|
exit 0;
|
|
|
|
elif [ "$1" == "clone" ]; then
|
2024-05-05 19:44:51 -04:00
|
|
|
${lib.getExe pkgs.git} clone $GIT
|
2024-05-02 09:05:00 -04:00
|
|
|
cd nixcfg
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
alyraffauf.scripts.hoenn.enable =
|
2024-05-02 14:39:55 -04:00
|
|
|
lib.mkEnableOption "Enable hoenn system configuration script";
|
2024-05-02 09:05:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf config.alyraffauf.scripts.hoenn.enable {
|
|
|
|
environment.systemPackages = with pkgs; [hoenn];
|
|
|
|
};
|
|
|
|
}
|