Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
167 lines (152 loc) · 3.87 KB
/
Copy pathflake.nix
File metadata and controls
167 lines (152 loc) · 3.87 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
# SPDX-FileCopyrightText: 2025 Foundation Devices, Inc. <hello@foundation.xyz>
# SPDX-License-Identifier: GPL-3.0-or-later
{
description = "KeyOS development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
fenix,
}: let
inherit (nixpkgs) lib;
systems = [
"aarch64-darwin"
"x86_64-darwin"
"aarch64-linux"
"x86_64-linux"
];
forAllSystems = f:
lib.foldl' lib.recursiveUpdate {} (
map (
system:
lib.mapAttrs (_: value: {${system} = value;}) (f system)
)
systems
);
in
forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = ["segger-jlink-qt4-874"];
segger-jlink.acceptLicense = true;
};
};
customPackages =
(with pkgs; {
inherit just reuse taplo;
# upstream slint-lsp for CI (faster)
slint-lsp-upstream = slint-lsp;
})
// pkgs.callPackage ./nix/rust-toolchain.nix {inherit self fenix system;}
// pkgs.callPackage ./nix/slint.nix {}
// pkgs.callPackage ./nix/cosign2.nix {inherit self;}
// pkgs.callPackage ./nix/localazy.nix {}
// pkgs.callPackage ./nix/slint-runner.nix {};
buildPackages = with pkgs;
[
bc
taplo
cmake
curl
gcc-arm-embedded
gh
git
git-lfs
gnumake
just
openssl
protobuf
pkg-config
reuse
unixtools.xxd
clang
gcc
llvmPackages.libclang
llvmPackages.libcxxClang
llvmPackages.llvm
# For the SDK icon2glyph.py
(python3.withPackages (ps: [ps.pillow]))
]
++ (with customPackages; [
cosign2
rust-keyos
]);
devPackages =
buildPackages
++ (with customPackages; [
localazy
rust-analyzer
slint-runner
slint-lsp
slint-viewer
])
++ (
with pkgs;
[
mdcat
mermaid-cli
]
++ lib.optionals stdenv.isLinux [
segger-jlink
]
);
clangAttrs = {
# for bindgen in c++ libs
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
darwinPkgs = with pkgs;
lib.optionals stdenv.isDarwin [
libiconv
];
sharedLibs = with pkgs;
[
pcsclite
libusb1
zlib
]
++ darwinPkgs
++ lib.optionals stdenv.isLinux [udev fontconfig];
mkShell = packages:
pkgs.mkShellNoCC (
{
strictDeps = true;
packages = packages;
hardeningDisable = ["all"];
buildInputs = sharedLibs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath sharedLibs;
shellHook = ''
export FOUNDATION_DEVELOP_SHELL=1
# darwin xcode
unset DEVELOPER_DIR
unset SDKROOT
# unset clang env variables
unset CC
unset CXX
unset AR
unset RANLIB
'';
}
// clangAttrs
// lib.optionalAttrs pkgs.stdenv.isDarwin {
LIBRARY_PATH = lib.makeLibraryPath darwinPkgs;
}
);
in {
packages = customPackages;
formatter = pkgs.alejandra;
devShells = {
# full development shell
default = mkShell devPackages;
# minimal build shell
build = mkShell buildPackages;
};
});
}