nixcfg/nixosModules/scripts/hoenn/default.nix

40 lines
1.1 KiB
Nix
Raw Normal View History

2024-05-02 09:05:00 -04:00
{
pkgs,
lib,
config,
...
}: let
hoenn = pkgs.writeShellScriptBin "hoenn" ''
FLAKE=''${FLAKE:-"github:alyraffauf/nixcfg"}
HOST=''${HOST:-${config.networking.hostName}}
GIT=''${GIT:-"https://github.com/alyraffauf/nixcfg.git"}
2024-05-02 09:05:00 -04:00
if [ "$1" = "sync" ]; then
if [ "$2" == "" ] || [ "$2" == "now" ]; then
sudo ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake $FLAKE#$HOST
2024-05-02 09:05:00 -04:00
exit 0;
elif [ "$2" == "boot" ]; then
bin/sudo ${pkgs.nixos-rebuild}/bin/nixos-rebuild boot --flake $FLAKE#$HOST
2024-05-02 09:05:00 -04:00
exit 0;
fi
elif [ "$1" == "gc" ]; then
sudo ${pkgs.nix}/bin/nix-collect-garbage -d
2024-05-02 09:05:00 -04:00
exit 0;
elif [ "$1" == "clone" ]; then
${pkgs.git}/bin/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 {
# Packages that should be installed to the user profile.
environment.systemPackages = with pkgs; [hoenn];
};
}