ctucx.git: trainsearch

web based trip-planner, fork of https://cyberchaos.dev/yuka/trainsearch

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

flake: refactor, remove `flake-utils` dependency
2 files changed, 40 insertions(+), 74 deletions(-)
M
flake.lock
|
34
----------------------------------
M
flake.nix
|
80
++++++++++++++++++++++++++++++++++++++++----------------------------------------
diff --git a/flake.lock b/flake.lock
@@ -1,23 +1,5 @@
 {
   "nodes": {
-    "flake-utils": {
-      "inputs": {
-        "systems": "systems"
-      },
-      "locked": {
-        "lastModified": 1731533236,
-        "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
-        "type": "github"
-      },
-      "original": {
-        "owner": "numtide",
-        "repo": "flake-utils",
-        "type": "github"
-      }
-    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1737299813,

@@ -36,24 +18,8 @@
     },
     "root": {
       "inputs": {
-        "flake-utils": "flake-utils",
         "nixpkgs": "nixpkgs"
       }
-    },
-    "systems": {
-      "locked": {
-        "lastModified": 1681028828,
-        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
-        "owner": "nix-systems",
-        "repo": "default",
-        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-systems",
-        "repo": "default",
-        "type": "github"
-      }
     }
   },
   "root": "root",
diff --git a/flake.nix b/flake.nix
@@ -2,59 +2,60 @@
 
   description = "trainsearch";
 
-  inputs = {
-    flake-utils.url = "github:numtide/flake-utils";
-    nixpkgs.url     = "github:NixOS/nixpkgs/nixos-24.11";
-  };
-
-  outputs = { self, nixpkgs, flake-utils }: {
-
-    overlay = final: prev: {
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.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 ];
+      }));
+
+  in {
+
+    packages = forAllSystems (pkgs: {
+      default     = pkgs.trainsearch;
+      trainsearch = pkgs.trainsearch;
+    });
+
+    devShells = forAllSystems (pkgs: {
+      default = pkgs.mkShell {
+        buildInputs = with pkgs; [
+          nodejs
+          nodePackages.webpack
+          nodePackages.webpack-cli
+          nodePackages.webpack-dev-server
+        ];
+        shellHook = ''
+          export NODE_OPTIONS=--openssl-legacy-provider
+        '';
+      };
+    });
 
+    overlays.default = final: prev: {
       trainsearch = final.buildNpmPackage {
         name = "trainsearch";
-        src  = self;
+        src  = inputs.self;
 
         npmDepsHash = "sha256-anEajLsr+iiZ1nYLBerc7VqJops5Ln2mn9EN+x1zVts=";
         makeCacheWritable = true;
 
         npmBuildScript = "build";
 
-        GIT_VERSION    = if (self.sourceInfo ? shortRev) then self.sourceInfo.shortRev else "dirty";
-        GIT_COMMIT     = if (self.sourceInfo ? rev)      then self.sourceInfo.rev      else "dirty";
-        GIT_COMMITDATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" self.lastModifiedDate);
+        GIT_VERSION    = if (inputs.self.sourceInfo ? shortRev) then inputs.self.sourceInfo.shortRev else "dirty";
+        GIT_COMMIT     = if (inputs.self.sourceInfo ? rev)      then inputs.self.sourceInfo.rev      else "dirty";
+        GIT_COMMITDATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" inputs.self.lastModifiedDate);
 
         installPhase = ''
           cp -r dist $out
         '';
       };
-
     };
 
-  } // (flake-utils.lib.eachDefaultSystem (system:
-    let
-      pkgs = import nixpkgs {
-        inherit system;
-        overlays = [ self.overlay ];
-      };
-
-    in rec {
-
-      packages.default     = pkgs.trainsearch;
-      packages.trainsearch = pkgs.trainsearch;
-
-      devShells.default = pkgs.mkShell {
-        buildInputs = with pkgs; [
-          nodejs
-          nodePackages.webpack
-          nodePackages.webpack-cli
-          nodePackages.webpack-dev-server
-        ];
-        shellHook = ''
-          export NODE_OPTIONS=--openssl-legacy-provider
-        '';
-      };
+  };
 
-    }
-  ));
-}-
\ No newline at end of file
+}