summaryrefslogtreecommitdiff
path: root/justfile
blob: 05fecc305bb108b2655c53a239536452a3c37f3b (plain) (blame)
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
hostname := shell("hostname | sed 's/\\..*//' | tr '[:upper:]' '[:lower:]'")

default:
  @just --list

action target action:
  git add . && rui --allow-unfree --allow-insecure {{target}} {{action}} -- --impure

build target=hostname:
  @uname | \
    grep -q Darwin \
    && just darwin_action {{target}} build \
    || just action {{target}} build

darwin_action target action:
  nix run nix-darwin -- {{action}} --flake .#{{target}}

switch target=hostname:
  @uname | \
    grep -q Darwin \
    && just darwin_action {{target}} switch \
    || just action {{target}} switch

news user='ebisu':
  rui home news --user {{user}} -- --impure

check:
  nix flake check

fmt:
  treefmt

push message:
  git add . && git commit -m "{{message}}" && git push origin main

commit message:
  git add . && git commit -m "{{message}}"

restore path='.':
  git restore --staged {{path}} && git restore {{path}}

deploy hostname user='root' ip=hostname:
  git add . && nixos-rebuild \
    --flake .#{{hostname}} \
    --target-host {{user}}@{{ip}} \
    --use-remote-sudo \
    switch

provision ip hostname:
  doas nix run github:nix-community/nixos-anywhere \
    -- \
    --flake .#{{hostname}} root@{{ip}}

update:
  nix flake metadata --json | \
    jq -r '.locks.nodes | keys[] | select(. != "nixpkgs")' | \
    xargs -I{} nix flake update {}