about summary refs log tree commit diff
path: root/pkgs/misc/barebox
diff options
context:
space:
mode:
authorRouven Czerwinski <rouven@czerwinskis.de>2020-12-13 06:19:08 +0100
committerAndreas Rammhold <andreas@rammhold.de>2020-12-14 21:49:37 +0100
commit7a6203fffc16227e5a0f4477fff050c32ddd27b0 (patch)
tree97b512a68abf4da122e73d3c7b3f80f340e8784e /pkgs/misc/barebox
parentaf2ab765157d623533098ddc97662e27bd568c72 (diff)
bareboxTools: init at v2020.12.0
This adds the bareboxTools as a package. The buildBarebox function is
intentionally modeled like the buildUBoot function, which should allow
future expansion to build barebox for NixOS systems. The tools are
useful on their own, since they allow flashing of systems via the
different USB loader tools shipped in the scripts directory.
Diffstat (limited to 'pkgs/misc/barebox')
-rw-r--r--pkgs/misc/barebox/default.nix96
1 files changed, 96 insertions, 0 deletions
diff --git a/pkgs/misc/barebox/default.nix b/pkgs/misc/barebox/default.nix
new file mode 100644
index 0000000000000..78d4228abb3bd
--- /dev/null
+++ b/pkgs/misc/barebox/default.nix
@@ -0,0 +1,96 @@
+{ stdenv
+, lib
+, fetchurl
+, bison
+, dtc
+, flex
+, libusb1
+, lzop
+, openssl
+, pkgconfig
+, buildPackages
+}:
+
+let
+  buildBarebox = {
+    filesToInstall
+  , installDir ? "$out"
+  , defconfig
+  , extraMeta ? {}
+  , ... } @ args: stdenv.mkDerivation rec {
+    pname = "barebox-${defconfig}";
+
+    version = "2020.12.0";
+
+    src = fetchurl {
+      url = "https://www.barebox.org/download/barebox-${version}.tar.bz2";
+      sha256 = "06vsd95ihaa2nywpqy6k0c7xwk2pzws4yvbp328yd2pfiigachrv";
+    };
+
+    postPatch = ''
+      patchShebangs scripts
+    '';
+
+    nativeBuildInputs = [
+      bison
+      dtc
+      flex
+      openssl
+      libusb1
+      lzop
+      pkgconfig
+    ];
+    depsBuildBuild = [ buildPackages.stdenv.cc ];
+
+    hardeningDisable = [ "all" ];
+
+    makeFlags = [
+      "DTC=dtc"
+      "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
+    ];
+
+    configurePhase = ''
+      runHook preConfigure
+
+      make ${defconfig}
+
+      runHook postConfigure
+    '';
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir -p ${installDir}
+      cp ${lib.concatStringsSep " " filesToInstall} ${installDir}
+
+      runHook postInstall
+    '';
+
+    enableParallelBuilding = true;
+
+    dontStrip = true;
+
+    meta = with lib; {
+      homepage = "https://www.barebox.org";
+      description = "The Swiss Army Knive for bare metal";
+      license = licenses.gpl2;
+      maintainers = with maintainers; [ emantor ];
+    } // extraMeta;
+  } // removeAttrs args [ "extraMeta" ];
+
+in {
+  inherit buildBarebox;
+
+  bareboxTools = buildBarebox {
+    defconfig = "hosttools_defconfig";
+    installDir = "$out/bin";
+    extraMeta.platforms = lib.platforms.linux;
+    filesToInstall = [
+      "scripts/bareboximd"
+      "scripts/imx/imx-usb-loader"
+      "scripts/omap4_usbboot"
+      "scripts/omap3-usb-loader"
+      "scripts/kwboot"
+    ];
+  };
+}