treesummaryrefslogcommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorPatrick2026-05-08 01:26:02 +0200
committerPatrick2026-05-08 01:26:02 +0200
commit8d7a89c3aab3e12ba71595195f2964d36fb8ffc8 (patch)
tree78fef6088305fcd251043dff8b260f727fc04c1d /flake.nix
parent05c494c760b337f06cc2bc9676d60b23c19504e0 (diff)
downloadzhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.tar.gz
zhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.zip
update build and flake
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix36
1 files changed, 35 insertions, 1 deletions
diff --git a/flake.nix b/flake.nix
index 8662667..265a9ea 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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}
+ '';
+ };
+ };
};
}