-
Notifications
You must be signed in to change notification settings - Fork 16
/
flake.nix
97 lines (86 loc) · 3.8 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
#
# Copyright 2024, UNSW
# SPDX-License-Identifier: BSD-2-Clause
#
{
description = "A flake for building sDDF";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
zig-overlay.url = "github:mitchellh/zig-overlay";
};
outputs = { nixpkgs, zig-overlay, ... }:
let
microkit-version = "1.4.1";
microkit-platforms = {
aarch64-darwin = "macos-aarch64";
x86_64-darwin = "macos-x86-64";
x86_64-linux = "linux-x86-64";
};
forAllSystems = with nixpkgs.lib; genAttrs (builtins.attrNames microkit-platforms);
in
{
# Shell for developing sDDF.
# Includes dependencies for building sDDF and its
# examples.
devShells = forAllSystems
(system: {
default =
let
pkgs = import nixpkgs {
inherit system;
};
llvm = pkgs.llvmPackages_18;
zig = zig-overlay.packages.${system}."0.13.0";
in
# mkShellNoCC, because we do not want the cc from stdenv to leak into this shell
pkgs.mkShellNoCC rec {
name = "sddf-dev";
microkit-platform = microkit-platforms.${system} or (throw "Unsupported system: ${system}");
env.MICROKIT_SDK = pkgs.fetchzip {
url = "https://github.com/seL4/microkit/releases/download/${microkit-version}/microkit-sdk-${microkit-version}-${microkit-platform}.tar.gz";
hash = {
aarch64-darwin = "sha256-QMgIpQYGFeu7Rm+KNS9vijAksuW4WXf+TJnLVtto6Lw=";
x86_64-darwin = "sha256-9WHEVkmSEijBiVsCWRcoSBhu4TPPzItTAx/P70/7UyM=";
x86_64-linux = "sha256-VpljwkGAPl/vkTBFoG6j2ivD9CMy+u3TI7pwdlz+Zho=";
}.${system} or (throw "Unsupported system: ${system}");
};
nativeBuildInputs = with pkgs; [
pkgsCross.aarch64-embedded.stdenv.cc.bintools
pkgsCross.aarch64-embedded.stdenv.cc
zig
qemu
gnumake
dosfstools
imagemagick
(symlinkJoin {
name = "clang-complete";
paths = llvm.clang-unwrapped.all;
# Clang searches up from the directory where it sits to find its built-in
# headers. The `symlinkJoin` creates a symlink to the clang binary, and that
# symlink is what ends up in your PATH from this shell. However, that symlink's
# destination, the clang binary file, still resides in its own nix store
# entry (`llvm.clang-unwrapped`), isolated from the header files (found in
# `llvm.clang-unwrapped.lib` under `lib/clang/18/include`). So when search up its
# parent directories, no built-in headers are found.
#
# By copying over the clang binary over the symlinks in the realisation of the
# `symlinkJoin`, we can fix this; now the search mechanism looks up the parent
# directories of the `clang` binary (which is a copy created by below command),
# until it finds the aforementioned `lib/clang/18/include` (where the `lib` is
# actually a symlink to `llvm.clang-unwrapped.lib + "/lib"`).
postBuild = ''
cp --remove-destination -- ${llvm.clang-unwrapped}/bin/* $out/bin/
'';
})
# for git-clang-format.
llvm.libclang.python
llvm.lld
llvm.libllvm
];
# To avoid Nix adding compiler flags that are not available on a freestanding
# environment.
hardeningDisable = [ "all" ];
};
});
};
}