-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
178 lines (164 loc) · 5.09 KB
/
Copy pathflake.nix
File metadata and controls
178 lines (164 loc) · 5.09 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
description = "A very basic flake";
inputs = {
flake-utils = {
url = "github:numtide/flake-utils";
};
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
crane
}:
{
nixosConfigurations = {
orangepi5plus = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
./sdcard.nix
./hardware-configuration.nix
./configuration.nix
{
nixpkgs.buildPlatform = "x86_64-linux";
nixpkgs.hostPlatform = "aarch64-linux";
}
];
specialArgs = {
inherit nixpkgs;
};
};
};
}
// flake-utils.lib.eachDefaultSystem (
system:
let
crossSystem = "aarch64-linux";
pkgs = (
import nixpkgs {
inherit crossSystem system;
overlays = [ (import rust-overlay) ];
}
);
craneLib = crane.mkLib pkgs;
crateExpression =
{
openssl,
libiconv,
lib,
pkg-config,
stdenv,
}:
craneLib.buildPackage {
src = craneLib.cleanCargoSource ./.;
DEP_JXL_LIB = "${pkgs.libjxl.out}";
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
strictDeps = true;
# Dependencies which need to be build for the current platform
# on which we are doing the cross compilation. In this case,
# pkg-config needs to run on the build platform so that the build
# script can find the location of openssl. Note that we don't
# need to specify the rustToolchain here since it was already
# overridden above.
nativeBuildInputs = with pkgs; [
pkg-config
clang-tools
libgcc
clang
libllvm
libclang
gcc
rust-bindgen
]
++ lib.optionals stdenv.buildPlatform.isDarwin [
libiconv
];
# Dependencies which need to be built for the platform on which
# the binary will run. In this case, we need to compile openssl
# so that it can be linked with our executable.
buildInputs = [
# Add additional build inputs here
openssl
];
};
# Common arguments can be set here to avoid repeating them later
# Note: changes here will rebuild all dependency crates
# commonArgs = {
# src = craneLib.cleanCargoSource ./.;
# strictDeps = true;
# DEP_JXL_LIB = "${pkgs.libjxl.out}";
# LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
# nativeBuildInputs = with pkgs; [
# # Add extra native build inputs here, etc.
# # pkg-config
# pkgs.pkg-config
# pkgs.clang-tools
# pkgs.libgcc
# pkgs.clang
# pkgs.libllvm
# pkgs.libclang
# pkgs.gcc
# pkgs.rust-bindgen
# ];
# buildInputs = [
# # Add additional build inputs here
# pkgs.libjxl
# pkgs.libcamera
# ]
# ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# # Additional darwin specific inputs can be set here
# pkgs.libiconv
# ];
# };
my-crate = pkgs.callPackage crateExpression { };
in
{
packages.default = my-crate;
packages.sdcard = self.nixosConfigurations.orangepi5plus.config.system.build.sdImage;
apps.default = flake-utils.lib.mkApp {
drv = pkgs.writeScriptBin "my-app" ''
${pkgs.pkgsBuildBuild.qemu}/bin/qemu-aarch64 ${my-crate}/bin/cross-rust-overlay
'';
};
devShells.default =
with pkgs;
mkShell {
buildInputs = [
cargo
rustc
rustfmt
pre-commit
rustPackages.clippy
];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
DEP_JXL_LIB = "${pkgs.libjxl.out}";
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
packages = [
# Generic DevTools
# clang-tools must be first before clang
(pkgs.writeShellScriptBin "_exec" ''
#!/bin/bash
export PORT=3001
cargo run --release
'')
pkgs.pkg-config
pkgs.clang-tools
pkgs.libjxl
pkgs.libllvm
pkgs.libclang
pkgs.rust-bindgen
pkgs.libcamera
pkgs.nixfmt
];
};
}
);
}