From 06847c6f6fdbeb048b12df1d427842ad5d6a5417 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Sat, 27 Jan 2024 14:22:51 +0100 Subject: [PATCH] infrastructure --- configuration.nix | 53 +++++++++++++++++++++++++++++++++++++++++----- flake.lock | 17 +++++++++++++++ flake.nix | 5 +++-- spi0-0cs.dtbo | Bin 0 -> 794 bytes 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 spi0-0cs.dtbo diff --git a/configuration.nix b/configuration.nix index 55132a7..a8d3450 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,8 +1,6 @@ -{ stable, config, pkgs, lib, ... }: +{ hardware, stable, config, pkgs, lib, ... }: let - SSID = "mywifi"; - SSIDpassword = "mypassword"; interface = "wlan0"; hostname = "nixpi"; in { @@ -23,6 +21,47 @@ in { LC_TIME = "de_DE.UTF-8"; }; + + 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 = {}; + console.keyMap = "de"; services.xserver = { @@ -52,7 +91,8 @@ in { hostName = hostname; wireless = { enable = true; -# networks."${SSID}".psk = SSIDpassword; + userControlled.enable = false; + networks = (import ./networks.nix); interfaces = [ interface ]; }; }; @@ -66,7 +106,8 @@ in { shell = pkgs.xonsh; isNormalUser = true; hashedPassword = "$y$j9T$ODBtPwWjIx50Bjhctw9kW/$jhfsHaAyh8zOXBV7cCK9l2M0yWyE3VLiL0h55XXV5J2"; - extraGroups = [ "wheel" ]; + extraGroups = [ "wheel" "gpio" "spi" "dialout" ]; + openssh.authorizedKeys.keys = (import ./authorizedKeys.nix); }; }; @@ -83,7 +124,9 @@ in { git-lfs lm_sensors file + (writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@") raspberrypi-eeprom + libraspberrypi ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; diff --git a/flake.lock b/flake.lock index d9bf892..49bd48f 100644 --- a/flake.lock +++ b/flake.lock @@ -64,6 +64,22 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1706182238, + "narHash": "sha256-Ti7CerGydU7xyrP/ow85lHsOpf+XMx98kQnPoQCSi1g=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "f84eaffc35d1a655e84749228cde19922fcf55f1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1703013332, @@ -115,6 +131,7 @@ "root": { "inputs": { "agenix": "agenix", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable" } diff --git a/flake.nix b/flake.nix index 57d0345..645c9b0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ -# /etc/nixos/flake.nix { description = "flake for a remote display on a raspi"; @@ -6,9 +5,10 @@ nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11"; agenix.url = "github:ryantm/agenix"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; - outputs = {nixpkgs, nixpkgs-stable, agenix, ...} @ inputs: let + outputs = {nixpkgs, nixpkgs-stable, agenix, nixos-hardware, ...} @ inputs: let system = "aarch64-linux"; stable = import nixpkgs-stable { inherit system; config.allowUnfree = true; }; in { @@ -17,6 +17,7 @@ specialArgs = { inherit inputs stable; }; modules = [ ./configuration.nix + nixos-hardware.nixosModules.raspberry-pi-4 agenix.nixosModules.default ]; }; diff --git a/spi0-0cs.dtbo b/spi0-0cs.dtbo new file mode 100644 index 0000000000000000000000000000000000000000..8b20ab7e2eb3a2589cef2a4f38d246b295befe9f GIT binary patch literal 794 zcmaiyT}lHn5XWa*MQbUjAc*+rgAbN|DU_lhUceV0g^>L;*ldj}y1$AbV zHCn9>{5Q$uH#5m(UpjBE0L>!+7y~qxIG&>RP`fCy6#dV3`t2LIRTIY!&BHR1XJI6V zE-n>Mv!X6QaR;cIFL4vY z%PcVy`26jC jr9m5RW*TzEq|gee1%1$k=(9+(Dufo~iIe%j?o{p%;mn#F literal 0 HcmV?d00001