{ config, lib, pkgs, ... }: let octoprintPort = 8080; in { imports = [ ./hardware-configuration.nix ]; c3d2 = { isInHq = true; mergeHostsFile = true; hq.interface = "eth0"; hq.statistics.enable = true; k-ot.enable = true; audioServer.enable = true; }; boot = { loader = { grub.enable = false; raspberryPi = { enable = true; version = 3; uboot.enable = true; }; }; kernelPackages = pkgs.linuxPackages_latest; # No ZFS on latest kernel: supportedFilesystems = lib.mkForce [ "vfat" "ext4" ]; kernelParams = [ "console=tty0" ]; tmpOnTmpfs = true; }; hardware.deviceTree = { enable = true; kernelPackage = config.boot.kernelPackages.kernel; }; nixpkgs.config.packageOverrides = pkgs: { makeModulesClosure = x: # prevent kernel install fail due to missing modules pkgs.makeModulesClosure (x // { allowMissing = true; }); }; nix = { buildCores = 4; maxJobs = 2; }; networking = { hostName = "pulsebert"; # Define your hostname. # The global useDHCP flag is deprecated, therefore explicitly set to false here. # Per-interface useDHCP will be mandatory in the future, so this generated config # replicates the default behaviour. useDHCP = false; interfaces.eth0.useDHCP = true; interfaces.wlan0.useDHCP = true; firewall.enable = false; }; environment.systemPackages = with pkgs; [ libraspberrypi mpd mpv ncmpcpp ncpamixer pulseaudio # required for pactl ]; programs.tmux.enable = true; security.sudo = { enable = true; wheelNeedsPassword = false; }; # quirk for this pi3 systemd.services.bluetooth.serviceConfig = { Restart = "always"; RestartSec = "1s"; }; users.users = { # Allow access to printer serial port and GPIO "${config.services.octoprint.user}".extraGroups = [ "dialout" ]; # Allow gpio group to access GPIO devices gpio = { isNormalUser = true; group = "gpio"; }; }; services = { # Do not log to flash: journald.extraConfig = '' Storage=volatile ''; openssh = { enable = true; }; mjpg-streamer = { enable = true; inputPlugin = "input_uvc.so -d /dev/v4l/by-id/usb-046d_0817_4B7115A0-video-index0 -r 640x480 -f 30 -pl 50hz -ex auto"; outputPlugin = "output_http.so -p 3020"; }; nginx = { enable = true; virtualHosts = { "drkkr.hq.c3d2.de" = { default = true; enableACME = true; forceSSL = true; locations."/" = { proxyPass = "http://127.0.0.1:${toString octoprintPort}"; proxyWebsockets = true; extraConfig = '' proxy_set_header X-Scheme $scheme; proxy_set_header Accept-Encoding identity; client_max_body_size 2000M; ''; }; locations."/cam/stream" = { proxyPass = "http://localhost:3020/?action=stream"; extraConfig = "proxy_pass_request_headers off;"; }; locations."/cam/capture" = { proxyPass = "http://localhost:3020/?action=snapshot"; extraConfig = "proxy_pass_request_headers off;"; }; }; }; }; octoprint = rec { enable = true; port = octoprintPort; extraConfig.webcam = { snapshot = "http://localhost:3020?action=snapshot"; stream = "https://drkkr.hq.c3d2.de/cam/stream"; }; # plugins = let # python = pkgs.octoprint.python; # octoprint-filament-sensor-universal = python.pkgs.buildPythonPackage rec { # pname = "OctoPrint-Filament-Sensor-Universal"; # version = "1.0.0"; # src = pkgs.fetchFromGitHub { # owner = "lopsided98"; # repo = pname; # rev = "8a72696867a9a008c5a79b49a9b029a4fc426720"; # sha256 = "1a7lzmjbwx47qhrkjp3hggiwnx172x4axcz0labm9by17zxlsimr"; # }; # propagatedBuildInputs = [ pkgs.octoprint python.pkgs.libgpiod ]; # }; # #in p: [ octoprint-filament-sensor-universal ]; # in p: []; }; udev.extraRules = '' KERNEL=="gpiochip*", GROUP="gpio", MODE="0660" ''; }; system.stateVersion = "21.05"; # Did you read the comment? }