My Nix configuration. Enter at your own risk.
0

Configure Feed

Select the types of activity you want to include in your feed.

dotnix / justfile
2.5 kB 62 lines
1_default: 2 @just --list 3 4# - Defaults to the current hostname. 5# - Will fail if the hostname does not have a valid configuration. 6# 7# Snapshot and install the current configuration. 8install user=shell('whoami') hostname=shell('hostname'): _relock _snapshot (_switch user hostname) 9 10# Install only the Home Manager configuration. 11install-home user=shell('whoami') hostname=shell('hostname'): _relock _snapshot (_switch-home user hostname) 12 13# Read the news. 14news user=shell('whoami') hostname=shell('hostname'): 15 @home-manager news --flake path:.#{{user}}@{{hostname}} 16 17# Update the flake's input and install the current configuration. 18update user=shell('whoami') hostname=shell('hostname'): _update _snapshot (_switch user hostname) 19 20# Abandon current changes and install the previous configuration. 21revert user=shell('whoami') hostname=shell('hostname'): _abandon _relock (_switch user hostname) 22 23_switch user hostname: (_switch-nixos hostname) (_switch-home user hostname) 24 25_switch-nixos hostname: 26 #!/usr/bin/env bash 27 set -euo pipefail 28 if [ ! -f hosts/{{hostname}}/configuration.nix ]; then 29 exit 0 30 fi 31 sudo -v 32 ./scripts/run-quiet "Applying NixOS config for {{hostname}}..." -- \ 33 sudo nixos-rebuild switch --flake path:.#{{hostname}} 34 gum log --level info "Applied NixOS config for {{hostname}}" 35 36# Switch to the Home Manager flake for the given user and hostname. 37_switch-home user hostname: 38 @./scripts/run-quiet "Applying Home Manager config for {{user}}@{{hostname}}..." -- \ 39 home-manager switch --flake path:.#{{user}}@{{hostname}} -b backup 40 @gum log --level info "Applied Home Manager config for {{user}}@{{hostname}}" 41 42_update: 43 @./scripts/run-quiet "Updating flake inputs..." -- nix flake update 44 @gum log --level info "Updated flake inputs" 45 46# Locks any newly-added inputs and prunes removed ones without refetching 47# the already-locked ones. Sidesteps the Lix bug where home-manager's 48# in-process locker refuses to fetch `path:.` for the root flake when it 49# has to lock a freshly-added input mid-switch. 50_relock: 51 @./scripts/run-quiet "Relocking flake inputs..." -- nix flake lock 52 @gum log --level info "Relocked flake inputs" 53 54# Snapshot the repo in its current state. 55_snapshot: 56 @./scripts/run-quiet "Snapshotting repo..." -- jj status 57 @gum log --level info "Snapshotted repo" 58 59# Abandon the current commit 60_abandon: 61 @./scripts/run-quiet "Abandoning current commit..." -- jj abandon 62 @gum log --level info "Abandoned current commit"