Skip to content

Instantly share code, notes, and snippets.

@karmanyaahm
Last active June 25, 2023 18:34
Show Gist options
  • Save karmanyaahm/5dc741b52dfbf6cbcb32da2fc90a31e3 to your computer and use it in GitHub Desktop.
Save karmanyaahm/5dc741b52dfbf6cbcb32da2fc90a31e3 to your computer and use it in GitHub Desktop.
Orange Pi Zero with Allwinner H2+ NixOS SD Card image with uboot included; cross compiling `x86_64` -> `armv7l`; ethernet works, wifi not tested
# NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix build --impure .#opi
{
description = "NixOS Orange Pi Zero configuration flake";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
outputs = { self, nixpkgs }: rec {
pkgsIntel = import nixpkgs {
system = "x86_64-linux"; # or something else
config = { allowUnfree = true; allowUnsupportedSystem = true;};
};
nixosConfigurations.opi = nixpkgs.lib.nixosSystem {
system = "armv7l-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-armv7l-multiplatform.nix"
({ ... }: {
nixpkgs.hostPlatform.system = "armv7l-linux";
nixpkgs.buildPlatform.system = "x86_64-linux";
sdImage.postBuildCommands = "dd if=${pkgsIntel.pkgsCross.armv7l-hf-multiplatform.ubootOrangePiZero}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc";
# Time, keyboard language, etc
i18n.defaultLocale = "en_US.UTF-8";
# User
users.users.notme = {
isNormalUser = true;
extraGroups = [
"wheel" # Enable ‘sudo’ for the user.
];
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAC3Nz"
];
password = "";
};
# Allow ssh in
services.openssh.enable = true;
networking = {
hostName = "nixos-backup-server";
};
# This makes the build be a .img instead of a .img.zst
#sdImage.compressImage = false;
system = {
stateVersion = "23.05";
};
})
];
};
opi = nixosConfigurations.opi.config.system.build.sdImage;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment