forked from demostf/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
149 lines (138 loc) · 4.35 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
inputs = {
nixpkgs.url = "nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "flake-utils";
cross-naersk.url = "github:icewind1991/cross-naersk";
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
};
outputs = {
self,
flake-utils,
cross-naersk,
naersk,
nixpkgs,
rust-overlay,
...
}: let
inherit (flake-utils.lib) eachDefaultSystem eachSystem;
in (eachDefaultSystem (system: let
overlays = [
(import rust-overlay)
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
};
lib = pkgs.lib;
hostTarget = pkgs.hostPlatform.config;
targets = [
"x86_64-unknown-linux-musl"
"i686-unknown-linux-musl"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
"x86_64-pc-windows-gnu"
hostTarget
];
releaseTargets = lib.lists.remove hostTarget targets;
artifactForTarget = target: "parse_demo${cross-naersk'.execSufficForTarget target}";
assetNameForTarget = target: "parser-${builtins.replaceStrings ["-unknown" "-gnu" "-musl" "eabihf" "-pc"] ["" "" "" "" ""] target}${cross-naersk'.execSufficForTarget target}";
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
nearskOpt = {
inherit (pkgs.demostf-parser) pname src;
};
buildMatrix = targets: {
include =
builtins.map (target: {
inherit target;
artifact_name = artifactForTarget target;
asset_name = assetNameForTarget target;
})
targets;
};
hostNaersk = cross-naersk'.hostNaersk;
mkHydraJobs = system: {
parser = derivation {
name = "parser";
builder = "mybuilder";
inherit system;
};
nested = {
attribute = derivation {
name = "nested-attribute";
builder = "mybuilder";
inherit system;
};
};
};
in rec {
packages =
lib.attrsets.genAttrs targets (target:
(cross-naersk'.buildPackage target) (nearskOpt
// {
overrideMain = args:
args
// {
preConfigure = ''
cargo_build_options="$cargo_build_options --bin parse_demo"
'';
};
}))
// rec {
inherit (pkgs) demostf-parser demostf-parser-codegen demostf-parser-codegen-events demostf-parser-codegen-props;
check = hostNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
clippy = hostNaersk.buildPackage (nearskOpt
// {
mode = "clippy";
});
test = hostNaersk.buildPackage (nearskOpt
// {
release = false;
mode = "test";
});
default = demostf-parser;
};
inherit targets;
inherit releaseTargets;
matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;
apps = rec {
tf-demo-parser = flake-utils.lib.mkApp {
drv = packages.tf-demo-parser;
exePath = "/bin/parse_demo";
};
default = tf-demo-parser;
};
checks = {
fmt-check = pkgs.stdenvNoCC.mkDerivation {
name = "fmt-check";
src = ./.;
doCheck = true;
dontBuild = true;
nativeBuildInputs = with pkgs; [alejandra shellcheck shfmt];
checkPhase = ''
alejandra -c .
'';
installPhase = ''
mkdir $out
'';
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [rust-bin.stable.latest.default bacon cargo-edit cargo-outdated rustfmt clippy cargo-audit hyperfine valgrind cargo-insta cargo-semver-checks];
};
})
// {
overlays.default = import ./overlay.nix;
hydraJobs = eachSystem ["x86_64-linux" "aarch64-linux"] (system: {
parser = self.packages.${system}.tf-demo-parser;
});
});
}