-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nu
37 lines (37 loc) · 844 Bytes
/
main.nu
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
# NUS: NixOS Update Script
# It's a simple script that updates your flake-based system and pushes changes to git.
# Additionally it displays which packages changed.
def main [
--path (-p): string = '/etc/nixos'
] {
if not ($path | path exists) {
print 'Path does not exist'
return
}
cd $path
nix flake update
print ''
nixos-rebuild switch
print ''
let generations = (
nix-env
--list-generations
--profile /nix/var/nix/profiles/system
| lines
| last 2
| each {|| split column ' '
| get column1
| str trim
| get 0 }
)
let changes = (
nvd diff
$'/nix/var/nix/profiles/system-($generations.0)-link'
$'/nix/var/nix/profiles/system-($generations.1)-link'
)
print $changes
print ''
git commit -am 'update flake inputs' -m $changes
print ''
git push
}