mirror of
https://github.com/davegallant/nix-config
synced 2025-08-05 14:43:39 +00:00
Check arch in justfile
This commit is contained in:
18
README.md
18
README.md
@@ -11,16 +11,10 @@ The configuration is very specific to my own machines and setup, but it may be a
|
|||||||
|
|
||||||
Recipes are stored in a justfile. [just](https://github.com/casey/just) is required.
|
Recipes are stored in a justfile. [just](https://github.com/casey/just) is required.
|
||||||
|
|
||||||
To run a NixOS rebuild:
|
To run a rebuild:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
just build-linux
|
just rebuild
|
||||||
```
|
|
||||||
|
|
||||||
To run a macOS rebuild:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
just build-mac
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
@@ -38,13 +32,7 @@ If there are updates, they should be reflected in [flake.lock](./flake.lock).
|
|||||||
To rollback to the previous generation:
|
To rollback to the previous generation:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
just rollback-linux
|
just rollback
|
||||||
```
|
|
||||||
|
|
||||||
or on macOS:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
just rollback-mac
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Garbage collection
|
## Garbage collection
|
||||||
|
18
justfile
18
justfile
@@ -1,21 +1,15 @@
|
|||||||
set export
|
set export
|
||||||
|
|
||||||
config := "machines/$(hostname)/configuration.nix"
|
config := "machines/$(hostname)/configuration.nix"
|
||||||
arch := `uname s`
|
arch := `uname -s`
|
||||||
|
|
||||||
cmd := if arch == "Linux" { "nixos-rebuild" } else { "darwin-rebuild" }
|
cmd := if arch == "Linux" { "nixos-rebuild --use-remote-sudo" } else { "darwin-rebuild" }
|
||||||
|
|
||||||
build-linux:
|
rebuild:
|
||||||
nixos-rebuild --use-remote-sudo -I nixos-config=$config switch --flake .
|
$cmd switch --flake . -I nixos-config=$config
|
||||||
|
|
||||||
build-mac:
|
rollback:
|
||||||
darwin-rebuild switch -I nixos-config=$config --flake .
|
$cmd switch --rollback -I nixos-config=$config
|
||||||
|
|
||||||
rollback-linux:
|
|
||||||
nixos-rebuild --use-remote-sudo switch --rollback -I nixos-config=$config
|
|
||||||
|
|
||||||
rollback-mac:
|
|
||||||
darwin-rebuild --rollback -I nixos-config=$config
|
|
||||||
|
|
||||||
update:
|
update:
|
||||||
@./nix-flake-update.sh
|
@./nix-flake-update.sh
|
||||||
|
@@ -2,18 +2,9 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
arch=$(uname -s)
|
|
||||||
|
|
||||||
git pull
|
git pull
|
||||||
update_msg=$(nix flake update 2>&1 | grep -v 'warning:')
|
update_msg=$(nix flake update 2>&1 | grep -v 'warning:')
|
||||||
if [[ $arch == "Linux" ]]; then
|
just rebuild
|
||||||
just build-linux
|
|
||||||
elif [[ $arch == "Darwin" ]]; then
|
|
||||||
just build-mac
|
|
||||||
else
|
|
||||||
echo "Unsupported OS: $arch"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
git add .
|
git add .
|
||||||
git commit -S -m "nix flake update: $(TZ=UTC date '+%Y-%m-%d %H:%M:%S %Z')
|
git commit -S -m "nix flake update: $(TZ=UTC date '+%Y-%m-%d %H:%M:%S %Z')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user