- Add flake.nix with packages for all 5 apps (landing, gacha, backoffice, dimentorin, hackathon) - Add NixOS modules for deployment (systemd service for Next.js, nginx for Vite apps) - Add mkHackathonWithEnv function for build-time environment variables - Add development shell with Node.js 22, npm, bun 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
77 lines
1.8 KiB
Nix
77 lines
1.8 KiB
Nix
# NixOS Module for Static Vite Apps (nginx-based)
|
|
{ self }:
|
|
|
|
{ appName }:
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.services."imphnen-${appName}";
|
|
in {
|
|
options.services."imphnen-${appName}" = {
|
|
enable = lib.mkEnableOption "Imphnen ${appName}";
|
|
|
|
domain = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Domain name for the app";
|
|
};
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = self.packages.${pkgs.system}.${appName};
|
|
description = "The ${appName} package to use";
|
|
};
|
|
|
|
enableSSL = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Enable ACME SSL";
|
|
};
|
|
|
|
extraLocations = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.anything;
|
|
default = {};
|
|
description = "Additional nginx locations";
|
|
};
|
|
|
|
extraConfig = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
description = "Extra nginx configuration";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
services.nginx = {
|
|
enable = true;
|
|
recommendedGzipSettings = true;
|
|
recommendedOptimisation = true;
|
|
recommendedProxySettings = true;
|
|
recommendedTlsSettings = true;
|
|
|
|
virtualHosts.${cfg.domain} = {
|
|
forceSSL = cfg.enableSSL;
|
|
enableACME = cfg.enableSSL;
|
|
root = cfg.package;
|
|
|
|
locations = {
|
|
"/" = {
|
|
tryFiles = "$uri $uri/ /index.html";
|
|
};
|
|
|
|
# Cache static assets
|
|
"~* \\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$" = {
|
|
tryFiles = "$uri =404";
|
|
extraConfig = ''
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
'';
|
|
};
|
|
} // cfg.extraLocations;
|
|
|
|
extraConfig = cfg.extraConfig;
|
|
};
|
|
};
|
|
};
|
|
}
|