Skip to content

Instantly share code, notes, and snippets.

@telent
Created November 22, 2017 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telent/f4db573d4ed3d8d314487ae7c3794bb7 to your computer and use it in GitHub Desktop.
Save telent/f4db573d4ed3d8d314487ae7c3794bb7 to your computer and use it in GitHub Desktop.
(this doesn't work)
with import <nixpkgs> {
crossSystem = {
system = "mipsel-linux-gnu";
withTLS = true;
platform = {
uboot = null;
name = "malta";
kernelArch = "mips";
kernelBaseConfig = "malta_defconfig";
kernelHeadersBaseConfig = "malta_defconfig";
kernelTarget = "uImage";
gcc = { abi = "gnu"; } ;
kernelAutoModules = false;
kernelModules = false;
kernelPreferBuiltin = true;
};
};
};
let nocheck = d : lib.overrideDerivation d (a: {
doCheck = stdenv.buildPlatform == stdenv.hostPlatform;
});
in rec {
hello = (nocheck pkgs.hello);
linux = linux_latest;
kernel = lib.overrideDerivation linux (a: {
name = "nixwrt_kernel";
});
all = buildEnv {
name = "nixwrt";
paths = [ hello pkgs.busybox ];
};
}
@telent
Copy link
Author

telent commented Nov 22, 2017

I am trying to cross-compile a mips kernel for my router, building on an x86-64 machine. However, I cobbled it together by copypasta and cargo-culting and perhaps unsurprisingly it dosn't work. It dies with the error

configuring
no configure script, doing nothing
building
make: Entering directory '/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/linux-4.14'
make[1]: Entering directory '/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/build'
/nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: /nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: cannot execute binary file
/nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: /nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: cannot execute binary file
/nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: /nix/store/5xs811xq6rf2y43fzyxyjr8mvg0lmb5v-glibc-2.26-75-mipsel-unknown-linux-gnu-mipsel-unknown-linux-gnu-bin/bin/getconf: cannot execute binary file
/bin/sh: gcc: command not found
/bin/sh: gcc: command not found
/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/linux-4.14/scripts/gcc-version.sh: line 26: gcc: command not found
/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/linux-4.14/scripts/gcc-version.sh: line 27: gcc: command not found
  HOSTCC  scripts/basic/fixdep
/bin/sh: gcc: command not found
make[2]: *** [scripts/Makefile.host:102: scripts/basic/fixdep] Error 127
make[1]: *** [/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/linux-4.14/Makefile:449: scripts_basic] Error 2
make[1]: Leaving directory '/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/build'
make: *** [Makefile:146: sub-make] Error 2
make: Leaving directory '/tmp/nix-build-linux-config-4.14-mipsel-unknown-linux-gnu.drv-0/linux-4.14'
builder for ‘/nix/store/rcmzyax5f75gyafqw800i1ldsbwaj522-linux-config-4.14-mipsel-unknown-linux-gnu.drv’ failed with exit code 2
error: build of ‘/nix/store/rcmzyax5f75gyafqw800i1ldsbwaj522-linux-config-4.14-mipsel-unknown-linux-gnu.drv’ failed
/home/dan/.nix-profile/bin/nix-shell: failed to build all dependencies

Can anyone see what I'm doing wrong?

@telent
Copy link
Author

telent commented Nov 22, 2017

For the avoidance of doubt, the command I'm running is

NIX_PATH=nixpkgs=`pwd`/nixpkgs nix-build -A linux --show-trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment