anchor.diff:          WorkingDirectory = cfg.dataDir;
         };
         environment = {
  -        PYTHONPATH="${pythonEnv}/${pkgs.python3.sitePackages}";
  -        ETEBASE_EASY_CONFIG_PATH="${configIni}";
  +        PYTHONPATH = "${pythonEnv}/${pkgs.python3.sitePackages}";
  +        ETEBASE_EASY_CONFIG_PATH = "${configIni}";
         };
         preStart = ''
           # Auto-migrate on first run or if the package has changed
  
positive.code:   pythonEnv = pkgs.python3.withPackages (ps: with ps;
      [ etebase-server daphne ]);
  
    dbConfig = {
      sqlite3 = ''
        engine = django.db.backends.sqlite3
        name = ${cfg.dataDir}/db.sqlite3
      '';
    };
  
    defaultConfigIni = toString (pkgs.writeText "etebase-server.ini" ''
      [global]
      debug = false
      secret_file = ${if cfg.secretFile != null then cfg.secretFile else ""}
      media_root = ${cfg.dataDir}/media
  
      [allowed_hosts]
      allowed_host1 = ${cfg.host}
  
      [database]
      ${dbConfig."${cfg.database.type}"}
    '');
  
    configIni = if cfg.customIni != null then cfg.customIni else defaultConfigIni;
  
    defaultUser = "etebase-server";
  in
  {
    options = {
      services.etebase-server = {
        enable = mkOption {
  
negative.code:         example = "/run/etebase-server/etebase-server.sock";
        };
  
        settings = mkOption {
          type = lib.types.submodule {
            freeformType = iniFmt.type;
  
            options = {
              global = {
                debug = mkOption {
                  type = types.bool;
                  default = false;
                  description = ''
                    Whether to set django's DEBUG flag.
                  '';
                };
                secret_file = mkOption {
                  type = with types; nullOr str;
                  default = null;
                  description = ''
                    The path to a file containing the secret
                    used as django's SECRET_KEY.
                  '';
                };
                media_root = mkOption {
                  type = types.str;
                  default = "${cfg.dataDir}/media";
                  defaultText = "\${config.services.etebase-server.dataDir}/media";
                  description = "The media directory.";
                };
              };
              allowed_hosts = {
                allowed_host1 = mkOption {
                  type = types.str;
                  default = "0.0.0.0";
                  example = "localhost";
                  description = ''
                    The main host that is allowed access.
                  '';
                };
              };
              database = {
                engine = mkOption {
                  type = types.enum [ "django.db.backends.sqlite3" "django.db.backends.postgresql" ];
                  default = "django.db.backends.sqlite3";
                  description = "The database engine to use.";
                };
                name = mkOption {
                  type = types.str;
                  default = "${cfg.dataDir}/db.sqlite3";
                  defaultText = "\${config.services.etebase-server.dataDir}/db.sqlite3";
                  description = "The database name.";
                };
              };
            };
          };
          default = {};
          description = ''
            Configuration for <package>etebase-server</package>. Refer to
            <link xlink:href="https://github.com/etesync/server/blob/master/etebase-server.ini.example" />
            and <link xlink:href="https://github.com/etesync/server/wiki" />
            for details on supported values.
          '';
          example = {
            global = {
              debug = true;
              media_root = "/path/to/media";
            };
            allowed_hosts = {
              allowed_host2 = "localhost";
            };
          };
        };
  
        user = mkOption {
  