forked from JoNil/elf2uf2-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
80 lines (64 loc) · 2.03 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
};
outputs = inputs @ { self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.devshell.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-darwin"
];
perSystem = { system, config, pkgs, ... }:
let
native-toolchain = inputs.fenix.packages.${system}.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain native-toolchain;
my-crate = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
doCheck = false;
buildInputs = [
# Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.darwin.apple_sdk.frameworks.IOKit
pkgs.libiconv
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
in
rec {
packages.elf2uf2_rs = my-crate;
apps.elf2uf2_rs.program = "${my-crate}/bin/elf2uf2-rs";
apps.default = apps.elf2uf2_rs;
overlayAttrs = {
inherit (config.packages) elf2uf2_rs;
};
devshells.default = {
packagesFrom = [ my-crate ];
packages = [
inputs.fenix.packages.${system}.rust-analyzer
];
};
};
};
}