2021-09-20 22:26:37 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2021-09-22 22:24:05 +02:00
|
|
|
{
|
|
|
|
imports = [
|
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
|
|
|
|
2022-06-12 17:26:32 +02:00
|
|
|
c3d2 = {
|
2021-02-23 20:13:13 +01:00
|
|
|
isInHq = true;
|
2022-01-18 23:07:39 +01:00
|
|
|
mergeHostsFile = true;
|
2021-02-24 14:16:42 +01:00
|
|
|
hq.interface = "eth0";
|
2021-09-28 00:28:51 +02:00
|
|
|
hq.statistics.enable = true;
|
2022-01-16 12:25:04 +01:00
|
|
|
k-ot.enable = true;
|
2022-03-29 22:53:12 +02:00
|
|
|
audioServer.enable = true;
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
|
|
|
|
2021-09-07 21:13:41 +02:00
|
|
|
boot = {
|
2022-08-23 00:19:33 +02:00
|
|
|
growPartition = true;
|
2021-09-07 21:13:41 +02:00
|
|
|
loader = {
|
|
|
|
grub.enable = false;
|
|
|
|
};
|
2022-08-23 00:19:33 +02:00
|
|
|
kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
|
2021-12-10 00:19:44 +01:00
|
|
|
# No ZFS on latest kernel:
|
|
|
|
supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
|
2022-03-29 22:53:12 +02:00
|
|
|
kernelParams = [ "console=tty0" ];
|
2021-09-07 21:13:41 +02:00
|
|
|
tmpOnTmpfs = true;
|
|
|
|
};
|
2022-06-12 17:26:32 +02:00
|
|
|
|
2021-12-14 23:30:24 +01:00
|
|
|
hardware.deviceTree = {
|
|
|
|
enable = true;
|
|
|
|
kernelPackage = config.boot.kernelPackages.kernel;
|
|
|
|
};
|
2022-06-12 17:26:32 +02:00
|
|
|
|
2022-01-07 22:32:47 +01:00
|
|
|
nixpkgs.config.packageOverrides = pkgs: {
|
|
|
|
makeModulesClosure = x:
|
|
|
|
# prevent kernel install fail due to missing modules
|
|
|
|
pkgs.makeModulesClosure (x // { allowMissing = true; });
|
|
|
|
};
|
2021-02-23 20:13:13 +01:00
|
|
|
|
2021-09-07 21:13:41 +02:00
|
|
|
nix = {
|
|
|
|
buildCores = 4;
|
2022-08-21 22:28:26 +02:00
|
|
|
maxJobs = 1;
|
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 = {
|
2022-08-21 22:28:26 +02:00
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
80 # nginx
|
|
|
|
443 # nginx
|
|
|
|
4713 # pulseaudio/pipewire network sync
|
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
2022-08-23 00:19:58 +02:00
|
|
|
5353 # mdns
|
2022-08-21 22:28:26 +02:00
|
|
|
5355 # llmnr
|
|
|
|
];
|
|
|
|
};
|
|
|
|
hostName = "pulsebert";
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2021-09-22 22:24:05 +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;
|
2022-08-21 22:28:26 +02:00
|
|
|
interfaces = {
|
|
|
|
eth0.useDHCP = true;
|
2022-08-23 00:19:45 +02:00
|
|
|
wlan0.useDHCP = false; # broken
|
2022-08-21 22:28:26 +02:00
|
|
|
};
|
2021-09-07 21:13:41 +02:00
|
|
|
};
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2021-02-24 14:16:42 +01:00
|
|
|
environment.systemPackages = with pkgs; [
|
2021-09-12 21:40:33 +02:00
|
|
|
libraspberrypi
|
2021-02-24 14:16:42 +01:00
|
|
|
mpd
|
2021-09-07 21:13:51 +02:00
|
|
|
mpv
|
2021-02-24 14:16:42 +01:00
|
|
|
ncmpcpp
|
2021-09-06 20:50:09 +02:00
|
|
|
ncpamixer
|
2021-09-20 22:26:37 +02:00
|
|
|
pulseaudio # required for pactl
|
2021-02-24 14:16:42 +01:00
|
|
|
];
|
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
|
|
|
|
2022-07-08 22:03:31 +02:00
|
|
|
security = {
|
|
|
|
rtkit.enable = true;
|
|
|
|
sudo = {
|
|
|
|
enable = true;
|
|
|
|
wheelNeedsPassword = false;
|
|
|
|
};
|
2020-06-19 19:05:46 +02:00
|
|
|
};
|
|
|
|
|
2022-03-29 22:53:12 +02:00
|
|
|
# quirk for this pi3
|
|
|
|
systemd.services.bluetooth.serviceConfig = {
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "1s";
|
|
|
|
};
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2022-08-21 22:10:01 +02:00
|
|
|
users.users = lib.mkMerge [
|
|
|
|
(lib.optionalAttrs config.services.octoprint.enable {
|
|
|
|
# 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";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2022-06-12 17:26:32 +02:00
|
|
|
|
2020-12-10 17:26:47 +01:00
|
|
|
services = {
|
2020-06-21 22:26:30 +02:00
|
|
|
# Do not log to flash:
|
|
|
|
journald.extraConfig = ''
|
|
|
|
Storage=volatile
|
2022-06-12 17:26:32 +02:00
|
|
|
'';
|
|
|
|
|
2021-09-07 21:13:41 +02:00
|
|
|
openssh = {
|
2020-12-10 17:26:47 +01:00
|
|
|
enable = true;
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
|
|
|
|
2020-12-10 17:26:47 +01:00
|
|
|
mjpg-streamer = {
|
2022-08-21 22:29:01 +02:00
|
|
|
# crashes with: MJPG-streamer [3040]: init_VideoIn failed
|
|
|
|
enable = false;
|
2020-12-10 17:26:47 +01:00
|
|
|
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";
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
|
|
|
|
2020-12-10 17:26:47 +01:00
|
|
|
nginx = {
|
2020-12-10 15:24:45 +01:00
|
|
|
enable = true;
|
2020-12-10 17:26:47 +01:00
|
|
|
virtualHosts = {
|
|
|
|
"drkkr.hq.c3d2.de" = {
|
|
|
|
default = true;
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
2022-08-21 22:09:39 +02:00
|
|
|
proxyPass = "http://127.0.0.1:${toString config.services.octoprint.port}";
|
2020-12-10 17:26:47 +01:00
|
|
|
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;";
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
2021-01-28 01:04:49 +01:00
|
|
|
};
|
2020-12-10 17:26:47 +01:00
|
|
|
};
|
|
|
|
};
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2020-12-10 15:24:45 +01:00
|
|
|
octoprint = rec {
|
|
|
|
enable = true;
|
2022-08-21 22:09:39 +02:00
|
|
|
port = 8080;
|
2021-02-25 17:50:15 +01:00
|
|
|
extraConfig.webcam = {
|
2020-12-10 15:24:45 +01:00
|
|
|
snapshot = "http://localhost:3020?action=snapshot";
|
2021-02-25 17:50:15 +01:00
|
|
|
stream = "https://drkkr.hq.c3d2.de/cam/stream";
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
2020-12-10 15:24:45 +01:00
|
|
|
# plugins = let
|
|
|
|
# python = pkgs.octoprint.python;
|
2022-06-12 17:26:32 +02:00
|
|
|
|
2020-12-10 15:24:45 +01:00
|
|
|
# octoprint-filament-sensor-universal = python.pkgs.buildPythonPackage rec {
|
2021-10-31 19:00:03 +01:00
|
|
|
# pname = "OctoPrint-Filament-Sensor-Universal";
|
|
|
|
# version = "1.0.0";
|
2022-06-12 17:26:32 +02:00
|
|
|
|
2021-10-31 19:00:03 +01:00
|
|
|
# src = pkgs.fetchFromGitHub {
|
|
|
|
# owner = "lopsided98";
|
2020-12-10 15:24:45 +01:00
|
|
|
# repo = pname;
|
|
|
|
# rev = "8a72696867a9a008c5a79b49a9b029a4fc426720";
|
|
|
|
# sha256 = "1a7lzmjbwx47qhrkjp3hggiwnx172x4axcz0labm9by17zxlsimr";
|
2022-06-12 17:26:32 +02:00
|
|
|
# };
|
|
|
|
|
2021-10-31 19:00:03 +01:00
|
|
|
# propagatedBuildInputs = [ pkgs.octoprint python.pkgs.libgpiod ];
|
2022-06-12 17:26:32 +02:00
|
|
|
# };
|
2021-10-31 19:00:03 +01:00
|
|
|
# #in p: [ octoprint-filament-sensor-universal ];
|
2020-12-10 15:24:45 +01:00
|
|
|
# in p: [];
|
2022-06-12 17:26:32 +02:00
|
|
|
};
|
2020-06-19 19:05:46 +02:00
|
|
|
|
2021-02-25 17:32:24 +01:00
|
|
|
udev.extraRules = ''
|
|
|
|
KERNEL=="gpiochip*", GROUP="gpio", MODE="0660"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-08-21 22:28:26 +02:00
|
|
|
system.stateVersion = "21.05";
|
2020-06-19 19:05:46 +02:00
|
|
|
}
|