-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
92 lines (83 loc) · 2.47 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
87
88
89
90
91
92
{
description = "Generate deterministic lockfiles for PlatformIO projects";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-parts,
treefmt-nix,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
imports = [ inputs.treefmt-nix.flakeModule ];
perSystem =
{
config,
system,
inputs',
pkgs,
lib,
...
}:
(
let
platformio2nix = pkgs.rustPlatform.buildRustPackage {
pname = "platformio2nix";
version = "0.2.0";
src = ./cli;
cargoLock.lockFile = ./cli/Cargo.lock;
nativeBuildInputs =
with pkgs;
[ pkg-config ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];
buildInputs = with pkgs; [ openssl ];
};
in
{
packages = rec {
default = platformio2nix;
inherit platformio2nix;
};
treefmt = import ./treefmt.nix;
devShells.default = pkgs.mkShell {
inherit (platformio2nix) nativeBuildInputs buildInputs;
packages =
[ config.treefmt.build.wrapper ]
++ (with pkgs; [
cargo
clippy
rust-analyzer
rustfmt
platformio
# for convenience when updating examples
(writeShellScriptBin "platformio2nix" ''
cargo run --manifest-path "$FLAKE_ROOT/cli/Cargo.toml" -- "$@"
'')
]);
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.openssl ];
PLATFORMIO_CORE_DIR = ".pio";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};
}
);
flake = {
overlays.default = final: prev: {
inherit (self.packages.${final.system}) platformio2nix;
makePlatformIOSetupHook = final.callPackage ./setup-hook.nix { };
};
};
};
}