1 { upgradeConfig, lib ? (import <nixpkgs> { }).lib, }:
4 modules = upgradeConfig ++ [{
11 Whether to periodically upgrade NixOS to the latest version.
12 Presumes that /etc/nixos is a git repo with a remote and
13 contains a pinch file called "channels".
21 Specification (in the format described by
22 <citerefentry><refentrytitle>systemd.time</refentrytitle>
23 <manvolnum>7</manvolnum></citerefentry>) of the time at
24 which the update will occur.
30 Git repositories to pull before running pinch. These are maintained
31 as git checkouts at specified places in the filesystem with specified
32 ownership rather than kept read-only in the nix store so that humans
33 can use them both as points of intervention in the automation and to
34 author and push changes back up.
37 type = types.attrsOf (types.submodule {
40 description = "Remote git repo.";
43 remoteName = mkOption {
44 description = ''Name of the git remote. Customarily "origin".'';
48 onRemoteURLMismatch = mkOption {
50 What to do if the remote URL in the git repo doesn't match the
53 type = types.enum [ "update" "abort" ];
56 onBranchMismatch = mkOption {
58 What to do if a different branch is currently checked out.
60 (Changes from <literal>remoteBranch</literal> are only ever
61 merged into <literal>localBranch</literal>, so if a different
62 branch is checked out, no remote changes will be merged.)
64 type = types.enum [ "continue" "abort" ];
68 description = "User as which to run 'git fetch'";
71 localBranch = mkOption {
76 remoteBranch = mkOption {
80 requireSignature = mkOption {
84 Only pull when the tip of the remote ref is signed by a key
85 specifed in <literal>signingKeys</literal>.
92 url = "https://github.com/chkno/auto-upgrade-demo-nixos";
94 signingKeys = [ ./admins.asc ];
96 "/home/alice/.config/nixpkgs" = {
97 url = "https://github.com/chkno/auto-upgrade-demo-user-nixpkgs";
99 signingKeys = [ ./admins.asc ./alice.asc ];
104 pinchFiles = mkOption {
106 Pinch files to use for channel updates. Typically these are inside
107 <literal>repos</literal>' paths.
109 type = types.listOf types.path;
111 example = [ "/etc/nixos/channels" ];
114 userEnvironments = mkOption {
116 User environments to update as part of an upgrade run.
119 type = types.attrsOf (types.submodule {
123 default = "userPackages";
125 The name of the single package that will be updated. You'll
126 want to create an 'entire user environment' package as shown in
127 https://nixos.wiki/wiki/FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F
130 otherPackagesAction = mkOption {
131 type = types.enum [ "remove" "keep" "abort" ];
134 What to do with packages other than <literal>package</literal>.
136 THIS DEFAULTS TO "remove", WHICH IS POTENTIALLY SOMEWHAT
137 DESTRUCTIVE! This is the default because it is the recommended
138 setting -- This module recommends managing your environment
139 through your one entire-environment <literal>package</literal>.
140 This keeps your environment declarative and ensures that all
141 packages receive regular updates.
143 # It seems like "upgrade" ought to be another choice here, powered
144 # by "nix-env --upgrade". But when I tried this, it didn't work.
148 example = { alice = { }; };