fixxxxxxxxxxxxxx
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, bun2nixFlake ? null, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
concatStringsSep
|
||||
@@ -105,14 +105,15 @@ let
|
||||
|
||||
serviceEnvFile = "${cfg.stateDir}/.env";
|
||||
composeFile = "${cfg.stateDir}/docker-compose.yml";
|
||||
bunNixFile = "${cfg.stateDir}/${cfg.bun2nix.outputFile}";
|
||||
sourcePath = cfg.source;
|
||||
|
||||
bun2nixCli =
|
||||
if bun2nixFlake != null then
|
||||
"${bun2nixFlake.packages.${pkgs.system}.default}/bin/bun2nix"
|
||||
else
|
||||
"${pkgs.bun}/bin/bunx bun2nix";
|
||||
publishedPorts =
|
||||
lib.optionals (cfg.httpPort != null) [ "${toString cfg.httpPort}:80" ]
|
||||
++ lib.optionals (cfg.httpsPort != null) [ "${toString cfg.httpsPort}:443" ];
|
||||
|
||||
firewallPorts =
|
||||
lib.optionals (cfg.httpPort != null) [ cfg.httpPort ]
|
||||
++ lib.optionals (cfg.httpsPort != null) [ cfg.httpsPort ];
|
||||
|
||||
serviceCommon = {
|
||||
restart = "unless-stopped";
|
||||
@@ -315,32 +316,6 @@ in
|
||||
description = "Enable Adminer container.";
|
||||
};
|
||||
|
||||
bun2nix = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Generate a bun2nix expression from the Wafrn bun lock file before starting.";
|
||||
};
|
||||
|
||||
lockFile = mkOption {
|
||||
type = types.str;
|
||||
default = "bun.lock";
|
||||
description = "Lock file path relative to services.wafrn.source.";
|
||||
};
|
||||
|
||||
outputFile = mkOption {
|
||||
type = types.str;
|
||||
default = "bun.nix";
|
||||
description = "Generated bun2nix expression filename under services.wafrn.stateDir.";
|
||||
};
|
||||
|
||||
copyPrefix = mkOption {
|
||||
type = types.str;
|
||||
default = "./";
|
||||
description = "Value passed to bun2nix --copy-prefix for workspace/file dependencies.";
|
||||
};
|
||||
};
|
||||
|
||||
bluesky = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
@@ -372,10 +347,6 @@ in
|
||||
assertion = cfg.httpPort != null || cfg.httpsPort != null;
|
||||
message = "services.wafrn requires at least one published port (httpPort or httpsPort).";
|
||||
}
|
||||
{
|
||||
assertion = (!cfg.bun2nix.enable) || (bun2nixFlake != null);
|
||||
message = "services.wafrn.bun2nix.enable requires using this module from the flake output so bun2nix is available.";
|
||||
}
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
@@ -402,17 +373,6 @@ in
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
${optionalString cfg.bun2nix.enable ''
|
||||
if [ ! -f "${cfg.source}/${cfg.bun2nix.lockFile}" ]; then
|
||||
echo "missing lockfile: ${cfg.source}/${cfg.bun2nix.lockFile}" >&2
|
||||
exit 1
|
||||
fi
|
||||
${bun2nixCli} \
|
||||
--lock-file "${cfg.source}/${cfg.bun2nix.lockFile}" \
|
||||
--output-file "${bunNixFile}" \
|
||||
--copy-prefix "${cfg.bun2nix.copyPrefix}"
|
||||
''}
|
||||
|
||||
install -m 0600 ${envTemplate} ${serviceEnvFile}
|
||||
${optionalString (cfg.secretsFile != null) ''
|
||||
cat "${cfg.secretsFile}" >> ${serviceEnvFile}
|
||||
@@ -448,10 +408,3 @@ in
|
||||
};
|
||||
};
|
||||
}
|
||||
publishedPorts =
|
||||
lib.optionals (cfg.httpPort != null) [ "${toString cfg.httpPort}:80" ]
|
||||
++ lib.optionals (cfg.httpsPort != null) [ "${toString cfg.httpsPort}:443" ];
|
||||
|
||||
firewallPorts =
|
||||
lib.optionals (cfg.httpPort != null) [ cfg.httpPort ]
|
||||
++ lib.optionals (cfg.httpsPort != null) [ cfg.httpsPort ];
|
||||
|
||||
Reference in New Issue
Block a user