forked from oxidecomputer/humility
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
86 lines (76 loc) · 2.36 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
{
description = "Flake shell to open Humility dev environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-overlay.inputs.flake-utils.follows = "flake-utils";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
self,
nixpkgs,
rust-overlay,
pre-commit-hooks,
flake-utils,
}: (flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
humility-overlay = final: prev: {
cargo = rust;
rustc = rust;
humility = final.callPackage ./humility.nix {
cargo = rust;
src = self;
version = "0.9.5";
inherit (prev.darwin.apple_sdk.frameworks) AppKit;
};
};
humility-overlays = [humility-overlay];
humility-pkgs = import nixpkgs {
inherit system;
overlays = humility-overlays;
};
pre-commit-checks = pre-commit-hooks.lib.${system}.run {
src = pkgs.lib.cleanSource ./.;
hooks = {
cargofmt = {
enable = true;
name = "cargo fmt";
entry = "${rust}/bin/cargo fmt --check --all";
files = "\\.rs$";
pass_filenames = false;
};
};
};
in {
packages = flake-utils.lib.flattenTree {
humility = humility-pkgs.humility;
default = humility-pkgs.humility;
};
devShells.default = pkgs.mkShell {
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
export PATH="$(pwd)/.cargo/bin:$PATH"
${pre-commit-checks.shellHook}
'';
nativeBuildInputs = with pkgs;
[
rust
cargo-readme
openocd
libusb1
]
# this is needed for libudev
++ lib.optionals pkgs.stdenv.isLinux [pkgs.systemd]
++ lib.optionals stdenv.isDarwin [darwin.apple_sdk.frameworks.AppKit];
};
checks = {
humility = humility-pkgs.humility.override {doCheck = true;};
};
}));
}