diff --git a/modules/lamassu-lnbits.nix b/modules/lamassu-lnbits.nix index 3ca110b..041c5c2 100644 --- a/modules/lamassu-lnbits.nix +++ b/modules/lamassu-lnbits.nix @@ -9,7 +9,7 @@ let # Shared environment variables for both services commonEnv = { - NODE_ENV = "production"; + NODE_ENV = cfg.mode; LOG_LEVEL = cfg.logLevel; HOSTNAME = cfg.hostname; @@ -117,6 +117,15 @@ in description = "Logging level for lamassu-server"; }; + mode = mkOption { + type = types.enum [ "production" "development" ]; + default = "development"; + description = '' + Run in production or development mode. + Development mode uses port 3001 for admin UI registration URLs. + ''; + }; + skip2FA = mkOption { type = types.bool; default = true; @@ -270,6 +279,8 @@ in CI = "true"; CC = "${pkgs.stdenv.cc}/bin/cc"; CXX = "${pkgs.stdenv.cc}/bin/c++"; + # Use content-addressable store to reduce disk usage + npm_config_cache = "${cfg.dataDir}/.npm-cache"; }; serviceConfig = { @@ -285,6 +296,8 @@ in ProtectHome = true; NoNewPrivileges = true; ReadWritePaths = [ cfg.dataDir ]; + # node-gyp needs writable /tmp for native module compilation + PrivateTmp = true; }; script = '' @@ -398,6 +411,7 @@ in export POSTGRES_HOST="127.0.0.1" POSTGRES_PORT="5432" export POSTGRES_DB="${cfg.database.name}" POSTGRES_USER="${cfg.database.user}" POSTGRES_PASSWORD="$DB_PASSWORD" export HOSTNAME="${cfg.hostname}" SKIP_2FA="${if cfg.skip2FA then "true" else "false"}" + export NODE_ENV="${cfg.mode}" sudo -E -u ${cfg.user} ${pkgs.nodejs_22}/bin/node ${cfg.dataDir}/source/packages/server/bin/lamassu-register "$@" '') ];