-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8a520f
commit 409ed0c
Showing
7 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# NixOS support for Radxa devices | ||
|
||
Radxa provides the NixOS implementation in the form of `nixos-hardware` modules | ||
for advanced users. | ||
|
||
Our goals are: | ||
|
||
* Only use `nixpkgs` provided packages. | ||
* Provide a consistent and simple experience to use our NixOS module. | ||
* Targetted audiences are advanced users who care mostly about CPU compute, storage, and network. | ||
* No support guarantee. We are not here to teach people how to use NixOS. | ||
|
||
We explicitly want to avoid packaging the entire vendor SDK bootloader and kernel | ||
in Nix. Those are not going to be accepted in `nixpkgs`, and our targetted audiences | ||
like homelabbers generally ignore the additional hardware features. | ||
|
||
This also aligns with [NixOS on ARM](https://wiki.nixos.org/wiki/NixOS_on_ARM)'s | ||
definition of "support": | ||
|
||
> Support for those board assumes as much is supported as Mainline Linux supports. | ||
## Characteristic of the default profiles | ||
|
||
* Using `linuxPackages_latest` | ||
* `bcachefs` rootfs with zstd compression and password-less encryption enabled | ||
* EFI boot chain provided by `systemd-boot` | ||
* Default serial console enabled with baud rate matches the platform firmware | ||
* No automatic partition expansion, as the module is only focusing on hardware | ||
|
||
## Common Nix flake pattern | ||
|
||
Below is an annoated flake example to create the initial boot image. | ||
|
||
``` | ||
{ | ||
description = "Example NixOS configurations for Radxa product"; | ||
# To build, run `nix build .#nixosConfigurations.radxa.config.system.build.diskoImages` | ||
inputs = { | ||
disko.url = "github:nix-community/disko"; | ||
disko.inputs.nixpkgs.follows = "nixpkgs"; | ||
nixos-hardware.url = "github:NixOS/nixos-hardware"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; | ||
}; | ||
outputs = inputs@{ | ||
self, | ||
disko, | ||
nixos-hardware, | ||
nixpkgs, | ||
}: { | ||
nixosConfigurations = { | ||
radxa = nixpkgs.lib.nixosSystem { | ||
specialArgs = { inherit inputs; }; | ||
system = "aarch64-linux"; | ||
modules = [ | ||
nixos-hardware.nixosModules.rock-4c-plus # Need to be replaced with the real device you are using. | ||
disko.nixosModules.disko # disko usage is optional in the running system, but we need it to generate the initial boot image. | ||
"${nixos-hardware}/radxa/disko.nix" | ||
{ | ||
disko = { | ||
imageBuilder = { | ||
# This is to avoid double emulation. Adjust the system according to your host system. | ||
# See https://github.com/nix-community/disko/issues/856 | ||
qemu = nixpkgs.legacyPackages.x86_64-linux.qemu + "/bin/qemu-system-aarch64 -M virt -cpu cortex-a57"; | ||
}; | ||
devices.disk.main.imageSize = "2G"; # 2G is enough for a basic CLI system while being small enough to flash | ||
}; | ||
users.users.radxa = { | ||
isNormalUser = true; | ||
initialPassword = "radxa"; | ||
extraGroups = [ "wheel" ]; | ||
}; | ||
services.openssh.enable = true; | ||
networking.hostName = "radxa"; | ||
system.stateVersion = "24.11"; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ lib | ||
, pkgs | ||
, config | ||
, ... | ||
}: | ||
let | ||
cfg = config.hardware.radxa; | ||
in { | ||
options.hardware.radxa = { | ||
enable = lib.mkEnableOption "Radxa system support"; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
boot = { | ||
# Currently enable bcachefs automatically set | ||
# kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; | ||
kernelPackages = lib.mkOverride 990 pkgs.linuxPackages_latest; | ||
supportedFilesystems = [ "bcachefs" ]; | ||
loader.systemd-boot.enable = lib.mkDefault true; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ lib | ||
, pkgs | ||
, config | ||
, ... | ||
}: | ||
let | ||
cfg = config.hardware.radxa; | ||
in { | ||
imports = [ | ||
../rockchip/disko.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ lib | ||
, pkgs | ||
, config | ||
, ... | ||
}: | ||
let | ||
cfg = config.hardware.rockchip; | ||
in { | ||
imports = [ | ||
../. | ||
../../rockchip/rk3399 | ||
]; | ||
|
||
hardware = { | ||
radxa.enable = true; | ||
rockchip = { | ||
rk3399.enable = true; | ||
diskoExtraPostVM = '' | ||
dd conv=notrunc,fsync if=${pkgs.ubootRock4CPlus}/idbloader.img of=$out/${cfg.diskoImageName} bs=512 seek=64 | ||
dd conv=notrunc,fsync if=${pkgs.ubootRock4CPlus}/u-boot.itb of=$out/${cfg.diskoImageName} bs=512 seek=16384 | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
"raspberry-pi-3" | ||
"raspberry-pi-4" | ||
"raspberry-pi-5" | ||
"rock-4c-plus" | ||
]; | ||
|
||
matchArch = | ||
|