aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-12-27 19:11:20 -0800
committerFranck Cuny <franck@fcuny.net>2024-12-27 19:11:20 -0800
commitdd218232da3ae82fdb93c4fa9e9e8e97a973c45e (patch)
tree7c1359cda4a8cd264f45d4937892f60f7d5f6a6a
parentupdate configuration for treefmt (diff)
downloadinfra-dd218232da3ae82fdb93c4fa9e9e8e97a973c45e.tar.gz
format justfile
-rw-r--r--justfile126
1 files changed, 62 insertions, 64 deletions
diff --git a/justfile b/justfile
index ac8dc64..b6cdc21 100644
--- a/justfile
+++ b/justfile
@@ -1,120 +1,118 @@
SSH_OPTIONS := "-o PubkeyAuthentication=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
-
nixdisk := "vda"
nixaddr := ""
-
hostname := lowercase(`hostname -s`)
default:
@just --list
-[group('nix')]
[doc('update dependencies')]
+[group('nix')]
update-deps:
- nix flake update --commit-lock-file
+ nix flake update --commit-lock-file
-[group('nix')]
[doc('a simple check to ensure the nix configuration is OK')]
+[group('nix')]
test-nix:
- nix flake check
- nix develop -c echo OK
+ nix flake check
+ nix develop -c echo OK
-[group('nix')]
[doc('run various formatting tools')]
+[group('nix')]
fmt:
- nix fmt
+ nix fmt
# Nix Store can contains corrupted entries if the nix store object has been modified unexpectedly.
# This command will verify all the store entries,
-# and we need to fix the corrupted entries manually via `sudo nix store delete <store-path-1> <store-path-2> ...`
-[group('nix')]
+
[doc('verify all the store entries')]
+[group('nix')]
verify-store:
- nix store verify --all
+ nix store verify --all
-[group('nix')]
[doc('garbage collect all unused nix store entries (system-wide and home-manager)')]
+[group('nix')]
gc:
- # garbage collect all unused nix store entries(system-wide)
- sudo nix-collect-garbage --delete-older-than 7d
- # garbage collect all unused nix store entries(for the user - home-manager)
- # https://github.com/NixOS/nix/issues/8508
- nix-collect-garbage --delete-older-than 7d
+ # garbage collect all unused nix store entries(system-wide)
+ sudo nix-collect-garbage --delete-older-than 7d
+ # garbage collect all unused nix store entries(for the user - home-manager)
+ # https://github.com/NixOS/nix/issues/8508
+ nix-collect-garbage --delete-older-than 7d
-[group('nix')]
[doc('list recent version')]
+[group('nix')]
history:
- nix profile history --profile /nix/var/nix/profiles/system
+ nix profile history --profile /nix/var/nix/profiles/system
-[group('nix')]
[doc('show all the auto gc roots in the nix store')]
+[group('nix')]
gcroot:
- ls -al /nix/var/nix/gcroots/auto/
+ ls -al /nix/var/nix/gcroots/auto/
-[group('secrets')]
[doc('edit a secret')]
+[group('secrets')]
[macos]
secrets +args:
- #!/usr/bin/env fish
- cd secrets && agenix -e {{args}}.age -i (op read "op://Personal/nixos/private key?ssh-format=openssh"|psub)
+ #!/usr/bin/env fish
+ cd secrets && agenix -e {{ args }}.age -i (op read "op://Personal/nixos/private key?ssh-format=openssh"|psub)
-[group('machines')]
[doc('build the configuration for the current host')]
+[group('machines')]
[macos]
build:
- darwin-rebuild build --flake .#{{hostname}}
+ darwin-rebuild build --flake .#{{ hostname }}
-[group('machines')]
[doc('switch the configuration for the current host')]
+[group('machines')]
[macos]
switch:
- darwin-rebuild switch --flake .#{{hostname}}
+ darwin-rebuild switch --flake .#{{ hostname }}
-[group('machines')]
[doc('build the configuration for the current host')]
+[group('machines')]
[linux]
build:
- nixos-rebuild build --flake .#{{hostname}}
+ nixos-rebuild build --flake .#{{ hostname }}
-[group('machines')]
[doc('switch the configuration for the current host')]
+[group('machines')]
[linux]
switch:
- nixos-rebuild switch --flake .#{{hostname}}
+ nixos-rebuild switch --flake .#{{ hostname }}
[group('vm')]
vm-bootstrap:
- #!/usr/bin/env bash
- set -euxo pipefail
- ssh {{SSH_OPTIONS}} root@{{nixaddr}} " \
- parted /dev/{{nixdisk}} -- mklabel gpt; \
- parted /dev/{{nixdisk}} -- mkpart primary 512MB 100%; \
- parted /dev/{{nixdisk}} -- mkpart ESP fat32 1MB 512MB; \
- parted /dev/{{nixdisk}} -- set 2 esp on; \
- sleep 1; \
- mkfs.ext4 -L nixos /dev/{{nixdisk}}1; \
- mkfs.fat -F 32 -n boot /dev/{{nixdisk}}2; \
- sleep 1; \
- mount /dev/disk/by-label/nixos /mnt; \
- mkdir -p /mnt/boot; \
- mount /dev/disk/by-label/boot /mnt/boot; \
- nixos-generate-config --root /mnt; \
- sed --in-place '/system\.stateVersion = .*/a \
- nix.extraOptions = \"experimental-features = nix-command flakes\";\n \
- services.openssh.enable = true;\n \
- services.openssh.settings.PasswordAuthentication = true;\n \
- services.openssh.settings.PermitRootLogin = \"yes\";\n \
- users.users.root.initialPassword = \"root\";\n \
- ' /mnt/etc/nixos/configuration.nix; \
- nixos-install --no-root-passwd && reboot; \
- "
+ #!/usr/bin/env bash
+ set -euxo pipefail
+ ssh {{ SSH_OPTIONS }} root@{{ nixaddr }} " \
+ parted /dev/{{ nixdisk }} -- mklabel gpt; \
+ parted /dev/{{ nixdisk }} -- mkpart primary 512MB 100%; \
+ parted /dev/{{ nixdisk }} -- mkpart ESP fat32 1MB 512MB; \
+ parted /dev/{{ nixdisk }} -- set 2 esp on; \
+ sleep 1; \
+ mkfs.ext4 -L nixos /dev/{{ nixdisk }}1; \
+ mkfs.fat -F 32 -n boot /dev/{{ nixdisk }}2; \
+ sleep 1; \
+ mount /dev/disk/by-label/nixos /mnt; \
+ mkdir -p /mnt/boot; \
+ mount /dev/disk/by-label/boot /mnt/boot; \
+ nixos-generate-config --root /mnt; \
+ sed --in-place '/system\.stateVersion = .*/a \
+ nix.extraOptions = \"experimental-features = nix-command flakes\";\n \
+ services.openssh.enable = true;\n \
+ services.openssh.settings.PasswordAuthentication = true;\n \
+ services.openssh.settings.PermitRootLogin = \"yes\";\n \
+ users.users.root.initialPassword = \"root\";\n \
+ ' /mnt/etc/nixos/configuration.nix; \
+ nixos-install --no-root-passwd && reboot; \
+ "
[group('vm')]
vm-copy:
- #!/usr/bin/env fish
- rsync -av -e 'ssh {{SSH_OPTIONS}}' \
- --exclude='.git/' \
- --exclude='result' \
- --exclude='.direnv/' \
- --rsync-path="sudo rsync" \
- $(dirname justfile)/ {{nixaddr}}:/nix-config
+ #!/usr/bin/env fish
+ rsync -av -e 'ssh {{ SSH_OPTIONS }}' \
+ --exclude='.git/' \
+ --exclude='result' \
+ --exclude='.direnv/' \
+ --rsync-path="sudo rsync" \
+ $(dirname justfile)/ {{ nixaddr }}:/nix-config