-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathflake.nix
More file actions
99 lines (84 loc) · 2.59 KB
/
Copy pathflake.nix
File metadata and controls
99 lines (84 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
description = "pnpm plugin for the asdf version manager";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [./treefmt.nix];
systems = [
"aarch64-darwin"
"x86_64-linux"
"aarch64-linux"
];
perSystem = {
pkgs,
lib,
system,
...
}: let
mkCheck = name: nodejs:
pkgs.stdenvNoCC.mkDerivation {
name = "bats-${name}-${system}";
__impure = true;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./bin
./tests
./LICENSE
];
};
nativeBuildInputs = [pkgs.git];
nativeCheckInputs = [
pkgs.asdf-vm
pkgs.mise
pkgs.bats
pkgs.curl
pkgs.git
pkgs.gnutar
pkgs.coreutils
pkgs.gnugrep
pkgs.gnused
nodejs
];
dontUnpack = true;
dontConfigure = true;
dontFixup = true;
doCheck = true;
dontInstall = true;
buildPhase = ''
mkdir -p $out
cp -r $src/bin $src/LICENSE $out/
chmod -R +x $out/bin/*
git -C $out init
git -C $out config user.name "Test Runner"
git -C $out config user.email "test@example.com"
# Patch shebangs (so asdf plugin test gets them when cloning)
patchShebangs $out/bin/*
git -C $out add .
git -C $out commit -m "Test snapshot" >/dev/null
'';
SSL_CERT_FILE =
if builtins.getEnv "SSL_CERT_FILE" != ""
then builtins.getEnv "SSL_CERT_FILE"
else "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
checkPhase = ''
export ASDF_PNPM_PLUGIN_REPO="$out"
export HOME=$(mktemp -d)
export NODE_EXTRA_CA_CERTS="$SSL_CERT_FILE"
declare -fx patchShebangs isScript
bats $src/tests/*.bats
'';
};
in {
checks = {
#node20 = mkCheck "node20" pkgs.nodejs_20;
#node22 = mkCheck "node22" pkgs.nodejs_22;
node24 = mkCheck "node24" pkgs.nodejs_24;
};
};
};
}