-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
54 lines (53 loc) · 1.3 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
fenix,
nixpkgs,
...
}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
rust = fenix.packages.${system};
toolchain = rust.stable.withComponents [
"rustc"
"rust-std"
"cargo"
"rust-docs"
"rustfmt"
"clippy"
"rust-src"
"rust-analyzer"
];
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = cargoToml.package.name;
version = cargoToml.package.version;
in {
packages.${system} = rec {
default = rustPlatform.buildRustPackage {
inherit pname version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
image = pkgs.dockerTools.buildImage {
name = default.pname;
config.Entrypoint = ["${default}/bin/huf"];
};
};
devShells.${system}.default = pkgs.mkShell {
name = pname;
buildInputs = [toolchain];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
};
formatter.${system} = pkgs.alejandra;
};
}