This repository was archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathflake.nix
101 lines (89 loc) · 3.52 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
{
description = "NixOS configuration for rk3588 remote deployment with UEFI and U-Boot options";
inputs = {
# Use the local flake for testing or remote flake for production.
# TODO: because this is a relative path input you will need to update the flake.lock file locally with `nix flake update nixos-rk3588`
nixos-rk3588.url = "path:.."; # For local testing
# nixos-rk3588.url = "github:ryan4yin/nixos-rk3588"; # For production
};
outputs = {nixos-rk3588, ...}: let
inherit (nixos-rk3588.inputs) nixpkgs;
# TODO: choose your rk3588 SBC model
boardModule = nixos-rk3588.nixosModules.orangepi5;
# Define system architecture and different compilation options.
bootType = "uefi"; # Change to "u-boot" for U-Boot
# Possible values for compilationType: "local-native", "remote-native", or "cross".
compilationType = "cross"; # Choose the compilation type here.
localSystem = "x86_64-linux";
targetSystem = "aarch64-linux";
# Kernel packages based on compilationType (local native, remote native, or cross-compilation)
pkgsKernel =
if compilationType == "cross"
then
import nixpkgs {
inherit localSystem;
crossSystem = targetSystem;
}
else
# For both local-native & remote-native compilation
import nixpkgs {system = targetSystem;};
# Define bootloader based on bootType (UEFI or U-Boot)
bootloaderModule =
if bootType == "uefi"
then {
# grub bootloader configured for UEFI
boot = {
# growPartition = true; # If partition resizing is necessary
kernelParams = ["console=ttyS0"]; # If you need serial console access
# loader.timeout = lib.mkDefault 0; # Optional, to skip GRUB menu
initrd.availableKernelModules = ["uas"]; # If specific kernel modules are required
loader.grub = {
enable = true;
device = "nodev";
efiSupport = true;
efiInstallAsRemovable = true;
};
};
}
else
# U-Boot configuration using sd-image
boardModule.sd-image;
in {
colmena = {
meta = {
nixpkgs = import nixpkgs {system = localSystem;};
specialArgs = {
rk3588 = {
inherit nixpkgs pkgsKernel;
};
inherit nixpkgs;
};
};
## TODO: to apply locally this "opi5" must match your local host name, such as "orangepi5" or "orangepi5plus"
opi5 = {
deployment.targetHost =
if compilationType != "local-native"
# TODO: you will want to change this IP to another address or host name
then "192.168.5.42"
else null;
deployment.targetUser =
if compilationType != "local-native"
then "root"
else null;
# Allow local deployment only if building locally
deployment.allowLocalDeployment = compilationType == "local-native";
imports = [
# import the rk3588 module, which contains the configuration for bootloader/kernel/firmware
boardModule.core
# Import the correct bootloader based on the selected bootType.
bootloaderModule
# Custom configuration
./configuration.nix
./user-group.nix
# TODO: you will likely need a fileSystems entry and additional availableKernelModules these can be included from hardware-configuration.nix generated by `nixos-generate-config`.
# ./hardware-configuration.nix
];
};
};
};
}