-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ config, pkgs, modulesPath, lib, self, ... }: | ||
let | ||
cfg = config.services.ihp; | ||
openssl = "${pkgs.openssl}/bin/openssl"; | ||
base64 = "${pkgs.coreutils}/bin/base64"; | ||
in | ||
{ | ||
systemd.services.app-keygen = { | ||
description = "App Session Key Generation"; | ||
wantedBy = [ "multi-user.target" ]; | ||
before = [ "app.service" ]; | ||
script = '' | ||
mkdir -p "$(dirname "${cfg.sessionSecretFile}")" | ||
if [ -n "${cfg.sessionSecret or ""}" ]; then | ||
# If sessionSecret is set, decode and write it to the file | ||
echo "${cfg.sessionSecret}" | ${base64} -d > "${cfg.sessionSecretFile}" | ||
elif [ ! -f "${cfg.sessionSecretFile}" ]; then | ||
# If sessionSecret is not set, generate a new secret | ||
${openssl} rand 96 > "${cfg.sessionSecretFile}" | ||
fi | ||
chmod 600 "${cfg.sessionSecretFile}" | ||
''; | ||
serviceConfig.Type = "oneshot"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters