mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git
synced 2025-01-24 01:36:34 +00:00
sp-modules: get rid of systemd.tmpfiles
Because it causes troubles when using bind-mounts for /var/lib/*.
This commit is contained in:
parent
83e8f6e8a1
commit
67c2b12c44
|
@ -1,6 +1,7 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
secrets-filepath = "/etc/selfprivacy/secrets.json";
|
secrets-filepath = "/etc/selfprivacy/secrets.json";
|
||||||
|
backup-dir = "/var/lib/bitwarden/backup";
|
||||||
inherit (import ./common.nix config) bitwarden-env sp;
|
inherit (import ./common.nix config) bitwarden-env sp;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -19,17 +20,25 @@ in
|
||||||
fileSystems = lib.mkIf sp.useBinds {
|
fileSystems = lib.mkIf sp.useBinds {
|
||||||
"/var/lib/bitwarden" = {
|
"/var/lib/bitwarden" = {
|
||||||
device = "/volumes/${sp.modules.bitwarden.location}/bitwarden";
|
device = "/volumes/${sp.modules.bitwarden.location}/bitwarden";
|
||||||
options = [ "bind" ];
|
options = [
|
||||||
|
"bind"
|
||||||
|
"x-systemd.required-by=bitwarden-secrets.service"
|
||||||
|
"x-systemd.required-by=vaultwarden.service"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
"/var/lib/bitwarden_rs" = {
|
"/var/lib/bitwarden_rs" = {
|
||||||
device = "/volumes/${sp.modules.bitwarden.location}/bitwarden_rs";
|
device = "/volumes/${sp.modules.bitwarden.location}/bitwarden_rs";
|
||||||
options = [ "bind" ];
|
options = [
|
||||||
|
"bind"
|
||||||
|
"x-systemd.required-by=bitwarden-secrets.service"
|
||||||
|
"x-systemd.required-by=vaultwarden.service"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.vaultwarden = {
|
services.vaultwarden = {
|
||||||
enable = true;
|
enable = true;
|
||||||
dbBackend = "sqlite";
|
dbBackend = "sqlite";
|
||||||
backupDir = "/var/lib/bitwarden/backup";
|
backupDir = backup-dir;
|
||||||
environmentFile = "${bitwarden-env}";
|
environmentFile = "${bitwarden-env}";
|
||||||
config = {
|
config = {
|
||||||
domain = "https://password.${sp.domain}/";
|
domain = "https://password.${sp.domain}/";
|
||||||
|
@ -52,15 +61,13 @@ in
|
||||||
else
|
else
|
||||||
bitwarden_env="ADMIN_TOKEN=$token"
|
bitwarden_env="ADMIN_TOKEN=$token"
|
||||||
fi
|
fi
|
||||||
# TODO revise this permissions mode
|
|
||||||
install -m 0640 -o vaultwarden -g vaultwarden -DT \
|
install -C -m 0700 -o vaultwarden -g vaultwarden \
|
||||||
|
-d /var/lib/bitwarden
|
||||||
|
|
||||||
|
install -C -m 0600 -o vaultwarden -g vaultwarden -DT \
|
||||||
<(printf "%s" "$bitwarden_env") ${bitwarden-env}
|
<(printf "%s" "$bitwarden_env") ${bitwarden-env}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /var/lib/bitwarden 0777 vaultwarden vaultwarden -"
|
|
||||||
"d /var/lib/bitwarden/backup 0777 vaultwarden vaultwarden -"
|
|
||||||
"f ${bitwarden-env} 0640 vaultwarden vaultwarden - -"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
sp = config.selfprivacy;
|
sp = config.selfprivacy;
|
||||||
|
stateDir =
|
||||||
|
if sp.useBinds
|
||||||
|
then "/volumes/${sp.modules.gitea.location}/gitea"
|
||||||
|
else "/var/lib/gitea";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.selfprivacy.modules.gitea = {
|
options.selfprivacy.modules.gitea = {
|
||||||
|
@ -15,20 +19,10 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.selfprivacy.modules.gitea.enable {
|
config = lib.mkIf config.selfprivacy.modules.gitea.enable {
|
||||||
fileSystems = lib.mkIf sp.useBinds {
|
|
||||||
"/var/lib/gitea" = {
|
|
||||||
device = "/volumes/${sp.modules.gitea.location}/gitea";
|
|
||||||
options = [ "bind" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
systemd.services.gitea.unitConfig = lib.mkIf sp.useBinds {
|
|
||||||
RequiresMountsFor = "/var/lib/gitea";
|
|
||||||
ConditionPathIsMountPoint = "/var/lib/gitea";
|
|
||||||
};
|
|
||||||
services = {
|
services = {
|
||||||
gitea = {
|
gitea = {
|
||||||
enable = true;
|
enable = true;
|
||||||
stateDir = "/var/lib/gitea";
|
inherit stateDir;
|
||||||
# log = {
|
# log = {
|
||||||
# rootPath = "/var/lib/gitea/log";
|
# rootPath = "/var/lib/gitea/log";
|
||||||
# level = "Warn";
|
# level = "Warn";
|
||||||
|
@ -39,7 +33,7 @@ in
|
||||||
host = "127.0.0.1";
|
host = "127.0.0.1";
|
||||||
name = "gitea";
|
name = "gitea";
|
||||||
user = "gitea";
|
user = "gitea";
|
||||||
path = "/var/lib/gitea/data/gitea.db";
|
path = "${stateDir}/data/gitea.db";
|
||||||
createDatabase = true;
|
createDatabase = true;
|
||||||
};
|
};
|
||||||
# ssh = {
|
# ssh = {
|
||||||
|
@ -48,10 +42,10 @@ in
|
||||||
# };
|
# };
|
||||||
lfs = {
|
lfs = {
|
||||||
enable = true;
|
enable = true;
|
||||||
contentDir = "/var/lib/gitea/lfs";
|
contentDir = "${stateDir}/lfs";
|
||||||
};
|
};
|
||||||
appName = "SelfPrivacy git Service";
|
appName = "SelfPrivacy git Service";
|
||||||
repositoryRoot = "/var/lib/gitea/repositories";
|
repositoryRoot = "${stateDir}/repositories";
|
||||||
domain = "git.${sp.domain}";
|
domain = "git.${sp.domain}";
|
||||||
rootUrl = "https://git.${sp.domain}/";
|
rootUrl = "https://git.${sp.domain}/";
|
||||||
httpAddress = "0.0.0.0";
|
httpAddress = "0.0.0.0";
|
||||||
|
@ -78,11 +72,13 @@ in
|
||||||
COOKIE_SECURE = true;
|
COOKIE_SECURE = true;
|
||||||
};
|
};
|
||||||
log = {
|
log = {
|
||||||
ROOT_PATH = "/var/lib/gitea/log";
|
ROOT_PATH = "${stateDir}/log";
|
||||||
LEVEL = "Warn";
|
LEVEL = "Warn";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.services.gitea.unitConfig.RequiresMountsFor =
|
||||||
|
lib.mkIf sp.useBinds "/volumes/${sp.modules.gitea.location}/gitea";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
fileSystems = lib.mkIf sp.useBinds {
|
fileSystems = lib.mkIf sp.useBinds {
|
||||||
"/var/lib/nextcloud" = {
|
"/var/lib/nextcloud" = {
|
||||||
device = "/volumes/${sp.modules.nextcloud.location}/nextcloud";
|
device = "/volumes/${sp.modules.nextcloud.location}/nextcloud";
|
||||||
options = [ "bind" ];
|
options = [
|
||||||
|
"bind"
|
||||||
|
"x-systemd.required-by=nextcloud-setup.service"
|
||||||
|
"x-systemd.required-by=nextcloud-secrets.service"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.services.nextcloud-secrets = {
|
systemd.services.nextcloud-secrets = {
|
||||||
|
@ -29,11 +33,11 @@
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
path = with pkgs; [ coreutils jq ];
|
path = with pkgs; [ coreutils jq ];
|
||||||
script = ''
|
script = ''
|
||||||
install -m 0440 -o nextcloud -g nextcloud -DT \
|
install -C -m 0440 -o nextcloud -g nextcloud -DT \
|
||||||
<(jq -re '.modules.nextcloud.databasePassword' ${secrets-filepath}) \
|
<(jq -re '.modules.nextcloud.databasePassword' ${secrets-filepath}) \
|
||||||
${db-pass-filepath}
|
${db-pass-filepath}
|
||||||
|
|
||||||
install -m 0440 -o nextcloud -g nextcloud -DT \
|
install -C -m 0440 -o nextcloud -g nextcloud -DT \
|
||||||
<(jq -re '.modules.nextcloud.adminPassword' ${secrets-filepath}) \
|
<(jq -re '.modules.nextcloud.adminPassword' ${secrets-filepath}) \
|
||||||
${admin-pass-filepath}
|
${admin-pass-filepath}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -18,11 +18,19 @@ in
|
||||||
fileSystems = lib.mkIf sp.useBinds {
|
fileSystems = lib.mkIf sp.useBinds {
|
||||||
"/var/lib/pleroma" = {
|
"/var/lib/pleroma" = {
|
||||||
device = "/volumes/${sp.modules.pleroma.location}/pleroma";
|
device = "/volumes/${sp.modules.pleroma.location}/pleroma";
|
||||||
options = [ "bind" ];
|
options = [
|
||||||
|
"bind"
|
||||||
|
"x-systemd.required-by=pleroma-secrets.service"
|
||||||
|
"x-systemd.required-by=pleroma.service"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
"/var/lib/postgresql" = {
|
"/var/lib/postgresql" = {
|
||||||
device = "/volumes/${sp.modules.pleroma.location}/postgresql";
|
device = "/volumes/${sp.modules.pleroma.location}/postgresql";
|
||||||
options = [ "bind" ];
|
options = [
|
||||||
|
"bind"
|
||||||
|
"x-systemd.required-by=pleroma-secrets.service"
|
||||||
|
"x-systemd.required-by=pleroma.service"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
|
@ -70,14 +78,12 @@ in
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
install -m 0750 -o pleroma -g pleroma -DT \
|
install -C -m 0700 -o pleroma -g pleroma -d /var/lib/pleroma
|
||||||
|
|
||||||
|
install -C -m 0700 -o pleroma -g pleroma -DT \
|
||||||
<(printf "%s" "$filecontents") ${secrets-exs}
|
<(printf "%s" "$filecontents") ${secrets-exs}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /var/lib/pleroma 0700 pleroma pleroma - -"
|
|
||||||
"f ${secrets-exs} 0755 pleroma pleroma - -"
|
|
||||||
];
|
|
||||||
environment.etc."setup.psql".text = ''
|
environment.etc."setup.psql".text = ''
|
||||||
CREATE USER pleroma;
|
CREATE USER pleroma;
|
||||||
CREATE DATABASE pleroma OWNER pleroma;
|
CREATE DATABASE pleroma OWNER pleroma;
|
||||||
|
|
Loading…
Reference in a new issue