simplify flake and add checks

This commit is contained in:
Abel Luck 2026-02-26 11:37:53 +01:00
parent affaa13e4b
commit d8f56bd942
2 changed files with 41 additions and 66 deletions

View file

@ -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
'';
};
});
};
}