NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.99k stars 14k forks source link

NixOS: declare all state locations #273972

Open roberth opened 10 months ago

roberth commented 10 months ago

Project description

Provide options that declare where all system state is kept. This serves a number of purposes:

Example module config:

  config = mkMerge [
    (mkIf cfg.enable ...)
    {
      state."my-module" = {
        locations = [
          "/var/lib/my-module";
        ];
        enable = cfg.enable;
      };
      # (already exists)
      meta.maintainers = ...;
    }
  ];

Some discussion can be found in


Add a :+1: reaction to issues you find important.

jansol commented 10 months ago

I assume by Impermanence you mean nix-community/impermanence?

rnhmjoj commented 10 months ago

Great idea! NixOS could do better with handling its state and this seems a step in the right direction.

nixos-discourse commented 10 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/what-about-state-management/37082/2

gytis-ivaskevicius commented 10 months ago

How about we do this the other way around? Configure applications to use certain state directory like /volumes/postgres whenever possible

this would allow users to easily find data directories and configure mountpoints/snapshotting and since its a custom path - it would allow us to easily find other state locations which are not properly configured

Not sure if there is much point in doing so, just a thought