-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
136 lines (126 loc) · 3.58 KB
/
Copy pathflake.nix
File metadata and controls
136 lines (126 loc) · 3.58 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
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
{
description = "atxt development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
keel = {
url = "github:spoke-sh/keel";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
sift = {
url = "github:rupurt/sift";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
inputs.keel.follows = "keel";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
crane,
keel,
sift,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [
"clippy"
"rustfmt"
"rust-src"
"rust-analyzer"
"llvm-tools"
];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = craneLib.cleanCargoSource ./.;
keelSrc = keel.outPath;
keelPkg = pkgs.callPackage "${keelSrc}/nix/keel.nix" {
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
};
siftPkg = sift.packages.${system}.sift;
commonArgs = {
inherit src;
strictDeps = true;
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
outputHashes = {
"txtplot-0.1.0" = "sha256-bC6zo1yhJg41iz69XbXqwIKOfNVXwFke0vzcSMbqvFE=";
};
});
package = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
in
{
packages = {
default = package;
keel = keelPkg;
sift = siftPkg;
};
devShells.default = pkgs.mkShell {
packages = [
rustToolchain
pkgs.cargo-nextest
pkgs.cargo-llvm-cov
pkgs.just
pkgs.ffmpeg
pkgs.util-linux
pkgs.vhs
pkgs.pkg-config
keelPkg
siftPkg
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.mold
];
shellHook =
''
export CARGO_TARGET_DIR="$HOME/.cache/cargo-target/atxt"
''
+ pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
export TMPDIR=/var/tmp
''
+ pkgs.lib.optionalString pkgs.stdenv.isLinux ''
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
'';
};
checks = {
inherit package;
clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features -- -W clippy::all -D warnings";
}
);
test = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
}
);
};
}
);
}