diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 443841363bf..981fbce0a3a 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -1,62 +1,89 @@ -{ stdenv, fetchurl, bc, dtc -, toolsOnly ? false -, defconfig ? "allnoconfig" -, targetPlatforms -, filesToInstall -}: +{ stdenv, fetchurl, bc, dtc }: let - platform = stdenv.platform; - crossPlatform = stdenv.cross.platform; - makeTarget = if toolsOnly then "tools NO_SDL=1" else "all"; - installDir = if toolsOnly then "$out/bin" else "$out"; - buildFun = kernelArch: - '' - if test -z "$crossConfig"; then - make ${makeTarget} - else - make ${makeTarget} ARCH=${kernelArch} CROSS_COMPILE=$crossConfig- - fi + buildUBoot = { targetPlatforms + , filesToInstall + , installDir ? "$out" + , defconfig + , extraMeta ? {} + , ... } @ args: + stdenv.mkDerivation (rec { + + name = "uboot-${defconfig}-${version}"; + version = "2015.10"; + + nativeBuildInputs = [ bc dtc ]; + + src = fetchurl { + url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"; + sha256 = "0m8r08izci0lzzjn5c5g5manp2rc7yc5swww0lxr7bamjigqvimx"; + }; + + configurePhase = '' + make ${defconfig} ''; -in -stdenv.mkDerivation rec { - name = "uboot-${defconfig}-${version}"; - version = "2015.10"; + installPhase = '' + runHook preInstall - src = fetchurl { - url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"; - sha256 = "0m8r08izci0lzzjn5c5g5manp2rc7yc5swww0lxr7bamjigqvimx"; + mkdir -p ${installDir} + cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir} + + runHook postInstall + ''; + + dontStrip = true; + + crossAttrs = { + makeFlags = [ + "ARCH=${stdenv.cross.platform.kernelArch}" + "CROSS_COMPILE=${stdenv.cross.config}-" + ]; + }; + + meta = with stdenv.lib; { + homepage = "http://www.denx.de/wiki/U-Boot/"; + description = "Boot loader for embedded systems"; + license = licenses.gpl2; + maintainers = [ maintainers.dezgeg ]; + platforms = targetPlatforms; + } // extraMeta; + } // args); + +in rec { + inherit buildUBoot; + + ubootTools = buildUBoot rec { + installDir = "$out/bin"; + buildFlags = "tools NO_SDL=1"; + dontStrip = false; + targetPlatforms = stdenv.lib.platforms.linux; + filesToInstall = ["tools/dumpimage" "tools/mkenvimage" "tools/mkimage"]; }; - patches = [ ./vexpress-Use-config_distro_bootcmd.patch ]; - - nativeBuildInputs = [ bc dtc ]; - - configurePhase = '' - make ${defconfig} - ''; - - buildPhase = assert (platform ? kernelArch); - buildFun platform.kernelArch; - - installPhase = '' - mkdir -p ${installDir} - cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir} - ''; - - dontStrip = !toolsOnly; - - crossAttrs = { - buildPhase = assert (crossPlatform ? kernelArch); - buildFun crossPlatform.kernelArch; + ubootJetsonTK1 = buildUBoot rec { + defconfig = "jetson-tk1_defconfig"; + targetPlatforms = ["armv7l-linux"]; + filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"]; }; - meta = with stdenv.lib; { - homepage = "http://www.denx.de/wiki/U-Boot/"; - description = "Boot loader for embedded systems"; - license = licenses.gpl2; - maintainers = [ maintainers.dezgeg ]; - platforms = targetPlatforms; + ubootPcduino3Nano = buildUBoot rec { + defconfig = "Linksprite_pcDuino3_Nano_defconfig"; + targetPlatforms = ["armv7l-linux"]; + filesToInstall = ["u-boot-sunxi-with-spl.bin"]; + }; + + ubootRaspberryPi = buildUBoot rec { + defconfig = "rpi_defconfig"; + targetPlatforms = ["armv6l-linux"]; + filesToInstall = ["u-boot.bin"]; + }; + + # Intended only for QEMU's vexpress-a9 emulation target! + ubootVersatileExpressCA9 = buildUBoot rec { + defconfig = "vexpress_ca9x4_defconfig"; + targetPlatforms = ["armv7l-linux"]; + filesToInstall = ["u-boot"]; + patches = [ ./vexpress-Use-config_distro_bootcmd.patch ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1c283e4acb1..bac0f0dd8b6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10574,36 +10574,13 @@ let ubootChooser = name: ubootTools; # Upstream U-Boots: - ubootTools = callPackage ../misc/uboot { - toolsOnly = true; - targetPlatforms = lib.platforms.linux; - filesToInstall = ["tools/dumpimage" "tools/mkenvimage" "tools/mkimage"]; - }; - - ubootJetsonTK1 = callPackage ../misc/uboot { - defconfig = "jetson-tk1_defconfig"; - targetPlatforms = ["armv7l-linux"]; - filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"]; - }; - - ubootPcduino3Nano = callPackage ../misc/uboot { - defconfig = "Linksprite_pcDuino3_Nano_defconfig"; - targetPlatforms = ["armv7l-linux"]; - filesToInstall = ["u-boot-sunxi-with-spl.bin"]; - }; - - ubootRaspberryPi = callPackage ../misc/uboot { - defconfig = "rpi_defconfig"; - targetPlatforms = ["armv6l-linux"]; - filesToInstall = ["u-boot.bin"]; - }; - - # Intended only for QEMU's vexpress-a9 emulation target! - ubootVersatileExpressCA9 = callPackage ../misc/uboot { - defconfig = "vexpress_ca9x4_defconfig"; - targetPlatforms = ["armv7l-linux"]; - filesToInstall = ["u-boot"]; - }; + inherit (callPackage ../misc/uboot {}) + buildUBoot + ubootJetsonTK1 + ubootPcduino3Nano + ubootRaspberryPi + ubootVersatileExpressCA9 + ; # Non-upstream U-Boots: ubootSheevaplug = callPackage ../misc/uboot/sheevaplug.nix { };