aboutsummaryrefslogtreecommitdiff
path: root/flake
diff options
context:
space:
mode:
Diffstat (limited to 'flake')
-rw-r--r--flake/scripts/common.nix4
-rw-r--r--flake/scripts/darwin.nix29
-rw-r--r--flake/scripts/default.nix17
-rw-r--r--flake/scripts/remote.nix134
4 files changed, 0 insertions, 184 deletions
diff --git a/flake/scripts/common.nix b/flake/scripts/common.nix
deleted file mode 100644
index 931480c..0000000
--- a/flake/scripts/common.nix
+++ /dev/null
@@ -1,4 +0,0 @@
-{ pkgs }:
-[
- (pkgs.writeScriptBin "update-deps" "nix flake update --commit-lock-file")
-]
diff --git a/flake/scripts/darwin.nix b/flake/scripts/darwin.nix
deleted file mode 100644
index abf6eac..0000000
--- a/flake/scripts/darwin.nix
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- pkgs,
- system,
- inputs,
-}:
-[
- (pkgs.writeScriptBin "nbuild" ''
- set -e
- echo "> Running darwin-rebuild build..."
- ${inputs.darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild build --flake .
- echo "> darwin-rebuild build was successful ✅"
- '')
-
- (pkgs.writeScriptBin "nswitch" ''
- set -e
- echo "> Running darwin-rebuild switch..."
- ${inputs.darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .
- echo "> macOS config was successfully applied 🚀"
- '')
-
- (pkgs.writeScriptBin "sync-agenix-key" ''
- set -e
- echo "> Copying agenix SSH key from 1password ..."
- mkdir -p ~/.ssh
- ${pkgs._1password-cli}/bin/op --account my.1password.com read "op://Private/agenix/private key?ssh-format=openssh" > ~/.ssh/agenix
- ${pkgs._1password-cli}/bin/op --account my.1password.com read "op://Private/agenix/public key" > ~/.ssh/agenix.pub
- echo "> agenix SSH key copied successfully 🔐"
- '')
-]
diff --git a/flake/scripts/default.nix b/flake/scripts/default.nix
deleted file mode 100644
index cf105f1..0000000
--- a/flake/scripts/default.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- pkgs,
- system,
- inputs,
-}:
-let
- common = import ./common.nix { inherit pkgs; };
- darwin = import ./darwin.nix { inherit pkgs system inputs; };
- remote = import ./remote.nix { inherit pkgs; };
-in
-{
- common = common;
- remote = remote;
- darwin = if pkgs.lib.hasSuffix "darwin" system then darwin else [ ];
-
- all = common ++ remote ++ (if pkgs.lib.hasSuffix "darwin" system then darwin else [ ]);
-}
diff --git a/flake/scripts/remote.nix b/flake/scripts/remote.nix
deleted file mode 100644
index c96aa81..0000000
--- a/flake/scripts/remote.nix
+++ /dev/null
@@ -1,134 +0,0 @@
-{
- pkgs,
-}:
-[
- (pkgs.writeScriptBin "rbuild" ''
- #!${pkgs.bash}/bin/bash
- set -e
-
- # Check if host argument is provided
- if [ -z "$1" ]; then
- echo "❌ Error: Please specify a host"
- echo "Usage: rbuild <hostname>"
- echo "Example: rbuild rivendell"
- exit 1
- fi
-
- HOST="$1"
- echo "> Running nixos-rebuild build for $HOST..."
-
- ${pkgs.nixos-rebuild}/bin/nixos-rebuild build \
- --keep-going \
- --flake ".#$HOST" \
- --target-host "$HOST" \
- --fast \
- --use-remote-sudo \
- --use-substitutes
-
- echo "> nixos-rebuild build for $HOST was successful ✅"
- '')
-
- (pkgs.writeScriptBin "rswitch" ''
- #!${pkgs.bash}/bin/bash
- set -e
-
- # Check if host argument is provided
- if [ -z "$1" ]; then
- echo "❌ Error: Please specify a host"
- echo "Usage: rswitch <hostname>"
- echo "Example: rswitch rivendell"
- exit 1
- fi
-
- HOST="$1"
- echo "> Running nixos-rebuild switch for $HOST..."
-
- ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch \
- --keep-going \
- --flake ".#$HOST" \
- --target-host "$HOST" \
- --fast \
- --use-remote-sudo \
- --use-substitutes
-
- echo "> NixOS config was successfully applied to $HOST 🚀"
- '')
-
- (pkgs.writeScriptBin "rdeploy" ''
- #!${pkgs.bash}/bin/bash
- set -e
-
- # Check if host argument is provided
- if [ -z "$1" ]; then
- echo "❌ Error: Please specify a host"
- echo "Usage: rdeploy <hostname>"
- echo "Example: rdeploy rivendell"
- exit 1
- fi
-
- HOST="$1"
- echo "> Deploying NixOS configuration to $HOST..."
- echo ""
-
- # First build
- echo "📦 Step 1/2: Building configuration..."
- ${pkgs.nixos-rebuild}/bin/nixos-rebuild build \
- --keep-going \
- --flake ".#$HOST" \
- --target-host "$HOST" \
- --fast \
- --use-remote-sudo \
- --use-substitutes
-
- echo ""
- echo "🔄 Step 2/2: Switching configuration..."
- ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch \
- --keep-going \
- --flake ".#$HOST" \
- --target-host "$HOST" \
- --fast \
- --use-remote-sudo \
- --use-substitutes
-
- echo ""
- echo "> NixOS deployment to $HOST completed successfully! 🎉"
- '')
-
- (pkgs.writeScriptBin "rhosts" ''
- #!${pkgs.bash}/bin/bash
- echo "> Available NixOS hosts in your flake:"
- echo ""
-
- # This attempts to list nixosConfigurations from the flake
- # You might need to adjust this based on your flake structure
- nix flake show --json 2>/dev/null | \
- ${pkgs.jq}/bin/jq -r '.nixosConfigurations | keys[]' 2>/dev/null || \
- echo "Unable to list hosts automatically. Check your flake/hosts.nix"
- '')
-
- (pkgs.writeScriptBin "rtest" ''
- #!${pkgs.bash}/bin/bash
- set -e
-
- # Check if host argument is provided
- if [ -z "$1" ]; then
- echo "❌ Error: Please specify a host"
- echo "Usage: rtest <hostname>"
- echo "Example: rtest rivendell"
- exit 1
- fi
-
- HOST="$1"
- echo "> Running dry-run build for $HOST..."
-
- ${pkgs.nixos-rebuild}/bin/nixos-rebuild dry-build \
- --keep-going \
- --flake ".#$HOST" \
- --target-host "$HOST" \
- --fast \
- --use-remote-sudo \
- --use-substitutes
-
- echo "> Dry-run build for $HOST completed ✅"
- '')
-]