-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
66 lines (49 loc) · 1.69 KB
/
justfile
File metadata and controls
66 lines (49 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
hostname := `if [ "$(uname)" = "Darwin" ]; then cat ~/.hostname 2> /dev/null || scutil --get ComputerName; else cat /proc/sys/kernel/hostname; fi`
_default:
just --list
_pull:
git pull
git checkout main
pre-commit: fmt
fmt:
nix run nixpkgs#alejandra -- .
_nixpkgs_hash OFFSET='3day':
#!/usr/bin/env nu
# bump nixpkgs-unstable
let offset = (date now) - {{OFFSET}}
let query = {until: $offset, sha: "nixos-unstable", per_page: 1, page: 1}
let hash = http get $"https://api.github.com/repos/nixos/nixpkgs/commits?($query | url build-query)" | first | get sha
print $hash
_update: _pull
#!/usr/bin/env bash
set -euxo pipefail
hash=$(just _nixpkgs_hash)
sed -i "s!nixpkgs-unstable.url =.*!nixpkgs-unstable.url = \"github:nixos/nixpkgs/${hash}\";!" flake.nix
update: _pull _update
# update the flake
nix flake update
git restore --staged . || true
git add flake.nix flake.lock
# commit our update
git commit -m "flake: update inputs"
switch-hm: _pull
home-manager switch --flake '.#{{hostname}}'
switch-nixos: _pull
sudo nixos-rebuild switch --flake '.#{{hostname}}'
switch-darwin: _pull
nix run nix-darwin -- build --flake '.#{{hostname}}'
ls -l result/sw/bin/nix
echo 'Waiting for Full Disk Access...' && read
sudo result/activate
switch:
#!/usr/bin/env bash
set -euxo pipefail
if [ -d "$HOME/.local/state/home-manager" ]; then
just switch-hm
fi
if [ "$(uname)" = "Darwin" ] && grep "darwinSystem" flake.nix | grep -q "{{hostname}}" flake.nix; then
just switch-darwin
fi
if [ "$(uname)" = "Linux" ] && grep -q "NixOS" /etc/os-release; then
just switch-nixos
fi