# How to make automatic upgrades in configuration.nix work?

**URL:** https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254
**Category:** Help
**Created:** [July 10, 2022, 12:06pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254 "2022-07-10T12:06:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![henrydenhengst](https://discourse.nixos.org/user_avatar/discourse.nixos.org/henrydenhengst/32/6817_2.png) [@henrydenhengst](https://discourse.nixos.org/u/henrydenhengst)
#### Post date: [July 10, 2022, 12:06pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/1 "2022-07-10T12:06:23Z")

</div>

My configuration.nix is not succesful when I insert this automatic update?!

```auto
### automatic upgrade
  system.autoUpgrade = {
      enable = true;
      channel = "https://nixos.org/channels/nixos-22.05";
  };

```

Errors:

```auto
[henry@nixos:~]$ sudo nixos-rebuild switch
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:345:20:

          344| ### automatic upgrade
          345| system.autoUpgrade = {
             | ^
          346| enable = true;
(use '--show-trace' to show detailed location information)
building Nix...
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:345:20:

          344| ### automatic upgrade
          345| system.autoUpgrade = {
             | ^
          346| enable = true;
(use '--show-trace' to show detailed location information)
building the system configuration...
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:345:20:

          344| ### automatic upgrade
          345| system.autoUpgrade = {
             | ^
          346| enable = true;
(use '--show-trace' to show detailed location information)

```

---

<div class="post-metadata">

### Author: ![Father2303](https://discourse.nixos.org/user_avatar/discourse.nixos.org/father2303/32/8705_2.png) [@Father2303](https://discourse.nixos.org/u/Father2303)
#### Post date: [July 10, 2022, 4:23pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/2 "2022-07-10T16:23:56Z")

</div>

Why don’t you just use `system.autoUpgrade.enable = true;` ?

The channel is already set globally and doesn’t have to be set in `configuration.nix`.

---

<div class="post-metadata">

### Author: ![henrydenhengst](https://discourse.nixos.org/user_avatar/discourse.nixos.org/henrydenhengst/32/6817_2.png) [@henrydenhengst](https://discourse.nixos.org/u/henrydenhengst)
#### Post date: [July 10, 2022, 4:28pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/3 "2022-07-10T16:28:04Z")

</div>

Still errors:

```auto
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:343:27:

          342|
          343| system.autoUpgrade.enable = true;
             | ^
(use '--show-trace' to show detailed location information)
building Nix...
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:343:27:

          342|
          343| system.autoUpgrade.enable = true;
             | ^
(use '--show-trace' to show detailed location information)
building the system configuration...
error: syntax error, unexpected '=', expecting end of file

       at /etc/nixos/configuration.nix:343:27:

          342|
          343| system.autoUpgrade.enable = true;
             | ^
(use '--show-trace' to show detailed location information)

```

---

<div class="post-metadata">

### Author: ![Father2303](https://discourse.nixos.org/user_avatar/discourse.nixos.org/father2303/32/8705_2.png) [@Father2303](https://discourse.nixos.org/u/Father2303)
#### Post date: [July 10, 2022, 4:31pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/4 "2022-07-10T16:31:35Z")

</div>

Check for missing/surplus semicolons, brackets etc. **anywhere** in `configuration.nix`.

This happens easily and is difficult to spot.

---

<div class="post-metadata">

### Author: ![henrydenhengst](https://discourse.nixos.org/user_avatar/discourse.nixos.org/henrydenhengst/32/6817_2.png) [@henrydenhengst](https://discourse.nixos.org/u/henrydenhengst)
#### Post date: [July 10, 2022, 4:48pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/5 "2022-07-10T16:48:58Z")

</div>

system.stateVersion = “22.05”;

Should these be integrated to one?

---

<div class="post-metadata">

### Author: ![henrydenhengst](https://discourse.nixos.org/user_avatar/discourse.nixos.org/henrydenhengst/32/6817_2.png) [@henrydenhengst](https://discourse.nixos.org/u/henrydenhengst)
#### Post date: [July 10, 2022, 5:00pm UTC](https://discourse.nixos.org/t/how-to-make-automatic-upgrades-in-configuration-nix-work/20254/6 "2022-07-10T17:00:08Z")

</div>

It was a ‘}’ in the wrong place afterall. OMG Sorry!

> <https://github.com/henrydenhengst/mynixos/blob/4fe32e02afa8b42ed05a3f7b7e4de0222a3acaa5/configuration.nix>
