diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2026-02-15 21:27:00 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2026-02-15 21:27:00 +0100 |
| commit | ce0dbf6b249956700c6a1705bf4ad85a09d53e8c (patch) | |
| tree | d7c3236807cfbf75d7f3a355eb5df5a5e2cc4ad7 /nix/module.nix | |
| parent | 064a1d01c5c14f5ecc032fa9b8346a4a88b893f6 (diff) | |
Switch, cleanup, and status CLI commands. Persistent build state via
state.json. Post-deploy hooks on success and failure with
WITRYNA_BUILD_STATUS. Dependency diet (axum→tiny_http, clap→argh,
tracing→log). Drop built-in rate limiting. Nix flake with NixOS module.
Arch Linux PKGBUILD. Centralized version management.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'nix/module.nix')
| -rw-r--r-- | nix/module.nix | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/nix/module.nix b/nix/module.nix new file mode 100644 index 0000000..6299ad9 --- /dev/null +++ b/nix/module.nix @@ -0,0 +1,68 @@ +flake: { config, lib, pkgs, ... }: +let + cfg = config.services.witryna; +in +{ + options.services.witryna = { + enable = lib.mkEnableOption "witryna deployment service"; + + package = lib.mkOption { + type = lib.types.package; + default = flake.packages.${pkgs.stdenv.hostPlatform.system}.witryna; + description = "The witryna package to use."; + }; + + configFile = lib.mkOption { + type = lib.types.path; + description = "Path to witryna.toml configuration file."; + }; + }; + + config = lib.mkIf cfg.enable { + users.users.witryna = { + isSystemUser = true; + group = "witryna"; + home = "/var/lib/witryna"; + }; + users.groups.witryna = {}; + + systemd.tmpfiles.rules = [ + "d /var/lib/witryna 0755 witryna witryna -" + "d /var/lib/witryna/clones 0755 witryna witryna -" + "d /var/lib/witryna/builds 0755 witryna witryna -" + "d /var/lib/witryna/cache 0755 witryna witryna -" + "d /var/log/witryna 0755 witryna witryna -" + ]; + + systemd.services.witryna = { + description = "Witryna - Git-based static site deployment orchestrator"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + User = "witryna"; + Group = "witryna"; + ExecStart = "${cfg.package}/bin/witryna serve --config ${cfg.configFile}"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + Restart = "on-failure"; + RestartSec = 5; + # Security hardening (mirrors debian/witryna.service) + NoNewPrivileges = true; + PrivateTmp = true; + ProtectSystem = "strict"; + ProtectKernelTunables = true; + ProtectKernelModules = true; + ProtectControlGroups = true; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; + LockPersonality = true; + MemoryDenyWriteExecute = true; + ReadWritePaths = [ "/var/lib/witryna" "/var/log/witryna" "/run/user" ]; + LimitNOFILE = 65536; + LimitNPROC = 4096; + }; + }; + }; +} |
