diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index a15c294b..44b2f57a 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -56,6 +56,9 @@ podman.enable = true; virt-manager.enable = true; }; + scripts = { + hoenn.enable = true; + }; services = { syncthing.enable = true; tailscale.enable = true; diff --git a/nixosModules/default.nix b/nixosModules/default.nix index 54a9fdc8..a20f10c4 100644 --- a/nixosModules/default.nix +++ b/nixosModules/default.nix @@ -3,5 +3,5 @@ pkgs, ... }: { - imports = [./apps ./containers ./desktop ./services ./system ./user]; + imports = [./apps ./containers ./desktop ./scripts ./services ./system ./user]; } diff --git a/nixosModules/scripts/default.nix b/nixosModules/scripts/default.nix new file mode 100644 index 00000000..feefc356 --- /dev/null +++ b/nixosModules/scripts/default.nix @@ -0,0 +1,8 @@ +{ + pkgs, + lib, + config, + ... +}: { + imports = [./hoenn]; +} diff --git a/nixosModules/scripts/hoenn/default.nix b/nixosModules/scripts/hoenn/default.nix new file mode 100644 index 00000000..2538c33c --- /dev/null +++ b/nixosModules/scripts/hoenn/default.nix @@ -0,0 +1,39 @@ +{ + pkgs, + lib, + config, + ... +}: let + hoenn = pkgs.writeShellScriptBin "hoenn" '' + FLAKE="github:alyraffauf/nixcfg" + HOST=${config.networking.hostName} + FLAKE_SRC="https://github.com/alyraffauf/nixcfg.git" + + if [ "$1" = "sync" ]; then + if [ "$2" == "" ] || [ "$2" == "now" ]; then + ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake $FLAKE#$HOST + exit 0; + elif [ "$2" == "boot" ]; then + ${pkgs.nixos-rebuild}/bin/nixos-rebuild boot --flake $FLAKE#$HOST + exit 0; + fi + elif [ "$1" == "gc" ]; then + ${pkgs.nix}/bin/nix-collect-garbage -d + exit 0; + elif [ "$1" == "clone" ]; then + ${pkgs.git}/bin/git clone $FLAKE_SRC + cd nixcfg + exit 0; + fi + ''; +in { + options = { + alyraffauf.scripts.hoenn.enable = + lib.mkEnableOption "Enable \hoenn system configuration script"; + }; + + config = lib.mkIf config.alyraffauf.scripts.hoenn.enable { + # Packages that should be installed to the user profile. + environment.systemPackages = with pkgs; [hoenn]; + }; +}