-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdunwrap.nix
96 lines (79 loc) · 1.88 KB
/
mdunwrap.nix
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
{ deno
, cacert
, stdenv
, lib
}:
let
entrypoint = "main.ts";
testFiles = [
"unwrap_test.ts"
];
vendorHash = "sha256-1XxJtHqjtqWUaLoXA5lQWA/dnXIIPXnca+KT15aXm3Q=";
vendor = stdenv.mkDerivation {
name = "mdunwrap-vendor";
outputHash = vendorHash;
outputHashMode = "recursive";
src = ./.;
nativeBuildInputs = [ deno cacert ];
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
"SOCKS_SERVER"
];
dontConfigure = true;
doCheck = false;
dontFixup = true;
buildPhase = ''
runHook preBuild
export DENO_DIR="$TMPDIR/deno"
deno vendor --output=vendor ${entrypoint} ${builtins.concatStringsSep " " testFiles}
mkdir -p vendor
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r --reflink=auto vendor $out
runHook postInstall
'';
};
in
stdenv.mkDerivation {
pname = "mdunwrap";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ deno ];
dontConfigure = true;
dontFixup = true;
buildPhase = ''
runHook preBuild
export DENO_DIR="$TMPDIR/deno"
deno compile \
--output=mdunwrap \
--no-remote \
--import-map=${vendor}/import_map.json \
--allow-read --allow-write \
${entrypoint}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp --reflink=auto mdunwrap $out/bin/
runHook postInstall
'';
doCheck = true;
checkPhase = ''
runHook preCheck
deno test \
--no-remote \
--import-map=${vendor}/import_map.json \
--allow-read=testdata \
${builtins.concatStringsSep " " testFiles}
runHook postCheck
'';
passthru.vendor = vendor;
meta = with lib; {
description = "Markdown unwrapper";
homepage = "https://github.com/zombiezen/mdunwrap";
license = licenses.asl20;
maintainers = with maintainers; [ zombiezen ];
};
}