Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
51 lines (49 loc) · 1.92 KB
/
Copy pathflake.nix
File metadata and controls
51 lines (49 loc) · 1.92 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
{
description = "Voltage CLI development shell (not a release package)";
inputs = {
# 26.05 still supports Intel macOS (dropped on current nixos-unstable).
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, rust-overlay, ... }:
let
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
in {
devShells = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
# The pinned toolchain, plus llvm-tools for `scripts/crap-report.sh`. CI and
# rustup users install only the components in rust-toolchain.toml.
toolchain = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain;
rust = pkgs.rust-bin.fromRustupToolchain (toolchain // {
components = toolchain.components ++ [ "llvm-tools-preview" ];
});
in {
default = pkgs.mkShell {
packages = [
rust
pkgs.python3
pkgs.cargo-machete
];
# Build in the checkout, not the Nix store. Cargo's incremental build
# is a no-op when sources have not changed.
shellHook = ''
if [ -f Cargo.toml ] && [ -f rust-toolchain.toml ]; then
if cargo build --locked; then
export PATH="$PWD/target/debug:$PATH"
else
echo "Voltage build failed; target/debug was not added to PATH." >&2
fi
else
echo "Enter the development shell from the repository root to build voltage." >&2
fi
'';
};
});
};
}