3 lib ? (import <nixpkgs> { }).lib,
7 modules = upgradeConfig ++ [
15 Whether to periodically upgrade NixOS to the latest version.
16 Presumes that /etc/nixos is a git repo with a remote and
17 contains a pinch file called "channels".
25 Specification (in the format described by
26 <citerefentry><refentrytitle>systemd.time</refentrytitle>
27 <manvolnum>7</manvolnum></citerefentry>) of the time at
28 which the update will occur.
34 Git repositories to pull before running pinch. These are maintained
35 as git checkouts at specified places in the filesystem with specified
36 ownership rather than kept read-only in the nix store so that humans
37 can use them both as points of intervention in the automation and to
38 author and push changes back up.
41 type = types.attrsOf (
45 description = "Remote git repo.";
48 remoteName = mkOption {
49 description = ''Name of the git remote. Customarily "origin".'';
53 onRemoteURLMismatch = mkOption {
55 What to do if the remote URL in the git repo doesn't match the
64 onBranchMismatch = mkOption {
66 What to do if a different branch is currently checked out.
68 (Changes from <literal>remoteBranch</literal> are only ever
69 merged into <literal>localBranch</literal>, so if a different
70 branch is checked out, no remote changes will be merged.)
79 description = "User as which to run 'git fetch'";
82 localBranch = mkOption {
87 remoteBranch = mkOption {
91 requireSignature = mkOption {
95 Only pull when the tip of the remote ref is signed by a key
96 specifed in <literal>signingKeys</literal>.
104 url = "https://github.com/chkno/auto-upgrade-demo-nixos";
106 signingKeys = [ ./admins.asc ];
108 "/home/alice/.config/nixpkgs" = {
109 url = "https://github.com/chkno/auto-upgrade-demo-user-nixpkgs";
119 pinchFiles = mkOption {
121 Pinch files to use for channel updates. Typically these are inside
122 <literal>repos</literal>' paths.
124 type = types.listOf types.path;
126 example = [ "/etc/nixos/channels" ];
129 userEnvironments = mkOption {
131 User environments to update as part of an upgrade run.
134 type = types.attrsOf (
139 default = "userPackages";
141 The name of the single package that will be updated. You'll
142 want to create an 'entire user environment' package as shown in
143 https://nixos.wiki/wiki/FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F
146 otherPackagesAction = mkOption {
154 What to do with packages other than <literal>package</literal>.
156 THIS DEFAULTS TO "remove", WHICH IS POTENTIALLY SOMEWHAT
157 DESTRUCTIVE! This is the default because it is the recommended
158 setting -- This module recommends managing your environment
159 through your one entire-environment <literal>package</literal>.
160 This keeps your environment declarative and ensures that all
161 packages receive regular updates.
163 # It seems like "upgrade" ought to be another choice here, powered
164 # by "nix-env --upgrade". But when I tried this, it didn't work.