diff --git a/rockchip/default.nix b/rockchip/default.nix new file mode 100644 index 00000000..461baedd --- /dev/null +++ b/rockchip/default.nix @@ -0,0 +1,33 @@ +{ lib +, pkgs +, config +, ... +}: +let + cfg = config.hardware.rockchip; +in { + options.hardware.rockchip = { + enable = lib.mkEnableOption "Rockchip SoC support"; + diskoImageName = lib.mkOption { + type = lib.types.str; + default = "main.raw"; + description = '' + The output image name for Disko. + Can be used by diskoExtraPostVM. + ''; + }; + diskoExtraPostVM = lib.mkOption { + type = lib.types.str; + description = '' + The post VM hook for Disko's Image Builder. + Can be used to install platform firmware like U-Boot. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + boot = { + kernelParams = [ "console=ttyS2,1500000n8" ]; + }; + }; +} diff --git a/rockchip/disko.nix b/rockchip/disko.nix new file mode 100644 index 00000000..7d6b4c9a --- /dev/null +++ b/rockchip/disko.nix @@ -0,0 +1,62 @@ +{ lib +, pkgs +, config +, ... +}: +let + cfg = config.hardware.rockchip; +in { + imports = [ + rk3399/disko.nix + ]; + + config = lib.mkIf cfg.enable { + disko = { + imageBuilder = { + extraRootModules = [ "bcachefs" ]; + extraPostVM = cfg.diskoExtraPostVM; + }; + memSize = lib.mkDefault 4096; # Default 1024 MB will throw "Cannot allocate memory" error + devices.disk.main = { + type = "disk"; + imageSize = lib.mkDefault "2G"; + content = { + type = "gpt"; + partitions = { + ESP = { + type = "EF00"; + # Firmware backoff + start = "16M"; + size = "500M"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0022" ]; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "bcachefs"; + mountpoint = "/"; + extraArgs = [ + "--metadata_checksum=xxhash" + "--data_checksum=xxhash" + "--compression=zstd" + "--background_compression=zstd" + "--str_hash=siphash" + "--wide_macs" + "--encrypted" + "--no_passphrase" + "--discard" + ]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/rockchip/rk3399/default.nix b/rockchip/rk3399/default.nix new file mode 100644 index 00000000..3aea18fd --- /dev/null +++ b/rockchip/rk3399/default.nix @@ -0,0 +1,20 @@ +{ lib +, pkgs +, config +, ... +}: +let + cfg = config.hardware.rockchip.rk3399; +in { + imports = [ + ../. + ]; + + options.hardware.rockchip.rk3399 = { + enable = lib.mkEnableOption "Rockchip RK3399 support"; + }; + + config = lib.mkIf cfg.enable { + hardware.rockchip.enable = true; + }; +} diff --git a/rockchip/rk3399/disko.nix b/rockchip/rk3399/disko.nix new file mode 100644 index 00000000..bae10ef5 --- /dev/null +++ b/rockchip/rk3399/disko.nix @@ -0,0 +1,14 @@ +{ lib +, pkgs +, config +, ... +}: +let + cfg = config.hardware.rockchip.rk3399; +in { + config = lib.mkIf cfg.enable { + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "arm-trusted-firmware-rk3399" + ]; + }; +}