remote-display-pi/configuration.nix

145 lines
3.7 KiB
Nix
Raw Permalink 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
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-02-07 11:57:46 +01:00
console.keyMap = "de";
2024-01-27 10:53:10 +01:00
services.xserver = {
layout = "de";
2024-02-07 11:57:46 +01:00
displayManager.startx.enable = true;
2024-01-27 10:53:10 +01:00
xkbVariant = "";
2024-02-07 11:57:46 +01:00
videoDrivers = [ "fbdev" ];
enable = true;
2024-01-27 10:53:10 +01:00
};
boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
2024-02-07 11:57:46 +01:00
kernelParams = [ "quiet" ];
2024-01-27 10:53:10 +01:00
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";
2024-02-07 11:57:46 +01:00
hardware.bluetooth.enable = false;
2024-01-27 10:53:10 +01:00
environment.systemPackages = with pkgs; [
wget
hyfetch
usbutils
pciutils
lm_sensors
2024-02-07 09:58:10 +01:00
btop
2024-01-27 10:53:10 +01:00
file
raspberrypi-eeprom
2024-01-27 14:22:51 +01:00
libraspberrypi
2024-02-07 11:57:46 +01:00
xorg.xinit
xorg.xorgserver
xorg.xf86inputevdev
xorg.xf86inputsynaptics
xorg.xf86inputlibinput
xorg.xf86videofbdev
tigervnc
jq
(writeShellScriptBin "connectvnc" "startx `which vncviewer` -fullscreen -viewonly grimmauld-nixos:5900 -passwd /root/.vnc/passwd --") # fixme: change address
2024-01-27 10:53:10 +01:00
];
2024-02-07 11:57:46 +01:00
hardware.opengl.enable = true;
hardware.opengl.driSupport = true;
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;
}