Impermanence directory permissions

Hi everyone,

I’m trying to figure out how the directory permissions are supposed to work with impermanence.

For example, I have configured Prometheus service, which has dataDir set to /var/lib/prometheus2 and to persist it I use this config (notice the user and group are set to root):

  environment.persistence = {
    "/persist".directories = [{
      directory = "/var/lib/prometheus2";
      user = "root";
      group = "root";
      mode = "0700";
    }];
  };

At this point there is neither /var/lib/prometheus2 nor /persist/var/lib/prometheus2 directories. When I do nixos-rebuild switch:

  • in the output I see:
    Warning: Source directory '/persist/var/lib/prometheus2' does not exist; it will be created for you with the following permissions: owner: 'root:root', mode: '0700'.
    
    this looks good;
  • however, when I check what is in the /persist/var/lib, I get:
    drwx------ 1 prometheus prometheus    8 Sep  8 13:09 prometheus2
    
    The owner and group are prometheus and not root.
  • the same applies to /var/lib:
    drwx------ 1 prometheus prometheus    8 Sep  8 13:09 prometheus2
    
    The owner and group are prometheus and not root.
  • when I umount /var/lib/prometheus2 and check the /var/lib:
    drwx------ 1 root    root       0 Sep  8 13:09 prometheus2
    
    The owner and group are root.

Is this expected behaviour?