-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
97 lines (92 loc) · 2.42 KB
/
flake.nix
File metadata and controls
97 lines (92 loc) · 2.42 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
{
description = "par2z dev shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in {
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in {
default = pkgs.stdenvNoCC.mkDerivation {
name = "par2z";
src = self;
nativeBuildInputs = [ pkgs.zig ];
dontConfigure = true;
dontFixup = true;
buildPhase = ''
export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-cache
zig build -Doptimize=ReleaseFast --prefix $out
'';
# zig build --prefix handles install
dontInstall = true;
};
});
checks = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in {
test = pkgs.stdenvNoCC.mkDerivation {
name = "par2z-test";
src = self;
nativeBuildInputs = [ pkgs.zig ];
dontConfigure = true;
dontFixup = true;
buildPhase = ''
export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-cache
zig build test-direct
'';
installPhase = "touch $out";
};
});
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
isDarwin = pkgs.stdenv.isDarwin;
valgrindPkg = if isDarwin then null else pkgs.valgrind;
linuxOnly = pkgs.lib.optionals (!isDarwin) [
pkgs.aflplusplus
pkgs.lcov
];
mktmpPkg = pkgs.writeShellScriptBin "mktmp" ''
#!/usr/bin/env bash
set -euo pipefail
if [ "''${1-}" = "--help" ] || [ "''${1-}" = "-h" ]; then
echo "usage: mktmp [--tmpdir]"
exit 0
fi
if [ "''${1-}" = "--tmpdir" ]; then
shift
fi
dir="''${TMPDIR:-/tmp}"
mktemp -d "$dir/mktmp.XXXXXX"
'';
par2TurboPkg = pkgs.writeShellScriptBin "par2-turbo" ''
exec ${pkgs.par2cmdline-turbo}/bin/par2 "$@"
'';
in {
default = pkgs.mkShell {
packages = [
pkgs.zig
pkgs.zls
pkgs.lldb
pkgs.cmake
pkgs.ninja
pkgs.pkg-config
pkgs.openssl
pkgs.par2cmdline
pkgs.luajit
par2TurboPkg
mktmpPkg
] ++ linuxOnly ++ pkgs.lib.optional (valgrindPkg != null) valgrindPkg;
shellHook = ''
echo "par2z dev shell: zig/zls/afl++/par2cmdline"
'';
};
});
};
}