inital work on pi5

This commit is contained in:
chaos 2024-08-31 14:05:17 +01:00
parent 4a1f8fb337
commit 50b3388c18
No known key found for this signature in database
8 changed files with 264 additions and 1 deletions

View file

@ -30,6 +30,8 @@ in {
chaos.gaming chaos.gaming
]) ])
./profiles/kodi.nix
./secrets.nix ./secrets.nix
./hardware.nix ./hardware.nix
]); ]);

View file

@ -0,0 +1,84 @@
{
pkgs,
tree,
...
}: let
kodiPackage = pkgs.kodi-wayland.withPackages (kodiPkgs:
with kodiPkgs; [
keymap
sendtokodi
sponsorblock
pvr-iptvsimple
inputstreamhelper
inputstream-adaptive
inputstream-rtmp
visualization-projectm
visualization-waveform
visualization-matrix
visualization-starburst
visualization-spectrum
]);
in {
environment.systemPackages = [
kodiPackage
];
services.xserver = {
enable = true;
desktopManager.kodi = {
enable = true;
package = kodiPackage;
};
#autoLogin.enable = true;
#autoLogin.user = "kodi";
};
networking.firewall = {
allowedTCPPorts = [8080];
allowedUDPPorts = [8080];
};
users.users.kodi = {
uid = 1002;
isNormalUser = true;
extraGroups = [
"video"
"input"
"uinput"
"audio"
"rtkit"
];
};
home-manager.users.kodi = {
imports = with tree.profiles.home-manager; [
base
gui.base
gui.environments.gnome
apps.fileRoller
apps.nautilus
apps.pavucontrol
apps.mpv
apps.firefox
apps.telegram
apps.aria2
apps.rclone
];
# only for x86_64
home.file.widevine-lib = {
source = "${pkgs.widevine-cdm}/share/google/chrome/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so";
target = ".kodi/cdm/libwidevinecdm.so";
};
home.file.widevine-manifest = {
source = "${pkgs.widevine-cdm}/share/google/chrome/WidevineCdm/manifest.json";
target = ".kodi/cdm/manifest.json";
};
home.stateVersion = "24.05";
};
}

View file

@ -50,4 +50,11 @@ in rec {
system = "aarch64-linux"; system = "aarch64-linux";
modules = defaultModules ++ [./hetzner-arm/hetzner-arm.nix]; modules = defaultModules ++ [./hetzner-arm/hetzner-arm.nix];
}; };
raspberry = nixosUnstableSystem {
specialArgs =
defaultSpecialArgs;
system = "aarch64-linux";
modules = defaultModules ++ [./raspberry/raspberry.nix];
};
} }

View file

@ -0,0 +1,111 @@
{
tree,
pkgs,
lib,
...
}: let
inherit (lib.modules) mkForce;
inherit (lib.lists) forEach foldl';
inherit (lib.attrsets) recursiveUpdate mapAttrsToList;
inherit (builtins) toFile concatStringsSep;
edk2 = pkgs.fetchzip {
url = "https://github.com/worproject/rpi5-uefi/releases/download/v0.3/RPi5_UEFI_Release_v0.3.zip";
hash = "sha256-bjEvq7KlEFANnFVL0LyexXEeoXj7rHGnwQpq09PhIb0=";
stripRoot = false;
};
fwFiles = let
piBootFw = "${pkgs.raspberrypifw}/share/raspberrypi/boot";
piBootFwFiles = foldl' recursiveUpdate {} (forEach [
"bootcode.bin"
"start.elf"
"fixup_cd.dat"
"fixup.dat"
"fixup_db.dat"
"fixup_x.dat"
"fixup4cd.dat"
"fixup4.dat"
"fixup4db.dat"
"fixup4x.dat"
"start_cd.elf"
"start_db.elf"
"start.elf"
"start_x.elf"
"start4cd.elf"
"start4db.elf"
"start4.elf"
"start4x.elf"
] (file: {
"${file}" = "${piBootFw}/${file}";
}));
in
{
"config.txt" = toFile "config.txt" ''
armstub=RPI_EFI.fd
device_tree_address=0x1f0000
device_tree_end=0x210000
# Makes GPU work?
dtoverlay=vc4-kms-v3d-pi5
# Force 32 bpp framebuffer allocation.
framebuffer_depth=32
# Disable compensation for displays with overscan.
disable_overscan=1
# Force maximum USB power regardless of the power supply.
usb_max_current_enable=1
# Force maximum CPU speed.
force_turbo=1
'';
# UEFI Files
"RPI_EFI.fd" = "${edk2}/RPI_EFI.fd";
"bcm2712-rpi-5-b.dtb" = "${edk2}/bcm2712-rpi-5-b.dtb";
}
// piBootFwFiles;
in {
imports = with tree; [
presets.nixos.encryptedDrive
];
boot = {
kernelPackages = pkgs.linuxPackages_rpi4;
supportedFilesystems = mkForce ["vfat"];
kernelParams = ["console=tty0"];
loader = {
systemd-boot = {
enable = true;
extraFiles = fwFiles;
};
efi.canTouchEfiVariables = false;
grub.enable = false;
generic-extlinux-compatible.enable = false;
};
initrd.availableKernelModules = [
"nvme"
"ehci_pci"
"xhci_pci"
"usb_storage"
"sd_mod"
"sdhci_pci"
];
};
system.build.firmware = pkgs.runCommand "firmware" {} ''
mkdir $out
${concatStringsSep "\n" (
mapAttrsToList (filename: path: ''
cp ${path} $out/${filename}
'')
fwFiles
)}
'';
}

View file

@ -0,0 +1,43 @@
{
lib,
tree,
...
}: let
inherit (lib.lists) flatten;
in {
nixpkgs.overlays = [
(_final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // {allowMissing = true;});
})
];
imports = flatten (with tree; [
users.root
users.chaos
(with tree.presets.nixos; [
#desktopGui
])
(with presets.home-manager.by-user; [
root.base
chaos.base
#chaos.guiDesktop
])
./hardware.nix
]);
networking.firewall = {
enable = true;
allowPing = true;
};
networking.hostName = "raspberry";
time.timeZone = "Europe/London";
system.stateVersion = "24.05";
home-manager.users.root.home.stateVersion = "24.05";
home-manager.users.chaos.home.stateVersion = "24.05";
}

View file

@ -10,7 +10,7 @@
in { in {
hardware = { hardware = {
enableAllFirmware = false; # we include a more minimal subset for base enableAllFirmware = false; # we include a more minimal subset for base
enableRedistributableFirmware = false; enableRedistributableFirmware = true;
wirelessRegulatoryDatabase = true; wirelessRegulatoryDatabase = true;
firmware = with pkgs; [ firmware = with pkgs; [

View file

@ -9,6 +9,7 @@ in {
emulatedSystems = ["aarch64-linux"]; emulatedSystems = ["aarch64-linux"];
registrations.aarch64-linux = { registrations.aarch64-linux = {
interpreter = mkForce "${pkgs.qemu}/bin/qemu-aarch64"; interpreter = mkForce "${pkgs.qemu}/bin/qemu-aarch64";
fixBinary = true;
}; };
}; };
nix.settings.extra-sandbox-paths = ["/run/binfmt" "${pkgs.qemu}"]; nix.settings.extra-sandbox-paths = ["/run/binfmt" "${pkgs.qemu}"];

View file

@ -0,0 +1,15 @@
{
pkgs,
lib,
...
}: let
inherit (lib.modules) mkForce;
in {
boot.binfmt = {
emulatedSystems = ["x86_64-linux"];
registrations.x86_64-linux = {
interpreter = mkForce "${pkgs.qemu}/bin/qemu-x86_64";
};
};
nix.settings.extra-sandbox-paths = ["/run/binfmt" "${pkgs.qemu}"];
}