ctucx.git: ctucx.things

simple inventory management web-app

commit f2857dc6e2248501adf8f98e5d6b834496d84b1e
parent 7e5e220348e8ab834f4791472d4dc4f181c7c9e4
Author: Katja (ctucx) <git@ctu.cx>
Date: Wed, 5 Mar 2025 20:14:07 +0100

flake: refactor, remove `flake-utils` dependency
2 files changed, 37 insertions(+), 51 deletions(-)
M
flake.lock
|
22
+++-------------------
M
flake.nix
|
66
++++++++++++++++++++++++++++++++++--------------------------------
diff --git a/flake.lock b/flake.lock
@@ -1,27 +1,12 @@
 {
   "nodes": {
-    "flake-utils": {
-      "locked": {
-        "lastModified": 1667395993,
-        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
-        "type": "github"
-      },
-      "original": {
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "type": "github"
-      }
-    },
     "nixpkgs": {
       "locked": {
-        "lastModified": 1670543317,
-        "narHash": "sha256-4mMR56rtxKr+Gwz399jFr4i76SQZxsLWxxyfQlPXRm0=",
+        "lastModified": 1688392541,
+        "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "7a6a010c3a1d00f8470a5ca888f2f927f1860a19",
+        "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
         "type": "github"
       },
       "original": {

@@ -33,7 +18,6 @@
     },
     "root": {
       "inputs": {
-        "flake-utils": "flake-utils",
         "nixpkgs": "nixpkgs"
       }
     }
diff --git a/flake.nix b/flake.nix
@@ -1,19 +1,43 @@
 {
+
   description = "ctucx.things inventory-app";
 
-  inputs = {
-    flake-utils.url = "github:numtide/flake-utils";
-    nixpkgs.url     = "github:NixOS/nixpkgs/nixos-22.11";
-  };
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
+
+  outputs = inputs: let
+    forAllSystems = function:
+      inputs.nixpkgs.lib.genAttrs [
+        "x86_64-linux"
+        "aarch64-linux"
+        "aarch64-darwin"
+      ] (system: function (import inputs.nixpkgs {
+        system   = system;
+        overlays = [ inputs.self.overlays.default ];
+      }));
 
-  outputs = { self, nixpkgs, flake-utils }: {
+  in {
 
-    nixosModule = import ./nixosModule.nix;
-    overlay     = final: prev: {
+    nixosModules.default = import ./nixosModule.nix;
+
+    packages = forAllSystems (pkgs: {
+      default      = pkgs.ctucx-things;
+      ctucx-things = pkgs.ctucx-things;
+    });
+
+    devShells = forAllSystems (pkgs: {
+      default = pkgs.mkShell {
+        nativeBuildInputs = [ pkgs.yarn pkgs.yarn2nix pkgs.php ];
+        shellHook = ''
+          export NODE_OPTIONS=--openssl-legacy-provider
+          alias serve="yarn build && php -S localhost:8080 -t public/"
+        '';
+      };
+    });
 
+    overlays.default = final: prev: {
       ctucx-things = final.mkYarnPackage rec {
         name = "ctucx-things";
-        src  = self;
+        src  = inputs.self;
 
         packageJSON = ./package.json;
         yarnLock    = ./yarn.lock;

@@ -30,29 +54,8 @@
           cp -r deps/ctucx.things/public/. $out
         '';
       };
-
     };
 
-  } // (flake-utils.lib.eachDefaultSystem (system:
-    let
-      pkgs = import nixpkgs {
-        inherit system;
-        overlays = [ self.overlay ];
-      };
-
-    in rec {
-
-      packages.default      = pkgs.ctucx-things;
-      packages.ctucx-things = pkgs.ctucx-things;
-
-      devShells.default = pkgs.mkShell {
-        nativeBuildInputs = [ pkgs.yarn pkgs.yarn2nix pkgs.php ];
-        shellHook = ''
-          export NODE_OPTIONS=--openssl-legacy-provider
-          alias serve="yarn build && php -S localhost:8080 -t public/"
-        '';
-      };
+  };
 
-    }
-  ));
-}-
\ No newline at end of file
+}