nix-config/hosts/pulsebert/default.nix

221 lines
5.7 KiB
Nix
Raw Normal View History

2020-06-19 19:05:46 +02:00
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
2020-12-10 17:26:47 +01:00
let
octoprintPort = 8080;
2021-02-22 11:45:12 +01:00
in {
2020-08-04 17:15:07 +02:00
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;
generic-extlinux-compatible.enable = false;
raspberryPi = {
enable = true;
version = 4;
uboot.enable = false;
};
};
#kernelPackages = pkgs.linuxPackages_rpi4;
kernelPackages = pkgs.linuxPackages_latest;
2020-06-19 19:05:46 +02:00
2021-09-07 21:13:41 +02:00
tmpOnTmpfs = true;
};
c3d2 = {
isInHq = true;
mapHqHosts = true;
hq.interface = "eth0";
};
2021-09-07 21:13:41 +02:00
nix = {
buildCores = 4;
maxJobs = 4;
};
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
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
git
2021-09-12 21:40:33 +02:00
htop
libraspberrypi
mpd
2021-09-07 21:13:51 +02:00
mpv
ncmpcpp
2021-09-06 20:50:09 +02:00
ncpamixer
2021-09-12 21:40:33 +02:00
vim
wget
];
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;
permitRootLogin = "yes";
};
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
};
# Enable sound.
sound.enable = true;
hardware.bluetooth = {
enable = true;
2021-09-06 23:58:12 +02:00
settings = {
2020-06-19 19:05:46 +02:00
Policy.AutoEnable = true;
General = {
Enable = "Source,Sink,Media,Socket";
#DiscoverableTimeout = 0;
#Discoverable = true;
};
};
};
hardware.pulseaudio = {
enable = true;
systemWide = true;
tcp.enable = true;
tcp.anonymousClients.allowedIpRanges = [
2021-02-22 11:45:12 +01:00
"127.0.0.0/8"
"::1/128"
"fd23:42:c3d2:500::/56"
2021-02-22 11:45:12 +01:00
"172.22.99.0/24"
"172.20.72.0/21"
2021-06-02 21:37:18 +02:00
"2a00:8180:2c00:200::/56"
2020-06-19 19:05:46 +02:00
];
zeroconf.publish.enable = true;
package = pkgs.pulseaudioFull;
extraModules = [ pkgs.pulseaudio-modules-bt ];
};
# tell Avahi to publish CUPS and PulseAudio
services.avahi = {
enable = true;
2021-09-07 21:13:41 +02:00
publish = {
enable = true;
addresses = true;
userServices = true;
};
2020-06-19 19:05:46 +02:00
};
2020-12-10 17:26:47 +01:00
security.acme = {
acceptTerms = true;
email = "mail@c3d2.de";
};
services.dhcpd4 = {
enable = true;
interfaces = [ config.c3d2.hq.interface ];
authoritative = false;
# the leases are defined in the secrets module imported
# at the top-level of this flake
};
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).
system.stateVersion = "20.09"; # Did you read the comment?
}