git.fiddlerwoaroof.com
Browse code

chore: more flake improvements

Edward Langley authored on 06/10/2023 07:46:18
Showing 1 changed files
... ...
@@ -12,39 +12,47 @@
12 12
     self,
13 13
     nixpkgs,
14 14
     flake-utils,
15
-  }:
15
+  }: let
16
+  in
16 17
     flake-utils.lib.eachDefaultSystem (system: let
17 18
       pkgs = import nixpkgs {
18 19
         inherit system;
19 20
       };
21
+      build_zig = deriv @ {nativeBuildInputs ? [], ...}:
22
+        pkgs.stdenv.mkDerivation ({
23
+            dontConfigure = true;
24
+
25
+            preBuild = ''
26
+              export HOME=$TMPDIR
27
+            '';
28
+
29
+            installPhase = ''
30
+              runHook preInstall
31
+              zig build -Drelease-safe -Dcpu=baseline --prefix $out install
32
+              runHook postInstall
33
+            '';
34
+          }
35
+          // deriv
36
+          // {
37
+            nativeBuildInputs = [pkgs.zig_0_10] ++ nativeBuildInputs;
38
+          });
20 39
       socat = pkgs.socat;
21
-    in rec {
40
+    in {
22 41
       devShells.default = pkgs.mkShell {
23 42
         buildInputs = [pkgs.zig_0_10 socat];
24 43
       };
25
-      devShell = devShells.default;
26
-      packages.default = pkgs.stdenv.mkDerivation {
44
+      devShell = self.devShells.default;
45
+      packages.default = build_zig {
27 46
         pname = "sigexec";
28 47
         version = "0.0.2";
29 48
         src = ./.;
30 49
 
31
-        dontConfigure = true;
32
-
33
-        preBuild = ''
34
-          export HOME=$TMPDIR
35
-        '';
36
-
37
-        installPhase = ''
38
-          runHook preInstall
39
-          zig build -Drelease-safe -Dcpu=baseline --prefix $out install
40
-          runHook postInstall
41
-        '';
42
-
43
-        nativeBuildInputs = [pkgs.zig_0_10];
44
-      };
45
-      apps.default = {
46
-        type = "app";
47
-        program = "${self.packages.${system}.default}/bin/sigexec";
50
+        meta = with pkgs.lib; {
51
+          homepage = "https://github.com/fiddlerwoaroof/sigexec";
52
+          description = "A simple utility that runs a command with each line sent over a socket.";
53
+          license = licenses.mit;
54
+          platforms = platforms.linux ++ platforms.darwin;
55
+        };
48 56
       };
49 57
     });
50 58
 }