nix-config/hosts/pulsebert/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

221 lines
6.3 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
{
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 = {
isInHq = true;
mergeHostsFile = true;
2022-09-04 13:13:59 +02: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-09-04 13:13:59 +02:00
growPartition = true;
# kernelPackages = pkgs.linuxKernel.packages.linux_5_15;
kernelParams = [ "console=tty0" ];
2022-09-12 22:24:11 +02:00
loader.grub.enable = false;
2022-08-24 00:32:00 +02:00
loader.efi.canTouchEfiVariables = true;
2022-09-04 13:13:59 +02:00
supportedFilesystems = lib.mkForce [ "vfat" "ext4" ];
2021-09-07 21:13:41 +02:00
tmpOnTmpfs = true;
};
2022-06-12 17:26:32 +02:00
hardware = {
2022-09-12 22:24:11 +02:00
bluetooth.enable = true;
2022-09-04 13:13:59 +02:00
deviceTree = {
enable = true;
kernelPackage = config.boot.kernelPackages.kernel;
};
enableRedistributableFirmware = true;
};
2021-09-07 21:13:41 +02:00
nix = {
2022-09-25 19:47:58 +02:00
settings = {
cores = 2;
max-jobs = 1;
};
2021-09-07 21:13:41 +02:00
};
2020-06-19 19:05:46 +02:00
2022-09-04 13:13:59 +02:00
nixpkgs.config.packageOverrides = pkgs: {
makeModulesClosure = x:
# prevent kernel install fail due to missing modules
pkgs.makeModulesClosure (x // { allowMissing = true; });
};
2021-09-07 21:13:41 +02:00
networking = {
firewall = {
allowedTCPPorts = [
2022-12-18 23:47:42 +01:00
# nginx
80 443
# pulseaudio/pipewire network sync
4713
# llmnr
5355
];
allowedUDPPorts = [
2022-12-18 23:47:42 +01:00
# mdns
5353
# llmnr
5355
];
};
hostName = "pulsebert";
2021-09-07 21:13:41 +02:00
useDHCP = false;
interfaces = {
2022-09-04 13:13:59 +02:00
eth0.useDHCP = true;
};
2021-09-07 21:13:41 +02:00
};
2020-06-19 19:05:46 +02:00
environment.systemPackages = with pkgs; [
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
2022-09-04 13:13:59 +02:00
# https://github.com/dump-dvb/nix-config/blob/310ceedca5ab2d5c22070bd73c603926b6100a74/hardware/configuration-rpi-3b.nix#L16
sdImage = lib.mkForce {
populateFirmwareCommands = let
configTxt = pkgs.writeText "config.txt" ''
[pi3]
kernel=u-boot-rpi3.bin
hdmi_force_hotplug=1
[pi02]
kernel=u-boot-rpi3.bin
[pi4]
kernel=u-boot-rpi4.bin
enable_gic=1
armstub=armstub8-gic.bin
# Otherwise the resolution will be weird in most cases, compared to
# what the pi3 firmware does by default.
disable_overscan=1
# Supported in newer board revisions
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[all]
# Boot in 64-bit mode.
arm_64bit=1
# U-Boot needs this to work, regardless of whether UART is actually used or not.
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
# a requirement in the future.
enable_uart=1
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# when attempting to show low-voltage or overtemperature warnings.
avoid_warnings=1
'';
in ''
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
# Add the config
cp ${configTxt} firmware/config.txt
# Add pi3 specific files
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
# Add pi4 specific files
cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin
cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-400.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4.dtb firmware/
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-cm4s.dtb firmware/
'';
populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
'';
};
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
};
users.users = lib.mkMerge [
(lib.optionalAttrs config.services.octoprint.enable {
# Allow access to printer serial port and GPIO
"${config.services.octoprint.user}".extraGroups = [ "dialout" ];
})
2022-09-04 13:13:59 +02:00
{ }
];
2022-06-12 17:26:32 +02:00
2020-12-10 17:26:47 +01:00
services = {
2022-09-25 19:24:41 +02:00
# Do not log to flash but also breaks journalctl --user
# 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
nginx = {
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
octoprint = rec {
enable = true;
2022-08-21 22:09:39 +02:00
port = 8080;
2021-02-25 17:50:15 +01:00
extraConfig.webcam = {
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
};
# plugins = let
# python = pkgs.octoprint.python;
2022-06-12 17:26:32 +02: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";
# 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 ];
# in p: [];
2022-06-12 17:26:32 +02:00
};
2021-02-25 17:32:24 +01:00
};
2022-08-24 00:32:00 +02:00
system.stateVersion = "22.11";
2020-06-19 19:05:46 +02:00
}