aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2025-12-14 13:01:14 -0800
committerFranck Cuny <franck@fcuny.net>2025-12-14 13:01:14 -0800
commit0520741b8ab872efcabb16ab3abcb0d6aaaa5718 (patch)
tree7156bb80ad72f7c8035dcfca906c4dd98d0d99ac
parentremove duplicated configuration for treefmt/pre-commit (diff)
downloadinfra-0520741b8ab872efcabb16ab3abcb0d6aaaa5718.tar.gz
use `just` (again) instead of custom scripts
Diffstat (limited to '')
-rw-r--r--flake.nix6
-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
-rw-r--r--home/profiles/ssh.nix9
-rw-r--r--home/programs/emacs/default.nix2
-rw-r--r--home/programs/emacs/site-lisp/init-programming.el6
-rw-r--r--justfile52
9 files changed, 73 insertions, 186 deletions
diff --git a/flake.nix b/flake.nix
index 5edd7bb..23d1c44 100644
--- a/flake.nix
+++ b/flake.nix
@@ -252,9 +252,11 @@
inherit (pre-commit-check) shellHook;
buildInputs = pre-commit-check.enabledPackages;
packages = with pkgs; [
- nixos-rebuild
- git
+ _1password-cli
agenix.packages.${system}.default
+ git
+ just
+ nixos-rebuild
];
};
}
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 ✅"
- '')
-]
diff --git a/home/profiles/ssh.nix b/home/profiles/ssh.nix
index 8e39def..f1ef16f 100644
--- a/home/profiles/ssh.nix
+++ b/home/profiles/ssh.nix
@@ -11,6 +11,15 @@
controlPath = "${config.home.homeDirectory}/.ssh/sockets/S.%r@%h:%p";
controlMaster = "auto";
};
+ "rivendell" = {
+ hostname = "192.168.1.114";
+ };
+ "bree" = {
+ hostname = "192.168.1.50";
+ };
+ "argonath" = {
+ hostname = "fcuny.net";
+ };
"github.com" = {
hostname = "github.com";
user = "git";
diff --git a/home/programs/emacs/default.nix b/home/programs/emacs/default.nix
index 99dc608..35a6c47 100644
--- a/home/programs/emacs/default.nix
+++ b/home/programs/emacs/default.nix
@@ -33,6 +33,8 @@ let
jq-mode
json-mode
json-reformat
+ just-mode
+ justl
ledger-mode
magit
marginalia
diff --git a/home/programs/emacs/site-lisp/init-programming.el b/home/programs/emacs/site-lisp/init-programming.el
index 1bad02f..5498647 100644
--- a/home/programs/emacs/site-lisp/init-programming.el
+++ b/home/programs/emacs/site-lisp/init-programming.el
@@ -156,6 +156,12 @@
(use-package jq-mode
:mode "\\.jq\\'")
+(use-package just-mode
+ :ensure t)
+
+(use-package justl
+ :ensure t)
+
(use-package terraform-mode
:mode "\.tf\\'")
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..81bf05f
--- /dev/null
+++ b/justfile
@@ -0,0 +1,52 @@
+# default recipe to display help information
+default:
+ @just --list
+
+# update the flakes
+[group('nix')]
+update-deps:
+ nix flake update --commit-look-file
+
+# check the flake for errors
+[group('nix')]
+check:
+ nix flake check
+
+# format the repository
+[group('nix')]
+fmt:
+ nix fmt
+
+# build the nix-darwin system configuration without switching to it
+[group('darwin')]
+build:
+ @echo "building nix-darwin config..."
+ darwin-rebuild build --flake .
+
+# switch the nix-darwin system configuration
+[group('darwin')]
+switch:
+ @echo "switching to new config..."
+ sudo darwin-rebuild switch --flake .
+
+[group('linux')]
+build-iso:
+ @echo "building an ISO for nixos..."
+ nix build .#nixosConfigurations.iso.config.system.build.isoImage
+
+[group('linux')]
+rbuild hostname:
+ @echo "building {{hostname}} nixos config..."
+ nixos-rebuild build --keep-going --flake ".#{{hostname}}" --target-host {{hostname}} --fast --use-remote-sudo --use-substitutes
+
+[group('linux')]
+rswitch hostname:
+ @echo "switching {{hostname}} to new config..."
+
+# sync agenix key from 1password
+[group('secrets')]
+sync-agenix-key:
+ @echo "copying agenix SSH key from 1password..."
+ mkdir -p ~/.ssh
+ op --account my.1password.com read "op://Private/agenix/private key?ssh-format=openssh" > ~/.ssh/agenix
+ op --account my.1password.com read "op://Private/agenix/public key" > ~/.ssh/agenix.pub