nh wraps rebuilds with nix-output-monitor progress and a closure diff. darwinFlake is this checkout, so nh darwin switch picks darwinConfigurations.<hostname> without a --flake argument. programs.nh.clean is left off since on Darwin it only cleans user profiles; store GC runs as a root nh clean all daemon in hosts/common/nix.nix.
nhup and nhu
Update every flake input, rebuild with nh darwin <action>, and push the new lock (#629): nhup switches, nhu only builds, so a lock that does not build is never pushed either way. Arguments go to nh. Commands of their own rather than an nh shell function: nh has no external subcommands, and shadowing it would break outside interactive shells. The git steps run against the flake checkout, so they work from any directory.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 mkUpdate =
name: action:
pkgs.writeShellApplication {
inherit name;
runtimeInputs = [
config.programs.nh.package
pkgs.git
];
text = ''
nh darwin ${action} -u "$@"
git -C ${flake} add .
git -C ${flake} commit -m "Update flake.lock"
git -C ${flake} push
'';
};View the complete file
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# nh wraps rebuilds with nix-output-monitor progress and a closure diff.
# `darwinFlake` is this checkout, so `nh darwin switch` picks
# `darwinConfigurations.<hostname>` without a --flake argument.
# `programs.nh.clean` is left off since on Darwin it only cleans user profiles;
# store GC runs as a root `nh clean all` daemon in hosts/common/nix.nix.
{
config,
pkgs,
...
}:
let
flake = "${config.naitokosuke.githubDirectory}/dotfiles";
## nhup and nhu
# Update every flake input, rebuild with `nh darwin <action>`, and push the
# new lock (#629): nhup switches, nhu only builds, so a lock that does not
# build is never pushed either way. Arguments go to nh. Commands of their
# own rather than an `nh` shell function: nh has no external subcommands,
# and shadowing it would break outside interactive shells. The git steps run
# against the flake checkout, so they work from any directory.
mkUpdate =
name: action:
pkgs.writeShellApplication {
inherit name;
runtimeInputs = [
config.programs.nh.package
pkgs.git
];
text = ''
nh darwin ${action} -u "$@"
git -C ${flake} add .
git -C ${flake} commit -m "Update flake.lock"
git -C ${flake} push
'';
};
in
{
programs.nh = {
enable = true;
darwinFlake = flake;
};
home.packages = [
(mkUpdate "nhup" "switch")
(mkUpdate "nhu" "build")
];
}