]> gitweb.ps.run Git - chirp/blob - flake.nix
update build.zig.zon
[chirp] / flake.nix
1 {
2   description = "Chirp!";
3
4   inputs = {
5     zig.url = "github:mitchellh/zig-overlay";
6   };
7
8   outputs = {
9     self,
10     zig,
11     pkgs,
12   }: let
13     nixosModule = {
14       config,
15       lib,
16       pkgs,
17       ...
18     }: {
19       options.services.chirp = {
20         enable = lib.mkEnableOption "Chirp";
21
22         port = lib.mkOption {
23           type = lib.types.port;
24           default = 8080;
25           description = "Port to listen on";
26         };
27       };
28
29       config = lib.mkIf config.services.chirp.enable {
30         systemd.services.chirp = {
31           description = "Chirp SystemD Service!";
32           wantedBy = ["multi-user.target"];
33           after = ["network.target"];
34           serviceConfig = {
35             ExecStart = "${zig.packages.master}";
36             Restart = "always";
37             Type = "simple";
38             DynamicUser = "yes";
39           };
40           environment = {
41             PORT = toString config.services.chirp.port;
42           };
43         };
44       };
45     };
46     in {
47       # TODO: packages.default build
48       apps.default = {
49         type = "app";
50         program = "${zig.packages.${pkgs.system}."0.14.0"} build run";
51       };
52     }
53     // {
54       nixosModules.default = nixosModule;
55     };
56 }