forked from slint-ui/slint-cpp-templates-stm32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
121 lines (107 loc) · 3.73 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
description = "Slint C++ Bare Metal Development Environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, nixpkgs-unstable, rust-overlay }:
let
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
in
{
devShells = builtins.listToAttrs (map (system: {
name = system;
value = let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
(final: prev: {
unstable = import nixpkgs-unstable {
inherit system;
};
})
];
};
slint = pkgs.stdenv.mkDerivation rec {
name = "slint";
src = pkgs.fetchFromGitHub {
owner = "scristall-bennu";
repo = "slint";
rev = "5bac14222fb8725fafb17918c623975a33c1d413";
sha256 = "9NPW0hwYtPmXNHTSnNF4lXF1rwWsI7wNCFL6hzv5AlY=";
};
cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
inherit src;
hash = "sha256-V/ewx07fiNfSSI6eI7p3pZfczSCn5N7P7UmoxkKuYIs=";
};
buildInputs = with pkgs; [
cargo
rustPlatform.cargoSetupHook
cmake
gcc-arm-embedded
unstable.corrosion
ninja
rust-cbindgen
(rust-bin.stable."1.83.0".default.override {
extensions = [ "rust-src" ];
targets = [ "thumbv7em-none-eabihf" ];
})
];
buildPhase = ''
# Build and install firmware target (thumbv8m.main-none-eabihf)
mkdir -p build-fw
cd build-fw
cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc \
-DCMAKE_CXX_COMPILER=arm-none-eabi-g++ \
-DCMAKE_AR=arm-none-eabi-ar \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DRust_CARGO_TARGET=thumbv7em-none-eabihf \
-DSLINT_FEATURE_FREESTANDING=ON \
-DSLINT_FEATURE_EXPERIMENTAL=ON \
-DBUILD_SHARED_LIBS=OFF \
-DSLINT_FEATURE_RENDERER_SOFTWARE=ON \
-DCMAKE_INSTALL_PREFIX=$out \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_SYSTEM_PROCESSOR=ARM \
--debug-find-pkg=Corrosion \
..
make
make install
'';
dontUseCmakeConfigure = true;
dontFixup = true;
dontInstall = true;
};
in
{
default = pkgs.mkShell {
buildInputs = with pkgs; [
gcc
gnumake
cmake
git
gcc-arm-embedded
pkg-config
rust-cbindgen
(pkgs.rust-bin.stable."1.83.0".default.override {
extensions = [ "rust-src" ];
targets = [ "thumbv7em-none-eabihf" ];
})
fontconfig
slint
];
shellHook = ''
export PATH=${pkgs.gcc-arm-embedded}/bin:$PATH
# Clean up these variables -- they often confuse cross builds
unset CMAKE_INCLUDE_PATH
unset CMAKE_LIBRARY_PATH
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath (with pkgs; [ fontconfig ])}"
'';
};
};
}) systems);
};
}