-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathflake.nix
More file actions
133 lines (124 loc) · 4.08 KB
/
Copy pathflake.nix
File metadata and controls
133 lines (124 loc) · 4.08 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
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
{
description = "OpenShell development environment";
nixConfig = {
extra-substituters = [ "https://openshell.cachix.org" ];
extra-trusted-public-keys = [
"openshell.cachix.org-1:OAr5MunsfH5PZvUsfD08OtGx5RtcwdNZGJdU5FqLm5w="
];
};
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Keep the QEMU and OVMF runtime used by Apple Silicon test guests on a
# known-good release. Development shells and cross toolchains use nixpkgs.
nixpkgs-test-guest.url = "github:NixOS/nixpkgs/0954f7ee2f6bb3dc7d4e3d0d8bcb8fd4bde4cfc5";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
flake-utils,
nixpkgs,
nixpkgs-test-guest,
treefmt-nix,
rust-overlay,
...
}:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
testGuestPkgs = import nixpkgs-test-guest { inherit system; };
commonDevShellPackages = with pkgs; [
actionlint
cargo-auditable
cargo-deny
cargo-nextest
# Assemble Debian artifacts on macOS and Linux.
dpkg
# Build and inspect ext4 images in VM driver tests.
e2fsprogs
git
# Required to find packages.
pkg-config
# Coverage.
lcov
kubernetes-helm
syft
trivy
uv
yq-go
zizmor
zstd
];
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
};
rustToolchain =
((pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
targets = map (toolchain: toolchain.target) (builtins.attrValues toolchains);
}).overrideAttrs
{
propagatedBuildInputs = [ ];
depsHostHostPropagated = [ ];
depsTargetTargetPropagated = [ ];
};
buildInputs = { pkgs, stdenv }: [
(pkgs.callPackage ./nix/pkgs/z3.nix { inherit stdenv; })
(pkgs.callPackage ./nix/pkgs/aws-lc.nix { inherit stdenv; })
];
inherit (import ./nix/toolchain) mkToolchain;
toolchains = {
x86_64-gnu = mkToolchain {
pkgs = pkgs.pkgsCross.gnu64;
inherit buildInputs;
};
x86_64-musl = mkToolchain {
pkgs = pkgs.pkgsCross.musl64;
inherit buildInputs;
};
aarch64-gnu = mkToolchain {
pkgs = pkgs.pkgsCross.aarch64-multiplatform;
inherit buildInputs;
};
aarch64-musl = mkToolchain {
pkgs = pkgs.pkgsCross.aarch64-multiplatform-musl;
inherit buildInputs;
};
}
// pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
aarch64-darwin = mkToolchain {
inherit pkgs buildInputs;
};
};
vmRuntime = pkgs.callPackage ./nix/pkgs/vm-runtime.nix { };
testGuest = import ./nix/test-guest {
inherit pkgs;
qemuPkgs = testGuestPkgs;
firmwarePkgs = testGuestPkgs;
};
in
{
apps.test-guest = testGuest.app;
apps.test-guest-cache = testGuest.cacheApp;
packages.vm-runtime = vmRuntime;
devShells.default = pkgs.mkShellNoCC {
packages = [ rustToolchain ] ++ commonDevShellPackages;
env = pkgs.lib.foldl' (env: toolchain: env // toolchain.env) { } (builtins.attrValues toolchains);
};
formatter = treefmtEval.config.build.wrapper;
}
);
}