-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflake.nix
106 lines (101 loc) · 3.09 KB
/
flake.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
97
98
99
100
101
102
103
104
105
106
{
description = "High-performance JSON to GRON (greppable, flattened JSON) converter";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05;
flake-parts.url = github:hercules-ci/flake-parts;
flake-root.url = github:srid/flake-root;
pre-commit-hooks = {
url = github:cachix/pre-commit-hooks.nix;
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = with inputs; [
flake-root.flakeModule
pre-commit-hooks.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
nativeBuildInputs = with pkgs; [cmake clang];
buildInputs = with pkgs; [curl openssl zlib];
fastgron = pkgs.stdenv.mkDerivation {
pname = "fastgron";
version = "v0.6.4";
src = ./.;
nativeBuildInputs = nativeBuildInputs;
buildInputs = buildInputs;
checkPhase = ''
runHook preCheck
env LD_LIBRARY_PATH=$PWD \
DYLD_LIBRARY_PATH=$PWD \
ctest -j$NIX_BUILD_CORES --verbose
runHook postCheck
'';
meta = with pkgs.lib; {
description = "High-performance JSON to GRON (greppable, flattened JSON) converter";
homepage = "https://github.com/adamritter/fastgron";
license = licenses.mit;
maintainers = with maintainers; [lafrenierejm];
mainProgram = "fastgron";
};
};
fastgronWithFallback = pkgs.writeShellApplication {
name = "fastgron-with-fallback";
runtimeInputs = [fastgron pkgs.mktemp];
text = ''
if [ ! "$#" -eq 1 ]; then
fastgron --help >&2 && exit 1
else
(fastgron "$1" 2>/dev/null || cat "$1") 2>/dev/null
fi'';
};
in {
# Pre-commit hooks.
pre-commit = {
check.enable = true;
settings.hooks = {
alejandra.enable = true;
clang-format = {
enable = true;
excludes = ["extern/.*"];
};
};
};
# `nix build`
packages = {
inherit fastgron fastgronWithFallback;
default = fastgron;
};
# `nix run`
apps = let
fastgron = {
type = "app";
program = "${self'.packages.fastgron}/bin/fastgron";
};
fastgronWithFallback = {
type = "app";
program = "${self'.packages.fastgronWithFallback}/bin/fastgron-with-fallback";
};
in {
inherit fastgron fastgronWithFallback;
default = fastgron;
};
# `nix develop`
devShells.default = pkgs.mkShell {
inputsFrom = [config.pre-commit.devShell];
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
};
};
};
}