nix-config/hosts/pulsebert/default.nix

168 lines
4.5 KiB
Nix
Raw Normal View History

2021-09-20 22:26:37 +02:00
{ config, lib, pkgs, ... }:
2020-06-19 19:05:46 +02:00
2020-12-10 17:26:47 +01:00
let
octoprintPort = 8080;
in
{
imports = [
# Include the results of the hardware scan.
2021-02-22 13:21:31 +01:00
./hardware-configuration.nix
2020-08-04 17:15:07 +02:00
];
2020-06-19 19:05:46 +02:00
2021-09-07 21:13:41 +02:00
boot = {
loader = {
grub.enable = false;
raspberryPi = {
enable = true;
2021-09-23 00:04:02 +02:00
version = 3;
uboot.enable = true;
2021-09-07 21:13:41 +02:00
};
};
2021-10-19 00:24:18 +02:00
kernelPackages = pkgs.linuxPackages_latest;
# TODO: can be removed when https://github.com/NixOS/nixpkgs/pull/142015 is merged
kernelPatches = [{
name = "disable-FB_SIMPLE";
patch = null;
extraConfig = ''
FB_SIMPLE m
'';
}];
2021-09-07 21:13:41 +02:00
tmpOnTmpfs = true;
};
c3d2 = {
isInHq = true;
mapHqHosts = true;
hq.interface = "eth0";
2021-09-28 00:28:51 +02:00
hq.statistics.enable = true;
};
2021-09-07 21:13:41 +02:00
nix = {
buildCores = 4;
2021-09-23 00:04:02 +02:00
maxJobs = 2;
2021-09-07 21:13:41 +02:00
};
2020-06-19 19:05:46 +02:00
2021-09-07 21:13:41 +02:00
networking = {
hostName = "pulsebert"; # Define your hostname.
2020-06-19 19:05:46 +02:00
# 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.
2021-09-07 21:13:41 +02:00
useDHCP = false;
interfaces.eth0.useDHCP = true;
interfaces.wlan0.useDHCP = true;
firewall.enable = false;
};
2020-06-19 19:05:46 +02:00
environment.systemPackages = with pkgs; [
2021-09-12 21:40:33 +02:00
libraspberrypi
mpd
2021-09-07 21:13:51 +02:00
mpv
ncmpcpp
2021-09-06 20:50:09 +02:00
ncpamixer
2021-09-20 22:26:37 +02:00
pulseaudio # required for pactl
];
2020-06-19 19:05:46 +02:00
2021-09-07 21:14:00 +02:00
programs.tmux.enable = true;
2020-06-19 19:05:46 +02:00
# Do not log to flash:
services.journald.extraConfig = ''
Storage=volatile
'';
2020-06-19 19:05:46 +02:00
# Enable the OpenSSH daemon.
2021-09-07 21:13:41 +02:00
services.openssh = {
enable = true;
};
2020-06-19 19:05:46 +02:00
security.sudo = {
enable = true;
wheelNeedsPassword = false;
};
users.users.k-ot = {
isNormalUser = true;
extraGroups = [ "wheel" "audio" ];
2020-06-19 19:05:46 +02:00
};
2021-09-27 22:40:27 +02:00
c3d2.audioServer.enable = true;
2020-06-19 19:05:46 +02:00
2020-12-10 17:26:47 +01:00
services.nginx = {
enable = true;
#recommendedGzipSettings = true;
recommendedProxySettings = 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;
2021-04-09 17:37:27 +02:00
client_max_body_size 2000M;
2020-12-10 17:26:47 +01:00
'';
};
2021-01-28 01:04:49 +01:00
locations."/cam/stream" = {
2021-02-25 17:50:15 +01:00
proxyPass = "http://localhost:3020/?action=stream";
2021-01-28 01:04:49 +01:00
extraConfig = "proxy_pass_request_headers off;";
};
locations."/cam/capture" = {
2021-02-25 17:50:15 +01:00
proxyPass = "http://localhost:3020/?action=snapshot";
2021-01-28 01:04:49 +01:00
extraConfig = "proxy_pass_request_headers off;";
};
2020-12-10 17:26:47 +01:00
};
};
};
services.octoprint = rec {
enable = true;
2020-12-10 17:26:47 +01:00
port = octoprintPort;
2021-02-25 17:50:15 +01:00
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: [];
};
2020-06-19 19:05:46 +02:00
# Allow access to printer serial port and GPIO
2021-09-07 21:13:41 +02:00
users.users.${config.services.octoprint.user}.extraGroups = [ "dialout" "gpio" ];
2020-06-19 19:05:46 +02:00
2021-02-25 17:32:24 +01:00
services.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";
};
# Allow gpio group to access GPIO devices
users.groups.gpio = { };
services.udev.extraRules = ''
KERNEL=="gpiochip*", GROUP="gpio", MODE="0660"
'';
2020-06-19 19:05:46 +02:00
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
2021-09-23 00:04:02 +02:00
system.stateVersion = "21.05"; # Did you read the comment?
2020-06-19 19:05:46 +02:00
}