LnL7 / nix-darwin

nix modules for darwin
MIT License
3.19k stars 457 forks source link

Failed assertions: `system.stateVersion` option is not defined in your nix-darwin configuration #1087

Closed joscha closed 1 month ago

joscha commented 2 months ago

I am getting

       error:
       Failed assertions:
       - The `system.stateVersion` option is not defined in your
       nix-darwin configuration. The value is used to conditionalize
       backwards‐incompatible changes in default settings. You should
       usually set this once when installing nix-darwin on a new system
       and then never change it (at least without reading all the relevant
       entries in the changelog using `darwin-rebuild changelog`).

       You can use the current value for new installations as follows:

           system.stateVersion = 5;

after upgrading nix-darwin:

• Updated input 'darwin':
    'github:lnl7/nix-darwin/884f3fe6d9bf056ba0017c132c39c1f0d07d4fec' (2024-07-23)
  → 'github:lnl7/nix-darwin/c03f85fa42d68d1056ca1740f3113b04f3addff2' (2024-09-19)

I found https://github.com/LnL7/nix-darwin/blob/c03f85fa42d68d1056ca1740f3113b04f3addff2/CHANGELOG#L1-L13

but I am frankly unsure on how to upgrade nix-darwin w/o a full reinstall. I have

  nix.configureBuildUsers = true;

which I understand is the culprit.

How do I find out what my current stateVersion is? Also, adding it to my darwin config like:

      darwinConfigurations = rec {
        j-one = darwinSystem {
          system = "aarch64-darwin";
          system.stateVersion = 5;

results in:

error: attribute 'system.stateVersion' already defined at /nix/store/nkzrkkmh0ld81s7aclrrd5n1nllbhqvh-source/flake.nix:54:11

Additionally I am not certain where to put

  ids.gids.nixbld = 30000;

apologies if the fix is obvious, hopefully help here might help others with the same issue to upgrade as well.

emilazy commented 2 months ago

You can set system.stateVersion = 4; to use the stateVersion that was current as of the nix-darwin version before you upgraded, which should just work, or set system.stateVersion = 5; to use the current one (but it is likely you will be prompted to add the nixbld GID setting too if you do that, yes). It should go in your nix-darwin configuration/modules, not the darwinSystem call itself.

joscha commented 1 month ago

Thank you @emilazy, that worked a charm!

mvillafuertem commented 1 day ago

Hi guys, after running nix flake update, I'm experiencing the same error, I have added system.StateVersion = 5; to the configuration, but the installation of karabiner isn't working. any idea @emilazy? Thanks

       error:
       Failed assertions:
       - The `system.stateVersion` option is not defined in your
       nix-darwin configuration. The value is used to conditionalize
       backwards‐incompatible changes in default settings. You should
       usually set this once when installing nix-darwin on a new system
       and then never change it (at least without reading all the relevant
       entries in the changelog using `darwin-rebuild changelog`).

       You can use the current value for new installations as follows:

           system.stateVersion = 5;
user defaults...
restarting Dock...
setting up user launchd services...
creating user service org.nixos.activate_karabiner_system_ext
creating user service org.pqrs.karabiner.agent.karabiner_grabber
cp: cannot stat '/nix/store/cx8xka66lfjvd1lsmv2bkqarj8ds00kd-launchd/user/Library/LaunchAgents/org.pqrs.karabiner.agent.karabiner_grabber.plist': No such file or directory