]> gitweb.ps.run Git - chirp/blobdiff - flake.nix
add flake.lock
[chirp] / flake.nix
index fd691a8755163ebfec058e5c21762ba335dc08bb..50221679b388b30614206d8143829179eb428d0d 100644 (file)
--- a/flake.nix
+++ b/flake.nix
@@ -1,56 +1,26 @@
 {
-  description = "Chirp!";
+  description = "Zig project flake";
 
   inputs = {
-    zig.url = "github:mitchellh/zig-overlay";
+    zig2nix.url = "github:Cloudef/zig2nix";
   };
 
-  outputs = {
-    self,
-    zig,
-    pkgs,
-  }: let
-    nixosModule = {
-      config,
-      lib,
-      pkgs,
-      ...
-    }: {
-      options.services.chirp = {
-        enable = lib.mkEnableOption "Chirp";
+  outputs = { zig2nix, ... }: let
+    flake-utils = zig2nix.inputs.flake-utils;
+  in (flake-utils.lib.eachDefaultSystem (system: let
+      # Zig flake helper
+      # Check the flake.nix in zig2nix project for more options:
+      # <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
+      env = zig2nix.outputs.zig-env.${system} {};
+    in with builtins; with env.pkgs.lib; rec {
+      apps.default = env.app [] "zig build run -- \"$@\"";
+      packages.default = env.package {
+        src = cleanSource ./.;
 
-        port = lib.mkOption {
-          type = lib.types.port;
-          default = 8080;
-          description = "Port to listen on";
-        };
-      };
+        nativeBuildInputs = with env.pkgs; [];
+        buildInputs = with env.pkgs; [];
 
-      config = lib.mkIf config.services.chirp.enable {
-        systemd.services.chirp = {
-          description = "Chirp SystemD Service!";
-          wantedBy = ["multi-user.target"];
-          after = ["network.target"];
-          serviceConfig = {
-            ExecStart = "${zig.packages.master}";
-            Restart = "always";
-            Type = "simple";
-            DynamicUser = "yes";
-          };
-          environment = {
-            PORT = toString config.services.chirp.port;
-          };
-        };
-      };
-    };
-    in {
-      # TODO: packages.default build
-      apps.default = {
-        type = "app";
-        program = "${zig.packages.${pkgs.system}."0.14.0"} build run";
+        zigPreferMusl = false;
       };
-    }
-    // {
-      nixosModules.default = nixosModule;
-    };
+    }));
 }