back interdiff of round #1 and #0

nix/vm: store service data in a shared folder on the host #466

merged
opened by winter.bsky.social targeting master from winter.bsky.social/core: push-tkullpkzpmst

This also switches away from nixos-shell in the process as by this point it wasn't really adding much to our setup except inflexibility.

Signed-off-by: Winter winter@winter.cafe

ERROR
.gitignore

Failed to calculate interdiff for this file.

ERROR
docs/hacking.md

Failed to calculate interdiff for this file.

ERROR
flake.nix

Failed to calculate interdiff for this file.

ERROR
nix/vm.nix

Failed to calculate interdiff for this file.

NEW
nix/modules/knot.nix
···
cfg.package
];
-
system.activationScripts.gitConfig = let
-
setMotd =
-
if cfg.motdFile != null && cfg.motd != null
-
then throw "motdFile and motd cannot be both set"
-
else ''
-
${optionalString (cfg.motdFile != null) "cat ${cfg.motdFile} > ${cfg.stateDir}/motd"}
-
${optionalString (cfg.motd != null) ''printf "${cfg.motd}" > ${cfg.stateDir}/motd''}
-
'';
-
in ''
-
mkdir -p "${cfg.repo.scanPath}"
-
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.repo.scanPath}"
-
-
mkdir -p "${cfg.stateDir}/.config/git"
-
cat > "${cfg.stateDir}/.config/git/config" << EOF
-
[user]
-
name = Git User
-
email = git@example.com
-
[receive]
-
advertisePushOptions = true
-
EOF
-
${setMotd}
-
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.stateDir}"
-
'';
-
users.users.${cfg.gitUser} = {
isSystemUser = true;
useDefaultShell = true;
···
description = "knot service";
after = ["network.target" "sshd.service"];
wantedBy = ["multi-user.target"];
+
enableStrictShellChecks = true;
+
+
preStart = let
+
setMotd =
+
if cfg.motdFile != null && cfg.motd != null
+
then throw "motdFile and motd cannot be both set"
+
else ''
+
${optionalString (cfg.motdFile != null) "cat ${cfg.motdFile} > ${cfg.stateDir}/motd"}
+
${optionalString (cfg.motd != null) ''printf "${cfg.motd}" > ${cfg.stateDir}/motd''}
+
'';
+
in ''
+
mkdir -p "${cfg.repo.scanPath}"
+
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.repo.scanPath}"
+
+
mkdir -p "${cfg.stateDir}/.config/git"
+
cat > "${cfg.stateDir}/.config/git/config" << EOF
+
[user]
+
name = Git User
+
email = git@example.com
+
[receive]
+
advertisePushOptions = true
+
EOF
+
${setMotd}
+
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.stateDir}"
+
'';
+
serviceConfig = {
User = cfg.gitUser;
+
PermissionsStartOnly = true;
WorkingDirectory = cfg.stateDir;
Environment = [
"KNOT_REPO_SCAN_PATH=${cfg.repo.scanPath}"