Skip to content

Instantly share code, notes, and snippets.

@sorki
Created August 25, 2020 14:13
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorki/548de08f621b066c94f0c36a7a78cc41 to your computer and use it in GitHub Desktop.
Save sorki/548de08f621b066c94f0c36a7a78cc41 to your computer and use it in GitHub Desktop.
rpi cross
{ config, lib, pkgs, ... }:
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix>
];
nixpkgs = {
crossSystem.system = "armv7l-linux";
};
# closure minification
environment.noXlibs = true;
services.xserver.enable = false;
services.xserver.desktopManager.xterm.enable = lib.mkForce false;
# this pulls too much graphical stuff
services.udisks2.enable = lib.mkForce false;
# this pulls spidermonkey and firefox
security.polkit.enable = false;
boot.supportedFilesystems = lib.mkForce [ "vfat" ];
i18n.supportedLocales = lib.mkForce [ (config.i18n.defaultLocale + "/UTF-8") ];
documentation.enable = false;
documentation.nixos.enable = false;
}
export NIX_PATH=nixpkgs=/home/jane/local_nixpkgs_checkout
nix-build --cores 0 '<nixpkgs/nixos>' \
-I nixos-config=configuration.nix \
-A config.system.build.sdImage \
-o result-cross \
--keep-going
@doronbehar
Copy link

@sorki this looks great! I haven't yet completed the build as it seems like it's gonna take forever. Are there any binary caches available? I added to my x86_64 machine those listed at the wiki but it didn't help to reduce the amount of builds. I tried using my own configuration.nix based on yours and I noticed that it will attempt to build gcc and firefox..

@sorki
Copy link
Author

sorki commented Aug 26, 2020

This minimal image takes reasonable amount of time to build on 8 core machine (like ~4 hours from scratch). You already get some things from official cache.nixos.org thanks to nixos-mobile using the cross tooling. How much is cached also depends on nixpkgs commit you pick.

The ones listed on the wiki are only useful for native / QEMU builds since with cross compilation you end up with different Nix store paths. That means you currently cannot interchange native and cross built packages - you might need to install the ones listed on the wiki iff you want to nixos-rebuild cross-built image on the target (I usually don't build anything on rPIs, just push cross-built closures from x86 or another bit more powerful armv7 builder).

@doronbehar
Copy link

Interesting. IIRC that Aarch64 can't be used for my specific RPI hardware. It'd be nice if hydra could help us with the cross builds - see NixOS/mobile-nixos#197

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