Closed Dridus closed 1 year ago
I have a BeagleBone Black and was trying to find out whether this project allows running NixOS on it. So I stumbled upon this PR. @Dridus can you comment on whether it works? Did you run it on a BeagleBone Black? Is there anything that needs special care?
@lorenzleutgeb we do run NixOS on BBBs successfully, though in the end didn't need this project as mainline NixOS was sufficient. the only things that we know don't work are that it's still booting using the eMMC u-boot and not the one we flash onto the SD card, and that we don't have a working BBBw with wireless yet, though we haven't tried too hard.
here's roughly the nixos config we're using to build the image:
sd-image.nix:
let
nixpkgsSrc = import ./nixpkgs.nix;
nixos = import "${nixpkgsSrc}/nixos" {
configuration = { ... }: {
imports = [
"${nixpkgsSrc}/nixos/modules/installer/cd-dvd/sd-image.nix"
./base.nix
./bbb.nix
];
};
};
in
nixos.config.system.build.sdImage // {
inherit (nixos) pkgs system config;
}
nixpkgs.nix:
builtins.fetchTarball "https://github.com/VitalBio/nixpkgs/archive/d40e14d80afbfa5386f6b8bbacaaabba51462ed5.tar.gz"
base.nix:
{ config, ... }:
{
imports = [ crosspkgs/modules ];
system.stateVersion = "20.09";
nixpkgs.overlays = [
(self: super: {
erlang = super.erlang.override { wxSupport = false; };
gnupg = super.gnupg.override { guiSupport = false; };
libnl = super.libnl.override { pythonSupport = false; };
nmap = super.nmap.override { withLua = false; };
polkit = super.polkit.override { withGnome = false; };
})
];
boot.loader.grub.enable = false;
documentation = {
info.enable = false;
man.enable = false;
};
environment.noXlibs = true;
i18n = {
defaultLocale = "en_US.UTF-8";
supportedLocales = [ (config.i18n.defaultLocale + "/UTF-8") ];
};
networking.firewall.enable = true;
programs.command-not-found.enable = false;
security = {
polkit.enable = false;
audit.enable = false;
};
services.udisks2.enable = false;
}
bbb.nix:
{ lib, config, pkgs, ... }:
{
config = {
nixpkgs.crossSystem = lib.systems.elaborate {
system = "armv7l-linux";
platform = lib.systems.platforms.beaglebone // {
kernelBaseConfig = "omap2plus_defconfig";
};
};
boot = {
kernelPackages = pkgs.linuxPackages_5_4;
kernelParams = ["console=ttyS0,115200n8"];
};
sdImage = {
compressImage = false;
populateFirmwareCommands =
let
uboot = pkgs.buildUBoot {
defconfig = "am335x_evm_defconfig";
extraMeta.platforms = ["armv7l-linux"];
filesToInstall = ["MLO" "u-boot.img"];
};
in ''
cp ${uboot}/MLO firmware/MLO
cp ${uboot}/u-boot.img firmware/u-boot.img
'';
populateRootCommands = let
inherit (config.system.build) toplevel;
in ''
mkdir -p ./files/boot/extlinux
mkdir -p ./files/boot/dtbs
cp $dtbDir/am335x-boneblack.dtb ./files/boot/dtbs
cat > ./files/boot/extlinux/extlinux.conf <<EOF
DEFAULT vital-device
MENU TITLE ------------------------------------------------------------
TIMEOUT 1
LABEL vital-device
MENU LABEL Vital Device
LINUX ../kernel
INITRD ../initrd
FDTDIR ../dtbs
APPEND systemConfig=${toplevel} init=${toplevel}/init $(cat ${toplevel}/kernel-params) dyndbg="file pinctrl-single.c +p; file drivers/pinctrl/core.c +p"
EOF
cp ${toplevel}/kernel ./files/boot/kernel
cp ${toplevel}/initrd ./files/boot/initrd
'';
};
hardware.leds = [
"beaglebone:black:heartbeat"
"beaglebone:black:mmc0"
"beaglebone:black:usr2"
"beaglebone:black:usr3"
];
};
}
and built with nix build -f sd-image.nix
note that we use a somewhat different configuration with custom devicetrees to reconfigure the pinmux etc, so I had to adapt this a bit and it may not work if I flubbed that edit
closing as this is old and I don't want it to clutter my PR list
wonderful project, thank you for it!