remote-display-pi/configuration.nix

138 lines
3.4 KiB
Nix
Raw Normal View History

2024-01-27 14:22:51 +01:00
{ hardware, stable, config, pkgs, lib, ... }:
2024-01-27 10:53:10 +01:00
let
interface = "wlan0";
hostname = "nixpi";
in {
time.timeZone = "Europe/Berlin";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
2024-01-27 14:22:51 +01:00
services.xserver = {
enable = true;
# displayManager.lightdm.enable = true;
# desktopManager.gnome.enable = true;
videoDrivers = [ "fbdev" ];
};
sound.enable = true;
hardware.pulseaudio.enable = true;
# Create gpio group
users.groups.gpio = {};
# Change permissions gpio devices
services.udev.extraRules = ''
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio",MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
SUBSYSTEM=="spidev", KERNEL=="spidev0.0", GROUP="spi", MODE="0660"
'';
hardware = {
raspberry-pi."4" = {
# audio.enable = true;
apply-overlays-dtmerge.enable = true;
};
deviceTree = {
enable = true;
filter = "*rpi-4-*.dtb";
overlays = [
{
name = "spi";
dtboFile = ./spi0-0cs.dtbo;
}
];
};
};
users.groups.spi = {};
2024-01-27 10:53:10 +01:00
console.keyMap = "de";
services.xserver = {
layout = "de";
xkbVariant = "";
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" ];
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
networking = {
hostName = hostname;
wireless = {
enable = true;
2024-01-27 14:22:51 +01:00
userControlled.enable = false;
networks = (import ./networks.nix);
2024-01-27 10:53:10 +01:00
interfaces = [ interface ];
};
};
services.openssh.enable = true;
programs.xonsh.enable = true;
users = {
mutableUsers = false;
users."pi" = {
shell = pkgs.xonsh;
isNormalUser = true;
hashedPassword = "$y$j9T$ODBtPwWjIx50Bjhctw9kW/$jhfsHaAyh8zOXBV7cCK9l2M0yWyE3VLiL0h55XXV5J2";
2024-01-27 14:22:51 +01:00
extraGroups = [ "wheel" "gpio" "spi" "dialout" ];
openssh.authorizedKeys.keys = (import ./authorizedKeys.nix);
2024-01-27 10:53:10 +01:00
};
};
hardware.enableRedistributableFirmware = true;
system.stateVersion = "23.11";
environment.systemPackages = with pkgs; [
wget
hyfetch
usbutils
pciutils
git
btop
git-lfs
lm_sensors
file
2024-01-27 14:22:51 +01:00
(writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@")
2024-01-27 10:53:10 +01:00
raspberrypi-eeprom
2024-01-27 14:22:51 +01:00
libraspberrypi
2024-01-27 10:53:10 +01:00
];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nixpkgs.config.allowUnfree = true;
boot.tmp.cleanOnBoot = true;
zramSwap.enable = true;
}