-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
118 lines (102 loc) · 2.71 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
{
description = "GReX T0 Nix Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
psrdada = {
url = "github:kiranshila/psrdada.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = {
self,
nixpkgs,
flake-utils,
psrdada,
crane,
fenix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [fenix.overlays.default];
};
inherit (pkgs) lib;
craneLib =
(crane.mkLib pkgs).overrideToolchain
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
]);
# T0 depends on an fpg file to build the SNAP interface,
# so that must be deterministically included as well
fpgFilter = path: _type: null != builtins.match ".*fpg$" path;
fpgOrCargo = path: type: (fpgFilter path type) || (craneLib.filterCargoSources path type);
src = lib.cleanSourceWith {
src = craneLib.path ./.; # The original, unfiltered source
filter = fpgOrCargo;
};
commonArgs = {
inherit src;
nativeBuildInputs = with pkgs; [
rustPlatform.bindgenHook
pkg-config
];
buildInputs = with pkgs; [
netcdf
hdf5
psrdada.packages.${system}.default
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
my-crate = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
NIX_OUTPATH_USED_AS_RANDOM_SEED = "plsfindfrb";
});
in {
checks = {
inherit my-crate;
my-crate-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
my-crate-fmt = craneLib.cargoFmt {inherit src;};
};
packages = {
default = my-crate;
inherit my-crate;
};
apps.default = flake-utils.lib.mkApp {drv = my-crate;};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages = with pkgs; [
alejandra
cargo-machete
cargo-show-asm
cargo-outdated
rust-analyzer-nightly
];
};
});
}