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 | |
| parent | 05c494c760b337f06cc2bc9676d60b23c19504e0 (diff) | |
| download | zhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.tar.gz zhttpws-8d7a89c3aab3e12ba71595195f2964d36fb8ffc8.zip | |
update build and flake
| -rw-r--r-- | build.zig | 2 | ||||
| -rw-r--r-- | flake.lock | 16 | ||||
| -rw-r--r-- | flake.nix | 36 |
3 files changed, 43 insertions, 11 deletions
@@ -38,7 +38,7 @@ pub fn build(b: *std.Build) void { // If neither case applies to you, feel free to delete the declaration you // don't need and to put everything under a single module. const exe = b.addExecutable(.{ - .name = "default", + .name = "zhttpws", .root_module = b.createModule(.{ // b.createModule defines a new module just like b.addModule but, // unlike b.addModule, it does not expose the module to consumers of @@ -2,12 +2,10 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1776949667, - "narHash": "sha256-GMSVw35Q+294GlrTUKlx087E31z7KurReQ1YHSKp5iw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "01fbdeef22b76df85ea168fbfe1bfd9e63681b30", - "type": "github" + "lastModified": 0, + "narHash": "sha256-4TLFHUwXraw9Df5mXC/vCrJgb50CRr3CzUzF0Mn3CII=", + "path": "/nix/store/jfwg36s3hfhlvxrxfw7d60nhycx5gp4h-source", + "type": "path" }, "original": { "id": "nixpkgs", @@ -27,11 +25,11 @@ ] }, "locked": { - "lastModified": 1777022972, - "narHash": "sha256-JONIVp25MIU90jh5LOl1LJsFoVhWTyRmvvxaJMqG5/g=", + "lastModified": 1777092395, + "narHash": "sha256-cJitc7H7Zr6YLPuVLvop+T2nd+b66f25kUaDivpuD2k=", "owner": "silversquirl", "repo": "zig-flake", - "rev": "a94c5ff62b4d642e6c12a38a5835ad13cbfd21d8", + "rev": "22e43efd36acb474a255496ada6c927e2fd2ac20", "type": "github" }, "original": { @@ -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} + ''; + }; + }; }; } |
