From 15f95ca074a33033560741817436615222df27e8 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Wed, 23 Dec 2020 14:00:05 -0800 Subject: [PATCH] Split sd-card configuration into new image --- build.sh | 2 +- configuration.nix | 31 +++++++++---------------------- sd-image.nix | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 sd-image.nix diff --git a/build.sh b/build.sh index 582cad0..d26f620 100755 --- a/build.sh +++ b/build.sh @@ -2,5 +2,5 @@ nix-build "" \ -I nixpkgs=https://github.com/danielfullmer/nixpkgs/archive/e69838e006a7271006ab834b521187891bf93ff4.tar.gz \ - -I nixos-config=./configuration.nix \ + -I nixos-config=./sd-image.nix \ -A config.system.build.sdImage diff --git a/configuration.nix b/configuration.nix index 6487ddb..d37a09d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,18 +1,6 @@ { config, lib, pkgs, ... }: -let - uboot = pkgs.callPackage ./uboot {}; -in { - imports = [ ]; - - nixpkgs.crossSystem = lib.recursiveUpdate lib.systems.examples.armv7l-hf-multiplatform { - platform = { - name = "pinecube"; - kernelBaseConfig = "sunxi_defconfig"; - }; - }; - boot.loader.grub.enable = false; boot.loader.generic-extlinux-compatible.enable = true; boot.consoleLogLevel = 7; @@ -20,15 +8,6 @@ in # cma is 64M by default which is waay too much and we can't even unpack initrd boot.kernelParams = [ "console=ttyS0,115200n8" "cma=32M" ]; - sdImage.populateFirmwareCommands = ""; - sdImage.populateRootCommands = '' - mkdir -p ./files/boot - ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot - ''; - sdImage.postBuildCommands = '' - dd if=${uboot}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc - ''; - # See: https://lore.kernel.org/patchwork/project/lkml/list/?submitter=22013&order=name boot.kernelPackages = pkgs.linuxPackages_5_9; boot.kernelPatches = [ @@ -75,7 +54,15 @@ in networking.wireless.enable = true; - ### + ### Cross-compilation stuff ### + # Natively compiling on the pinecube is infeasible + + nixpkgs.crossSystem = lib.recursiveUpdate lib.systems.examples.armv7l-hf-multiplatform { + platform = { + name = "pinecube"; + kernelBaseConfig = "sunxi_defconfig"; + }; + }; nixpkgs.overlays = [ (self: super: { diff --git a/sd-image.nix b/sd-image.nix new file mode 100644 index 0000000..91b143c --- /dev/null +++ b/sd-image.nix @@ -0,0 +1,20 @@ +{ config, pkgs, ... }: + +let + uboot = pkgs.callPackage ./uboot {}; +in +{ + imports = [ + + ./configuration.nix + ]; + + sdImage.populateFirmwareCommands = ""; + sdImage.populateRootCommands = '' + mkdir -p ./files/boot + ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot + ''; + sdImage.postBuildCommands = '' + dd if=${uboot}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc + ''; +}