Last active
June 22, 2024 23:57
-
-
Save calebstewart/224b03fdc698f615574c9ffc57f385ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "Base OS Image for Maden Raspberry Pi"; | |
inputs = { | |
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05"; | |
}; | |
outputs = { self, nixpkgs }@inputs: | |
let | |
hostSystem = "x86_64-linux"; | |
targetSystem = "aarch64-multiplatform"; | |
in rec { | |
nixosConfigurations.maden = nixpkgs.legacyPackages.${hostSystem}.pkgsCross.${targetSystem}.nixos { | |
imports = [ | |
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" | |
./maden.nix | |
]; | |
}; | |
images.maden = nixosConfigurations.maden.config.system.build.sdImage; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{lib, config, pkgs, ...}: | |
let | |
in { | |
system.stateVersion = "24.05"; | |
# Enable SSH server | |
services.openssh.enable = true; | |
# Required to build the RPi kernel | |
nixpkgs.overlays = [(final: super: { | |
makeModulesClosure = x: super.makeModulesClosure (x // {allowMissing = true;}); | |
})]; | |
# Setup SSH key for the root user | |
users.users.root.openssh.authorizedKeys.keys = [ | |
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFnavld9+Ik1jcIUVtd8Ng2qK2xoafOYXnmXpTRz5boh caleb@ryzen" | |
]; | |
# Set the system hostname | |
networking.hostName = "maden"; | |
# Use the RaspberryPi 4 kernel package | |
boot.kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_rpi4; | |
# Enable ADIN1110 options in the kernel | |
boot.kernelPatches = [ | |
{ | |
name = "enable-adin"; | |
patch = null; | |
extraStructuredConfig = { | |
ADIN1110 = lib.kernel.module; | |
ADIN_PHY = lib.kernel.module; | |
ADIN1100_PHY = lib.kernel.module; | |
CRC8 = lib.kernel.yes; | |
NET_SWITCHDEV = lib.kernel.yes; | |
}; | |
} | |
]; | |
# Install the devicetree overlay for ADIN1110 | |
hardware.deviceTree = { | |
enable = true; | |
overlays = [ | |
{ | |
name = "adin1110"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/ { | |
compatible = "brcm,bcm2708"; | |
fragment@0 { | |
target = <&spi0>; | |
__overlay__ { | |
#address-cells = <1>; | |
#size-cells = <0>; | |
status = "okay"; | |
eth1: adin1110@0{ | |
compatible = "adi,adin1110"; | |
reg = <0>; /* CE0 */ | |
pinctrl-names = "default"; | |
pinctrl-0 = <ð1_pins>; | |
interrupt-parent = <&gpio>; | |
interrupts = <22 0x2>; | |
spi-max-frequency = <23000000>; | |
mac-address = [ CA 2F B7 10 23 63 ]; | |
status = "okay"; | |
phy@1 { | |
compatible = "ethernet-phy-id0283.bc91"; | |
reg = <0>; | |
}; | |
}; | |
}; | |
}; | |
fragment@1 { | |
target = <&spidev0>; | |
__overlay__ { | |
status = "disabled"; | |
}; | |
}; | |
fragment@2 { | |
target = <&gpio>; | |
__overlay__ { | |
eth1_pins: eth1_pins { | |
brcm,pins = <22>; | |
brcm,function = <0>; /* in */ | |
brcm,pull = <0>; /* none */ | |
}; | |
}; | |
}; | |
}; | |
''; | |
} | |
]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment