pulsebert: copy from pipebert

This commit is contained in:
Astro 2021-09-22 21:11:22 +02:00
parent 35098479d1
commit 0fd5119b9d
6 changed files with 322 additions and 0 deletions

View File

@ -23,6 +23,7 @@ rec {
builders = [ "ssh://client@172.22.99.110" ];
wol = true;
};
pipebert.ip4 = "172.22.99.207";
samba = { };
storage-ng.publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMeg5ojU7U8+Lx824y+brazVJ007mEJDM7C7aUruOWGP";

213
hosts/pipebert/default.nix Normal file
View File

@ -0,0 +1,213 @@
# 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, lib, pkgs, ... }:
let
octoprintPort = 8080;
in {
imports = [ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot = {
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = false;
raspberryPi = {
enable = true;
version = 3;
uboot.enable = false;
};
};
#kernelPackages = pkgs.linuxPackages_rpi4;
kernelPackages = pkgs.linuxPackages_latest;
tmpOnTmpfs = true;
};
c3d2 = {
isInHq = true;
mapHqHosts = true;
hq.interface = "eth0";
};
nix = {
buildCores = 4;
maxJobs = 2;
};
networking = {
hostName = "pipebert"; # 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;
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
git
htop
libraspberrypi
mpd
mpv
ncmpcpp
ncpamixer
pulseaudio # required for pactl
vim
wget
];
programs.tmux.enable = true;
# Do not log to flash:
services.journald.extraConfig = ''
Storage=volatile
'';
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
permitRootLogin = "yes";
};
security.sudo = {
enable = true;
wheelNeedsPassword = false;
};
users.users.k-ot = {
isNormalUser = true;
extraGroups = [ "wheel" "audio" ];
};
# Enable sound.
sound.enable = true;
hardware.bluetooth = {
enable = true;
settings = {
Policy.AutoEnable = true;
General = {
Enable = "Source,Sink,Media,Socket";
#DiscoverableTimeout = 0;
#Discoverable = true;
};
};
};
services.pipewire = {
enable = true;
alsa.enable = true;
config.pipewire-pulse = lib.importJSON ./pipewire-pulse.conf.json;
pulse.enable = true;
};
security.rtkit.enable = true;
# tell Avahi to publish CUPS and PulseAudio
services.avahi = {
enable = true;
publish = {
enable = true;
addresses = true;
userServices = true;
};
};
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
};
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;
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;";
};
};
};
};
services.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: [];
};
# Allow access to printer serial port and GPIO
users.users.${config.services.octoprint.user}.extraGroups = [ "dialout" "gpio" ];
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"
'';
# 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 = "21.05"; # Did you read the comment?
}

9
hosts/pipebert/generate.sh Executable file
View File

@ -0,0 +1,9 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p jq
# shellcheck shell=bash
dir=$(dirname "$(readlink -f "$0")")
default_pipewire_pulse=$(nix-instantiate --eval -E '(import <nixos> { }).pkgs.path')/nixos/modules/services/desktops/pipewire/pipewire-pulse.conf.json
jq -s '.[0] * .[1] * .[2]' "$dir/pipewire-pulse.conf.in.json" "$default_pipewire_pulse" > "$dir/pipewire-pulse.conf.json" <(jq -cnS '{ "context.modules": [ inputs."context.modules" ] | add}' "$default_pipewire_pulse" "$dir/pipewire-pulse.conf.in.json")

View File

@ -0,0 +1,37 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
#imports =
# [ (modulesPath + "/installer/scan/not-detected.nix")
# ];
boot.initrd.availableKernelModules = [ "usbhid" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
boot.kernelParams = [ "snd_bcm2835.enable_headphones=1" ];
fileSystems."/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/FIRMWARE";
fsType = "vfat";
};
swapDevices = [ ];
hardware.enableRedistributableFirmware = true;
#networking.wireless.enable = true;
boot.loader.raspberryPi.firmwareConfig = ''
gpu_mem=192
dtparam=audio=on
'';
powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
}

View File

@ -0,0 +1,16 @@
{
"context.modules": [
{
"name": "libpipewire-module-zeroconf-publish"
},
{
"name": "libpipewire-module-protocol-pulse",
"args": {
"server.address": [
"unix:native",
"tcp:4713"
]
}
}
]
}

View File

@ -0,0 +1,46 @@
{
"context.modules": [
{
"args": {},
"flags": [
"ifexists",
"nofail"
],
"name": "libpipewire-module-rtkit"
},
{
"name": "libpipewire-module-protocol-native"
},
{
"name": "libpipewire-module-client-node"
},
{
"name": "libpipewire-module-adapter"
},
{
"name": "libpipewire-module-metadata"
},
{
"args": {
"server.address": [
"unix:native",
"tcp:4713"
],
"vm.overrides": {
"pulse.min.quantum": "1024/48000"
}
},
"name": "libpipewire-module-protocol-pulse"
},
{
"name": "libpipewire-module-zeroconf-publish"
}
],
"context.properties": {},
"context.spa-libs": {
"audio.convert.*": "audioconvert/libspa-audioconvert",
"support.*": "support/libspa-support"
},
"context.exec": [],
"stream.properties": {}
}