-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathflake.nix
More file actions
134 lines (134 loc) · 4.21 KB
/
Copy pathflake.nix
File metadata and controls
134 lines (134 loc) · 4.21 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
{
description = "Cardwire, a GPU manager for laptop and workstation";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
fenix.url = "github:nix-community/fenix/monthly";
git-hooks.url = "github:cachix/git-hooks.nix";
};
outputs =
{
self,
nixpkgs,
fenix,
git-hooks,
}:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = fn: nixpkgs.lib.genAttrs supportedSystems (system: fn system);
pkgs = system: nixpkgs.legacyPackages.${system};
fenixpkgs = system: fenix.packages.${system};
toolchainFor =
system:
let
tc = (fenixpkgs system).toolchainOf {
channel = "nightly";
date = "2026-08-12";
sha256 = "sha256-LQDrWx1txtq4YH8MaJENr7uH1a8W6TwCN464Xjda3Ss=";
};
in
(fenixpkgs system).combine [
tc.cargo
tc.rustc
tc.rustfmt
tc.clippy
tc.rust-src
tc.llvm-tools-preview
];
in
{
packages = forAllSystems (system: {
default = (pkgs system).callPackage ./nix { toolchain = toolchainFor system; };
vm-test = self.checks.${system}.vm-ci-2gpu;
vm-test-2gpu = self.checks.${system}.vm-ci-2gpu;
vm-test-3gpu = self.checks.${system}.vm-ci-3gpu;
vm-test-15gpu = self.checks.${system}.vm-ci-15gpu;
});
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
config = self.checks.${system}.pre-commit-check.config;
inherit (config) package configFile;
script = ''
${pkgs.lib.getExe package} run --all-files --config ${configFile}
'';
in
pkgs.writeShellScriptBin "pre-commit-run" script
);
devShells = forAllSystems (system: {
default = (pkgs system).mkShell {
packages = [
(toolchainFor system)
(pkgs system).clang
(pkgs system).libbpf
(pkgs system).bpftools
(pkgs system).udev
(pkgs system).pkg-config
(pkgs system).mdbook
(pkgs system).mdbook-mermaid
(pkgs system).wayland
(pkgs system).libxkbcommon
(pkgs system).vulkan-headers
(pkgs system).libxcb
(pkgs system).egl-wayland
(pkgs system).egl-x11
(pkgs system).libglvnd
]
++ self.checks.${system}.pre-commit-check.enabledPackages;
LD_LIBRARY_PATH = (pkgs system).lib.makeLibraryPath [
(pkgs system).wayland
(pkgs system).libxkbcommon
(pkgs system).vulkan-loader
(pkgs system).libGL
(pkgs system).udev
(pkgs system).vulkan-headers
(pkgs system).libxcb
(pkgs system).egl-wayland
(pkgs system).egl-x11
(pkgs system).libglvnd
];
LIBCLANG_PATH = "${(pkgs system).llvmPackages.libclang.lib}/lib";
RUST_SRC_PATH = "${toolchainFor system}/lib/rustlib/src/rust/library";
RUST_BACKTRACE = "1";
shellHook = ''
export PATH="$HOME/.cargo/bin:$PATH"
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
});
nixosModules.default = import ./nix/nixos-module.nix self;
nixosConfigurations = nixpkgs.lib.genAttrs supportedSystems (
system:
import ./nix/test-vm.nix {
inherit nixpkgs self system;
}
);
checks = forAllSystems (system: {
vm-ci-2gpu = import ./nix/ci-2gpu.nix {
inherit pkgs system self;
lib = nixpkgs.lib;
};
vm-ci-3gpu = import ./nix/ci-3gpu.nix {
inherit pkgs system self;
lib = nixpkgs.lib;
};
vm-ci-15gpu = import ./nix/ci-15gpu.nix {
inherit pkgs system self;
lib = nixpkgs.lib;
};
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt.enable = true;
rustfmt = {
enable = true;
package = toolchainFor system;
};
};
};
});
};
}