Nix Flakes configuration for MacOS, NixOS and WSL
1hostname := "$HOSTNAME"
2
3# default action: list actions
4default:
5 @just --list
6
7# Rebuild the system
8switch hostname=hostname:
9 #!/usr/bin/env sh
10 if [[ "$OSTYPE" == "darwin"* ]]; then \
11 sudo darwin-rebuild switch --flake .#{{ hostname }}; \
12 else \
13 sudo nixos-rebuild switch --flake .#{{ hostname }} --impure; \
14 fi;
15
16# Build a new configuration
17boot hostname=hostname:
18 #!/usr/bin/env sh
19 if [[ "$OSTYPE" == "darwin"* ]]; then \
20 @echo "This is not possible to do it on MacOS."
21 else \
22 sudo nixos-rebuild boot --flake .#{{ hostname }} --impure; \
23 fi;
24
25# Format code
26format:
27 nix fmt
28
29# Update dependencies
30update:
31 nix flake update
32
33# Cleanup all unused packages and generations
34clean:
35 nix-store --optimize
36 nix-collect-garbage -d
37 sudo nix-collect-garbage -d
38
39# Print size of the nix store
40size:
41 du -sh /nix/store