diff options
| author | Patrick | 2026-05-08 01:26:02 +0200 |
|---|---|---|
| committer | Patrick | 2026-05-08 01:26:02 +0200 |
| commit | 8d7a89c3aab3e12ba71595195f2964d36fb8ffc8 (patch) | |
| tree | 78fef6088305fcd251043dff8b260f727fc04c1d /flake.nix | |
| parent | 05c494c760b337f06cc2bc9676d60b23c19504e0 (diff) | |
| download | zhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.tar.gz zhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.zip | |
update build and flake
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -6,6 +6,7 @@ }; outputs = { + self, nixpkgs, zig, ... @@ -23,12 +24,45 @@ packages = forAllSystems (pkgs: zig: { default = zig.makePackage { - pname = "zig-flake-template"; + pname = "zhttpws"; version = "0.0.0"; src = ./.; zigReleaseMode = "fast"; depsHash = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo="; }; }); + + nixosModules.default = { config, lib, pkgs }: + let cfg = config.services.zhttpws; + in { + options.services.zhttpws = { + enable = lib.mkEnableOption "zhttpws"; + domain = lib.mkOption { + type = lib.types.str; + }; + port = lib.mkOption { + type = lib.types.port; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.zhttpws = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${self.packages.${pkgs.system}.default}/bin/zhttpws"; + DynamicUser = true; + Restart = "always"; + }; + environment = { + PORT = toString cfg.port; + }; + }; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' + reverse_proxy localhost:${toString cfg.port} + ''; + }; + }; }; } |
