harmonica-sd
This commit is contained in:
parent
c14da8e176
commit
1cbeba0f18
3 changed files with 174 additions and 0 deletions
54
hosts/harmonica-sd/configuration.nix
Normal file
54
hosts/harmonica-sd/configuration.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./sd-image.nix
|
||||
"${inputs.nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
|
||||
./hardware-configuration.nix
|
||||
../../modules
|
||||
inputs.agenix.nixosModules.default
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.vscode-server.nixosModules.default
|
||||
];
|
||||
|
||||
myModules = {
|
||||
enableKDE = false;
|
||||
enableFonts = false;
|
||||
blockYoutube = false;
|
||||
blockTwitter = false;
|
||||
enableTailscale = true;
|
||||
};
|
||||
|
||||
i18n.inputMethod.enable = lib.mkForce false; # no need for japanese input method
|
||||
|
||||
system.stateVersion = "25.05";
|
||||
|
||||
networking.hostName = "harmonica";
|
||||
|
||||
networking = {
|
||||
interfaces."wlan0".useDHCP = true;
|
||||
wireless = {
|
||||
enable = true;
|
||||
interfaces = ["wlan0"];
|
||||
networks = {
|
||||
"House_Bayram" = {
|
||||
psk = "PASSWORD";
|
||||
};
|
||||
"it_hurts_when_IP" = {
|
||||
psk = "PASSWORD";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# NTP time sync.
|
||||
services.timesyncd.enable = true;
|
||||
|
||||
security.sudo = {
|
||||
enable = true;
|
||||
wheelNeedsPassword = false;
|
||||
};
|
||||
services.getty.autologinUser = "osbm";
|
||||
}
|
||||
81
hosts/harmonica-sd/hardware-configuration.nix
Normal file
81
hosts/harmonica-sd/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
# Some packages (ahci fail... this bypasses that) https://discourse.nixos.org/t/does-pkgs-linuxpackages-rpi3-build-all-required-kernel-modules/42509
|
||||
nixpkgs.overlays = [
|
||||
(final: super: {
|
||||
makeModulesClosure = x:
|
||||
super.makeModulesClosure (x // {allowMissing = true;});
|
||||
})
|
||||
];
|
||||
|
||||
zramSwap = {
|
||||
enable = true;
|
||||
algorithm = "zstd";
|
||||
};
|
||||
|
||||
sdImage = {
|
||||
# bzip2 compression takes loads of time with emulation, skip it. Enable this if you're low on space.
|
||||
compressImage = false;
|
||||
imageName = "zero2.img";
|
||||
|
||||
extraFirmwareConfig = {
|
||||
# Give up VRAM for more Free System Memory
|
||||
# - Disable camera which automatically reserves 128MB VRAM
|
||||
start_x = 0;
|
||||
# - Reduce allocation of VRAM to 16MB minimum for non-rotated (32MB for rotated)
|
||||
gpu_mem = 16;
|
||||
|
||||
# Configure display to 800x600 so it fits on most screens
|
||||
# * See: https://elinux.org/RPi_Configuration
|
||||
hdmi_group = 2;
|
||||
hdmi_mode = 8;
|
||||
};
|
||||
};
|
||||
|
||||
hardware = {
|
||||
enableRedistributableFirmware = lib.mkForce false;
|
||||
firmware = [pkgs.raspberrypiWirelessFirmware]; # Keep this to make sure wifi works
|
||||
i2c.enable = true;
|
||||
deviceTree.filter = "bcm2837-rpi-zero*.dtb";
|
||||
deviceTree.overlays = [
|
||||
{
|
||||
name = "enable-i2c";
|
||||
dtsText = ''
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
/ {
|
||||
compatible = "brcm,bcm2837";
|
||||
fragment@0 {
|
||||
target = <&i2c1>;
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_rpi02w;
|
||||
|
||||
initrd.availableKernelModules = ["xhci_pci" "usbhid" "usb_storage"];
|
||||
loader = {
|
||||
grub.enable = false;
|
||||
generic-extlinux-compatible.enable = true;
|
||||
};
|
||||
extraModprobeConfig = ''
|
||||
options brcmfmac roamoff=1 feature_disable=0x82000
|
||||
'';
|
||||
|
||||
# Avoids warning: mdadm: Neither MAILADDR nor PROGRAM has been set. This will cause the `mdmon` service to crash.
|
||||
# See: https://github.com/NixOS/nixpkgs/issues/254807
|
||||
swraid.enable = lib.mkForce false;
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = "aarch64-linux";
|
||||
}
|
||||
39
hosts/harmonica-sd/sd-image.nix
Normal file
39
hosts/harmonica-sd/sd-image.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# This module extends the official sd-image.nix with the following:
|
||||
# - ability to add options to the config.txt firmware
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
options.sdImage = with lib; {
|
||||
extraFirmwareConfig = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
description = lib.mdDoc ''
|
||||
Extra configuration to be added to config.txt.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
sdImage.populateFirmwareCommands =
|
||||
lib.mkIf ((lib.length (lib.attrValues config.sdImage.extraFirmwareConfig)) > 0)
|
||||
(
|
||||
let
|
||||
# Convert the set into a string of lines of "key=value" pairs.
|
||||
keyValueMap = name: value: name + "=" + toString value;
|
||||
keyValueList = lib.mapAttrsToList keyValueMap config.sdImage.extraFirmwareConfig;
|
||||
extraFirmwareConfigString = lib.concatStringsSep "\n" keyValueList;
|
||||
in
|
||||
lib.mkAfter
|
||||
''
|
||||
config=firmware/config.txt
|
||||
# The initial file has just been created without write permissions. Add them to be able to append the file.
|
||||
chmod u+w $config
|
||||
echo "\n# Extra configuration" >> $config
|
||||
echo "${extraFirmwareConfigString}" >> $config
|
||||
chmod u-w $config
|
||||
''
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue