-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
143 lines (118 loc) · 3.64 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
{
description = "Tool zum automatischen generieren von Protokollen und Website Posts";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
nixConfig = {
substituters = "https://attic.hhu-fscs.de/fscs-public";
trusted-public-keys = "fscs-public:MuWSWnGgABFBwdeum/8n4rJxDpzYqhgd/Vm7u3fGMig=";
};
outputs =
{
self,
nixpkgs,
crane,
rust-overlay,
flake-utils,
...
}:
let
systems = [
"aarch64-linux"
"x86_64-linux"
];
in
flake-utils.lib.eachSystem systems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
craneLib = crane.mkLib pkgs;
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type: (markdownFilter path type) || (craneLib.filterCargoSources path type);
src = lib.cleanSourceWith {
src = craneLib.path ./.;
filter = markdownOrCargo;
};
crossBuildFor =
crossSystem:
let
crossPkgs = import nixpkgs {
inherit crossSystem;
localSystem = system;
overlays = [ (import rust-overlay) ];
};
crossCraneLib = (crane.mkLib crossPkgs).overrideToolchain (p: p.rust-bin.stable.latest.default);
systemTripleMap = {
"x86_64-linux" = "x86_64-unknown-linux-gnu";
"aarch64-linux" = "aarch64-unknown-linux-gnu";
};
cargoEnvVarSystem = lib.toUpper (lib.replaceStrings [ "-" ] [ "_" ] systemTripleMap.${crossSystem});
crossExpr =
{ stdenv }:
crossCraneLib.buildPackage {
inherit src;
strictDeps = true;
nativeBuildInputs = [ stdenv.cc ];
"CARGO_TARGET_${cargoEnvVarSystem}_LINKER" = "${stdenv.cc.targetPrefix}cc";
CARGO_BUILD_TARGET = systemTripleMap.${crossSystem};
HOST_CC = "${stdenv.cc.nativePrefix}cc";
TARGET_CC = "${stdenv.cc.targetPrefix}cc";
};
in
crossPkgs.callPackage crossExpr { };
localCommonArgs = {
inherit src;
strictDeps = true;
buildInputs = [ ];
};
localCargoArtifacts = craneLib.buildDepsOnly localCommonArgs;
local-prototool-crate = craneLib.buildPackage (
localCommonArgs
// {
cargoArtifacts = localCargoArtifacts;
meta.mainProgram = "prototool";
}
);
in
{
checks = {
inherit local-prototool-crate;
my-crate-test = craneLib.cargoTest (
localCommonArgs
// {
cargoArtifacts = localCargoArtifacts;
}
);
};
packages =
{
default = local-prototool-crate;
}
// (lib.listToAttrs (
map (crossSystem: lib.nameValuePair "cross-${crossSystem}" (crossBuildFor crossSystem)) systems
));
devShells = {
default = craneLib.devShell {
nativeBuildInputs = with pkgs; [
cargo
rustc
rustfmt
cargo-semver-checks
];
};
attic = pkgs.mkShell {
nativeBuildInputs = [
pkgs.attic-client
];
};
};
}
);
}