summary refs log tree commit diff
path: root/pkgs/os-specific/linux/busybox/default.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-29 13:32:40 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-29 13:43:00 +0100
commit423e923182d966e2315fdd405f1e0efbd1dcb18a (patch)
tree575aef3443a96c47298973f673b0ece158953a9f /pkgs/os-specific/linux/busybox/default.nix
parentdc0d68ffc30d2b446f416eff4ed974eeafcf8224 (diff)
downloadnixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar.gz
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar.bz2
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar.lz
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar.xz
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.tar.zst
nixpkgs-423e923182d966e2315fdd405f1e0efbd1dcb18a.zip
busybox: Enable building a minimal configuration
This starts with "make allnoconfig" rather than "make defconfig",
making it easier to turn on only the needed features.

Also, fix broken .config generation (the presence of "#" lines
confused parseconfig).
Diffstat (limited to 'pkgs/os-specific/linux/busybox/default.nix')
-rw-r--r--pkgs/os-specific/linux/busybox/default.nix43
1 files changed, 18 insertions, 25 deletions
diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix
index 34eb19380d4..da1d2dc2ed0 100644
--- a/pkgs/os-specific/linux/busybox/default.nix
+++ b/pkgs/os-specific/linux/busybox/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, enableStatic ? false, extraConfig ? ""}:
+{ stdenv, fetchurl, enableStatic ? false, enableMinimal ? false, extraConfig ? "" }:
 
 let
   configParser = ''
@@ -7,14 +7,7 @@ let
             NAME=`echo "$LINE" | cut -d \  -f 1`
             OPTION=`echo "$LINE" | cut -d \  -f 2`
 
-            if test -z "$NAME"; then
-                continue
-            fi
-
-            if test "$NAME" == "CLEAR"; then
-                echo "parseconfig: CLEAR"
-                echo > .config
-            fi
+            if ! [[ "$NAME" =~ ^CONFIG_ ]]; then continue; fi
 
             echo "parseconfig: removing $NAME"
             sed -i /$NAME'\(=\| \)'/d .config
@@ -25,19 +18,6 @@ let
     }
   '';
 
-  nixConfig = ''
-    CONFIG_PREFIX "$out"
-    CONFIG_INSTALL_NO_USR y
-
-    # Use the external mount.cifs program.
-    CONFIG_FEATURE_MOUNT_CIFS n
-    CONFIG_FEATURE_MOUNT_HELPERS y
-  '';
-
-  staticConfig = stdenv.lib.optionalString enableStatic ''
-    CONFIG_STATIC y
-  '';
-
 in
 
 stdenv.mkDerivation rec {
@@ -50,14 +30,27 @@ stdenv.mkDerivation rec {
 
   configurePhase = ''
     export KCONFIG_NOTIMESTAMP=1
-    make defconfig
+    make ${if enableMinimal then "allnoconfig" else "defconfig"}
+
     ${configParser}
+
     cat << EOF | parseconfig
-    ${staticConfig}
-    ${nixConfig}
+
+    CONFIG_PREFIX "$out"
+    CONFIG_INSTALL_NO_USR y
+
+    ${stdenv.lib.optionalString enableStatic ''
+      CONFIG_STATIC y
+    ''}
+
+    # Use the external mount.cifs program.
+    CONFIG_FEATURE_MOUNT_CIFS n
+    CONFIG_FEATURE_MOUNT_HELPERS y
+
     ${extraConfig}
     $extraCrossConfig
     EOF
+
     make oldconfig
   '';