From d8f56bd942713b86d44d7fbb33cd88f47d86a201 Mon Sep 17 00:00:00 2001 From: Abel Luck Date: Thu, 26 Feb 2026 11:37:53 +0100 Subject: [PATCH] simplify flake and add checks --- flake.lock | 34 ------------------------- flake.nix | 73 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 66 deletions(-) diff --git a/flake.lock b/flake.lock index 4cd654f..d37a53a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1769996383, - "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1771848320, @@ -32,24 +14,8 @@ "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1769909678, - "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "72716169fe93074c333e8d0173151350670b824c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "root": { "inputs": { - "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index af03a3d..6e49ac6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,42 +1,51 @@ { - inputs = { - nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; # tracks nixpkgs unstable branch - flake-parts.url = "github:hercules-ci/flake-parts"; - }; + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; outputs = - inputs@{ flake-parts, ... }: - # https://flake.parts/module-arguments.html - flake-parts.lib.mkFlake { inherit inputs; } { - flake = { - # Put your original flake attributes here. - }; + { self, nixpkgs }: + let systems = [ - # systems for which you want to build the `perSystem` attributes "x86_64-linux" "aarch64-darwin" ]; - perSystem = - { - config, - self', - inputs', - pkgs, - system, - ... - }: - { - devShells = { - default = pkgs.mkShell { - packages = with pkgs; [ - wrangler - nodejs_22 - ]; - shellHook = '' - export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt - ''; - }; - }; + forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); + in + { + checks = forAllSystems (pkgs: { + nix-cache-tests = pkgs.buildNpmPackage { + pname = "nix-cache-tests"; + version = "0.0.0"; + src = ./nix-cache; + npmDepsHash = "sha256-bIujU7pZa1ExCZOMOoxsTeLDSF1GuPN/oMSgiMhY/04="; + dontBuild = true; + doCheck = true; + nativeBuildInputs = [ pkgs.patchelf ]; + checkPhase = '' + runHook preCheck + binary=$(find node_modules -path '*/workerd-linux-64/bin/workerd' -type f) + if [ -n "$binary" ]; then + patchelf --set-interpreter "$(cat ${pkgs.stdenv.cc}/nix-support/dynamic-linker)" "$binary" + fi + npm test -- --run + runHook postCheck + ''; + installPhase = '' + touch $out + ''; }; + devShell = self.devShells.${pkgs.stdenv.hostPlatform.system}.default; + }); + + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + wrangler + nodejs_22 + ]; + shellHook = '' + export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt + ''; + }; + }); }; }