-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
116 lines (108 loc) · 3.04 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
rec {
description = "A small subset of Mellanox mlnx-ofed drivers ported to NixOS";
nixConfig = {
allow-import-from-derivation = "true";
extra-substituters = [ "https://mlnx-ofed-nixos.cachix.org" ];
extra-trusted-public-keys = [
"mlnx-ofed-nixos.cachix.org-1:jL/cqleOzhPw87etuHMeIIdAgFDKX8WnTBYMSBx3toI="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-compat.url = "github:edolstra/flake-compat";
};
outputs =
{ self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
systems = [
"aarch64-linux"
"x86_64-linux"
];
forAllSystems = f: lib.genAttrs systems (system: f system);
mkPkgs = system: import nixpkgs { inherit system; };
in
{
# Overlays
overlay = self.overlays.default;
overlays.default =
final: prev:
let
inherit (import ./pkgs { pkgs = prev; }) mkKernelModules packages;
in
packages
// {
linuxKernel = prev.linuxKernel // {
packagesFor =
kernel:
(prev.linuxKernel.packagesFor kernel).extend (
lpself: lpsuper:
mkKernelModules {
inherit (lpsuper) kernel kernelModuleMakeFlags;
}
);
};
};
# NixOS modules
nixosModules = {
default = import ./modules;
setupCacheAndOverlays = _: {
nixpkgs = {
overlays = [ self.overlays.default ];
nix.settings = {
substituters = nixConfig.extra-substituters;
trusted-public-keys = nixConfig.extra-trusted-public-keys;
};
};
};
};
# Packages
packages = forAllSystems (system: (import ./pkgs { pkgs = mkPkgs system; }).packages);
# Kernel packages
linuxPackages = forAllSystems (
system:
let
pkgs = mkPkgs system;
in
(import ./pkgs { inherit pkgs; }).mkKernelModules {
inherit (pkgs.linuxPackages) kernel kernelModuleMakeFlags;
}
);
linuxPackages_latest = forAllSystems (
system:
let
pkgs = mkPkgs system;
in
(import ./pkgs { inherit pkgs; }).mkKernelModules {
inherit (pkgs.linuxPackages_latest) kernel kernelModuleMakeFlags;
}
);
# Text formatters
formatter = forAllSystems (
system:
with (mkPkgs system);
writeShellApplication {
name = "formatter";
runtimeInputs = [
treefmt
nixfmt-rfc-style
mdformat
yamlfmt
];
text = lib.getExe treefmt;
}
);
# Dev shell that launches REPL
devShell = forAllSystems (
system:
with (mkPkgs system);
mkShell {
buildInputs = [ git ];
shellHook = ''
nix repl --expr "builtins.getFlake (builtins.toString $(git rev-parse --show-toplevel))"
exit $?
'';
}
);
};
}