diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-01-27 15:20:47 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-01-27 15:20:47 +0100 |
commit | e105f15292f5de776bcebac9972eaca296c236bd (patch) | |
tree | be3a7643b3c6977f5a12bec0aea5f1b17d70844f /machines | |
parent | b7c4edc5c3d154d8b488cc65e1c6eee171c0f74a (diff) | |
download | dots-e105f15292f5de776bcebac9972eaca296c236bd.tar.gz dots-e105f15292f5de776bcebac9972eaca296c236bd.zip |
Add rpi config
Diffstat (limited to 'machines')
-rw-r--r-- | machines/rpi3-amadeus/configuration.nix | 58 | ||||
-rw-r--r-- | machines/rpi3-amadeus/default.nix | 6 | ||||
-rw-r--r-- | machines/rpi3-amadeus/hyperion-ng.nix | 80 | ||||
-rw-r--r-- | machines/rpi3-amadeus/hyperion.nix | 32 | ||||
-rw-r--r-- | machines/rpi3-amadeus/mpdecimal.nix | 27 | ||||
-rw-r--r-- | machines/rpi3-amadeus/spi.dts | 49 | ||||
-rw-r--r-- | machines/rpi3-amadeus/spi.nix | 11 |
7 files changed, 263 insertions, 0 deletions
diff --git a/machines/rpi3-amadeus/configuration.nix b/machines/rpi3-amadeus/configuration.nix new file mode 100644 index 0000000..989bdbb --- /dev/null +++ b/machines/rpi3-amadeus/configuration.nix @@ -0,0 +1,58 @@ +{ config, pkgs, lib, ... }: +{ + + imports = [ + ./modules/hyperion.nix + ]; + + + # NixOS wants to enable GRUB by default + boot.loader.grub.enable = false; + # Enables the generation of /boot/extlinux/extlinux.conf + boot.loader.generic-extlinux-compatible.enable = true; + + # !!! Set to specific linux kernel version + boot.kernelPackages = pkgs.linuxPackages_5_4; + + # !!! Needed for the virtual console to work on the RPi 3, as the default of 16M doesn't seem to be enough. + # If X.org behaves weirdly (I only saw the cursor) then try increasing this to 256M. + # On a Raspberry Pi 4 with 4 GB, you should either disable this parameter or increase to at least 64M if you want the USB ports to work. + boot.kernelParams = ["cma=256M"]; + + # Settings above are the bare minimum + # All settings below are customized depending on your needs + + # systemPackages + environment.systemPackages = with pkgs; [ + vim curl wget + ]; + + services.openssh = { + enable = true; + permitRootLogin = "yes"; + }; + + networking.firewall.enable = false; + + # put your own configuration here, for example ssh keys: + users.mutableUsers = true; + users.groups = { + nixos = { + gid = 1000; + name = "nixos"; + }; + }; + users.users = { + nixos = { + uid = 1000; + home = "/home/nixos"; + name = "nixos"; + group = "nixos"; + extraGroups = [ "wheel" ]; + }; + }; + # users.extraUsers.root.openssh.authorizedKeys.keys = [ + # # Your ssh key + # "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM" + # ]; +} diff --git a/machines/rpi3-amadeus/default.nix b/machines/rpi3-amadeus/default.nix new file mode 100644 index 0000000..cd4010f --- /dev/null +++ b/machines/rpi3-amadeus/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./hardware-configuration.nix + ./configuration.nix + ]; +} diff --git a/machines/rpi3-amadeus/hyperion-ng.nix b/machines/rpi3-amadeus/hyperion-ng.nix new file mode 100644 index 0000000..ed47d53 --- /dev/null +++ b/machines/rpi3-amadeus/hyperion-ng.nix @@ -0,0 +1,80 @@ +{ stdenv, fetchurl, fetchzip, autoPatchelfHook, callPackage, +expat, glib, systemd, libX11, libXrandr, fontconfig, tlf, ncurses5, bzip2, +readline70, openssl, db, libglvnd, libusb }: +with stdenv.lib; +let + version = "2.0.0-alpha.9"; + + srcAarch64 = fetchurl { + url = "https://github.com/hyperion-project/hyperion.ng/releases/download/${version}/Hyperion-${version}-Linux-aarch64.tar.gz"; + sha256 = "09wvlhp5c1mkvjsgbsiy402cx8na7qykwgv4waivc7m5ns4sl2mf"; + }; + + srcX86 = fetchurl { + url = "https://github.com/hyperion-project/hyperion.ng/releases/download/${version}/Hyperion-${version}-Linux-x86_64.tar.gz"; + sha256 = "1gkjzqkh6qbwzkrdrg9xmznh6b676kmdlw54drqwfycakb7riad2"; + }; + + mpdecimal = callPackage ./mpdecimal.nix {}; + + bzip2_linked = stdenv.mkDerivation { + name = "bzip2-linked"; + unpackPhase = "true"; + installPhase = '' + mkdir -p $out/lib + cp -r ${bzip2.out}/lib/libbz2.so.1.0.6 $out/lib + ln -s $out/lib/libbz2.so.1.0.6 $out/lib/libbz2.so.1.0 + ''; + }; + + python3 = (import (fetchzip { + url = "https://github.com/nixos/nixpkgs/archive/7731621c81b5cd601a176c2109b44c5295049f20.zip"; + # Please update this hash with the one nix says on the first build attempt + sha256 = "0gdf2kkh3qcn9r300sl4khcg0fnixarjcil9pv9hami3dqjbpngv"; + }) { }).python3; +in +stdenv.mkDerivation { + inherit version; + pname = "hyperion-ng"; + + src = srcAarch64; + + nativeBuildInputs = [ autoPatchelfHook ]; + + buildInputs = [ + python3 + systemd + stdenv.cc.cc.lib + fontconfig.lib + tlf + ncurses5 + mpdecimal + glib + readline70 + openssl + db + libglvnd + libusb + expat + libX11 + libXrandr + + bzip2_linked + ]; + + sourceRoot = "share/hyperion"; + + buildPhase = ""; + installPhase = '' + mkdir -p $out/bin $out/lib + cp -r bin $out + cp -r lib $out + + #ln -s ${bzip2}/lib/libbz2.so.1.0.6 $out/lib/libbz2.so.1.0 + ''; + + meta = { + description = "Hyperion is an open source ambient light software. Feel free to join us and contribute new features!"; + homepage = "https://hyperion-project.org/"; + }; +} diff --git a/machines/rpi3-amadeus/hyperion.nix b/machines/rpi3-amadeus/hyperion.nix new file mode 100644 index 0000000..531eaad --- /dev/null +++ b/machines/rpi3-amadeus/hyperion.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: +let + hyperion = pkgs.callPackage ./hyperion-ng.nix { }; + hyperionConfig = pkgs.fetchurl { + url = "https://gist.githubusercontent.com/pniedzwiedzinski/e1810bc4dd08b97512d28c42daa95326/raw/460febec24390dc90d3b70987f07ef1ab8a77b3a/hyperion.config.json"; + sha256 = "1yaiw8ljy6kaq6vnf5ccq2c4wpjlakd00nmq51v1q2sdnc06jmqq"; + }; +in +{ + imports = [ + ./spi.nix + ]; + + environment.systemPackages = [ + hyperion + ]; + + systemd.services.hyperion = { + enable = true; + wantedBy = ["multi-user.target"]; + serviceConfig = { + ExecStart = "${hyperion}/bin/hyperiond"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + Restart = "on-failure"; + User = "root"; + Group = "root"; + Type = "simple"; + UMask = "007"; + TimeoutStopSec = "10"; + }; + }; +} diff --git a/machines/rpi3-amadeus/mpdecimal.nix b/machines/rpi3-amadeus/mpdecimal.nix new file mode 100644 index 0000000..fee59ee --- /dev/null +++ b/machines/rpi3-amadeus/mpdecimal.nix @@ -0,0 +1,27 @@ +{ stdenv, fetchurl, gcc, binutils }: + +let + pname = "mpdecimal"; + version = "2.5.0"; +in +stdenv.mkDerivation { + inherit pname version; + + src = fetchurl { + url = "https://www.bytereef.org/software/${pname}/releases/${pname}-${version}.tar.gz"; + sha256 = "1jm0vzlcsapx9ilrvns4iyws6n5i48zpxykmklfpv98jivf7wh8m"; + }; + + buildPhase = '' + ./configure + + sed -i 's/-Wl,//' libmpdec/Makefile + make + ''; + + installPhase = '' + mkdir -p $out/lib + cp libmpdec/*.so* $out/lib + ''; + +} diff --git a/machines/rpi3-amadeus/spi.dts b/machines/rpi3-amadeus/spi.dts new file mode 100644 index 0000000..db76c4b --- /dev/null +++ b/machines/rpi3-amadeus/spi.dts @@ -0,0 +1,49 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "raspberrypi"; + fragment@0 { + target = <&spi>; + __overlay__ { + cs-gpios = <&gpio 8 1>, <&gpio 7 1>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins &spi0_cs_pins>; + #address-cells = <1>; + #size-cells = <0>; + spidev@0 { + reg = <0>; // CE0 + spi-max-frequency = <500000>; + compatible = "spidev"; + }; + + spidev@1 { + reg = <1>; // CE1 + spi-max-frequency = <500000>; + compatible = "spidev"; + }; + }; + }; + fragment@1 { + target = <&alt0>; + __overlay__ { + // Drop GPIO 7, SPI 8-11 + brcm,pins = <4 5>; + }; + }; + + fragment@2 { + target = <&gpio>; + __overlay__ { + spi0_pins: spi0_pins { + brcm,pins = <9 10 11>; + brcm,function = <4>; // alt0 + }; + spi0_cs_pins: spi0_cs_pins { + brcm,pins = <8 7>; + brcm,function = <1>; // out + }; + }; + }; +}; diff --git a/machines/rpi3-amadeus/spi.nix b/machines/rpi3-amadeus/spi.nix new file mode 100644 index 0000000..8a8f332 --- /dev/null +++ b/machines/rpi3-amadeus/spi.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + hardware.deviceTree = { + enable = true; + filter = "*rpi*.dtb"; + overlays = [{ + name = "spi"; + dtsFile = ./spi.dts; + }]; + }; +} |