-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathflake.nix
102 lines (97 loc) · 3.06 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
}:
let
# Modify this if you are building on something other than x86_64-linux.
buildSystem = "x86_64-linux";
# Modify this of you want to attempt using a different device.
# See the `arch/arm64/boot/dts/qcom` directory in the Linux
# kernel source tree for available device trees.
deviceTreeName = "qcom/x1e80100-lenovo-yoga-slim7x.dtb";
nixpkgs-patched =
let
pkgs-unpatched = nixpkgs.legacyPackages.${buildSystem};
in
(pkgs-unpatched.applyPatches {
name = "nixpkgs-patched";
src = nixpkgs;
patches = [
./nixpkgs-devicetree.patch
./nixpkgs-efi-shell.patch
];
}).overrideAttrs
{ allowSubstitutes = true; };
pkgs-cross = import nixpkgs-patched {
overlays = [ (import ./packages/overlay.nix) ];
localSystem.system = buildSystem;
crossSystem.system = "aarch64-linux";
allowUnsupportedSystem = true;
};
in
(import ./default.nix)
// {
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
modules = [
"${nixpkgs-patched}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
./iso.nix
./modules/x1e80100.nix
./modules/common.nix
{
nixpkgs.pkgs = pkgs-cross;
hardware.deviceTree.name = deviceTreeName;
# Required to evaluate packages from `pkgs-cross` on the device.
isoImage.storeContents = [ nixpkgs-patched ];
}
];
};
system = nixpkgs.lib.nixosSystem {
modules = [
./examples/flake-based-config/configuration.nix
self.nixosModules.x1e
./modules/common.nix
(
{ lib, ... }:
{
nixpkgs.pkgs = nixpkgs.legacyPackages.aarch64-linux;
hardware.deviceTree.name = deviceTreeName;
# Copy the cross-compiled kernel from the install ISO. Remove
# this if you want to natively compile the kernel on your device.
boot.kernelPackages = lib.mkForce pkgs-cross.x1e80100-linux;
}
)
];
};
};
}
// (
let
eachSystem = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
treefmtEval = eachSystem (
system:
(treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} {
programs.nixfmt.enable = true;
settings.on-unmatched = "info";
})
);
in
{
formatter = eachSystem (system: treefmtEval.${system}.config.build.wrapper);
checks = eachSystem (system: {
treefmt = treefmtEval.${system}.config.build.check self;
});
}
);
}