From 6fcd7a09e0f1ffc17714c598a450b35a0c5acc4b Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 12 Jun 2018 23:14:55 +0000 Subject: [PATCH] Makes rootfs configuratble by device_config... This is a WIP, but this already should allow device-specific fb.modes --- bootimg.nix | 18 +++++++++--------- devices/asus-z00t/default.nix | 12 ++++++++++++ rootfs.nix | 9 +++++---- 3 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 devices/asus-z00t/default.nix diff --git a/bootimg.nix b/bootimg.nix index ed2bc7df..5df5f1ef 100644 --- a/bootimg.nix +++ b/bootimg.nix @@ -4,16 +4,16 @@ with (import ./overlay); let - deviceinfo = (lib.importJSON ./devices/postmarketOS-devices.json).${device_name}; + device_config = import (./devices + ("/" + device_name)) {inherit lib;}; linux = pkgs."linux_${device_name}"; kernel = "${linux}/Image.gz-dtb"; dt = "${linux}/boot/dt.img"; # TODO : Allow appending / prepending - cmdline = deviceinfo.kernel_cmdline; + cmdline = device_config.kernel_cmdline; # TODO : make configurable? - initrd = callPackage ./rootfs.nix { inherit device_name; }; + initrd = callPackage ./rootfs.nix { inherit device_config; }; in stdenv.mkDerivation { name = "nixos-mobile_${device_name}_boot.img"; @@ -33,12 +33,12 @@ stdenv.mkDerivation { --dt ${dt} \ --ramdisk ${initrd} \ --cmdline "${cmdline}" \ - --base ${deviceinfo.flash_offset_base } \ - --kernel_offset ${deviceinfo.flash_offset_kernel } \ - --second_offset ${deviceinfo.flash_offset_second } \ - --ramdisk_offset ${deviceinfo.flash_offset_ramdisk} \ - --tags_offset ${deviceinfo.flash_offset_tags } \ - --pagesize ${deviceinfo.flash_pagesize } \ + --base ${device_config.flash_offset_base } \ + --kernel_offset ${device_config.flash_offset_kernel } \ + --second_offset ${device_config.flash_offset_second } \ + --ramdisk_offset ${device_config.flash_offset_ramdisk} \ + --tags_offset ${device_config.flash_offset_tags } \ + --pagesize ${device_config.flash_pagesize } \ -o $out ''; } diff --git a/devices/asus-z00t/default.nix b/devices/asus-z00t/default.nix new file mode 100644 index 00000000..1dea9fc3 --- /dev/null +++ b/devices/asus-z00t/default.nix @@ -0,0 +1,12 @@ +{ + lib, +}: +let + config = (lib.importJSON ../postmarketOS-devices.json).asus-z00t; +in +config // { + name = config.pm_name; + rootfs = { + fb_modes = ./fb.modes; + }; +} diff --git a/rootfs.nix b/rootfs.nix index 3504f21b..8bd3b663 100644 --- a/rootfs.nix +++ b/rootfs.nix @@ -1,5 +1,5 @@ { - device_name, + device_config, stdenv, makeInitrd, @@ -22,6 +22,7 @@ # TODO : configurable through receiving device-specific informations. let + device_name = device_config.name; extraUtils = runCommandCC "extra-utils" { buildInputs = [ nukeReferences ]; @@ -265,9 +266,9 @@ let { object = stage1; symlink = "/init"; } { object = ./temp-splash.png; symlink = "/splash.png"; } { object = ./loading.png; symlink = "/loading.png"; } - # FIXME : configurable rootfs additions from device config. - { object = ./devices/asus-z00t/fb.modes; symlink = "/etc/fb.modes"; } - ]; + ] + ++ lib.optional (device_config ? rootfs.fb_modes) { object = device_config.rootfs.fb_modes; symlink = "/etc/fb.modes"; } + ; }; in stdenv.mkDerivation {