From f68d7a7e3a9001d13e27d2a9ca1beb51662f4305 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Fri, 20 Sep 2024 23:07:48 +0500 Subject: [PATCH 1/3] packages.wezterm: own derivation build (incomplete) --- packages/wezterm/default.nix | 108 ++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 8 deletions(-) diff --git a/packages/wezterm/default.nix b/packages/wezterm/default.nix index af4cb3e..985d5b9 100644 --- a/packages/wezterm/default.nix +++ b/packages/wezterm/default.nix @@ -1,16 +1,108 @@ { + bonLib, + craneLib, lib, - weztermPkgs, + pkgs, + version ? "2d0c5cddc91a9c59aef9a7667d90924e7cedd0ac", + hash ? "sha256-ZsDJQSUokodwFMP4FIZm2dYojf5iC4F/EeKC5VuQlqY=", ... -}: -weztermPkgs.default.overrideAttrs (old: { - pname = "wezterm"; +}: let + src = pkgs.fetchFromGitHub { + owner = "wez"; + repo = "wezterm"; + rev = version; + hash = hash; + fetchSubmodules = true; + }; + terminfo = + pkgs.runCommand "wezterm-terminfo" + { + nativeBuildInputs = [pkgs.ncurses]; + } '' + mkdir -p $out/share/terminfo $out/nix-support + tic -x -o $out/share/terminfo ${src}/termwiz/data/wezterm.terminfo + ''; + pkg = { + pname = "wezterm"; + inherit version; - meta = - old.meta - // { + inherit src; + + strictDeps = true; + doCheck = false; + + nativeBuildInputs = with pkgs; [ + installShellFiles + ncurses # tic for terminfo + pkg-config + python3 + ]; + + buildInputs = with pkgs; [ + fontconfig + pkgs.zlib + libxkbcommon + openssl + wayland + cairo + + xorg.libX11 + xorg.libxcb + xorg.xcbutil + xorg.xcbutilimage + xorg.xcbutilkeysyms + xorg.xcbutilwm # contains xcb-ewmh among others + ]; + + libPath = lib.makeLibraryPath (with pkgs; [ + xorg.xcbutilimage + libGL + vulkan-loader + ]); + + postPatch = '' + echo ${version} > .tag + + # tests are failing with: Unable to exchange encryption keys + # rm -r wezterm-ssh/tests + ''; + + preFixup = lib.optionalString pkgs.stdenv.isLinux '' + patchelf \ + --add-needed "${pkgs.libGL}/lib/libEGL.so.1" \ + --add-needed "${pkgs.vulkan-loader}/lib/libvulkan.so.1" \ + $out/bin/wezterm-gui + ''; + + postInstall = '' + mkdir -p $out/nix-support + echo "${terminfo}" >> $out/nix-support/propagated-user-env-packages + + install -Dm644 assets/icon/terminal.png $out/share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png + install -Dm644 assets/wezterm.desktop $out/share/applications/org.wezfurlong.wezterm.desktop + install -Dm644 assets/wezterm.appdata.xml $out/share/metainfo/org.wezfurlong.wezterm.appdata.xml + + install -Dm644 assets/shell-integration/wezterm.sh -t $out/etc/profile.d + installShellCompletion --cmd wezterm \ + --bash assets/shell-completion/bash \ + --fish assets/shell-completion/fish \ + --zsh assets/shell-completion/zsh + + install -Dm644 assets/wezterm-nautilus.py -t $out/share/nautilus-python/extensions + ''; + + meta = with lib; { homepage = "https://github.com/wez/wezterm"; description = "A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust"; license = lib.licenses.mit; + maintainers = with bonLib.maintainers; [L-Nafaryus]; + platforms = platforms.x86_64; + mainProgram = "wezterm"; }; -}) + }; +in let + cargoArtifacts = craneLib.buildDepsOnly pkg; +in + craneLib.buildPackage ( + pkg // {inherit cargoArtifacts;} + ) From 484529aaa23d1ba3351d1ace8a7e2744643e1ee2 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Fri, 20 Sep 2024 23:09:45 +0500 Subject: [PATCH 2/3] catarina: try to split radio service to isolated services (incomplete) --- nixosConfigurations/catarina/default.nix | 2 - nixosConfigurations/catarina/hardware.nix | 6 ++ .../catarina/services/radio.nix | 66 ++++++++++++------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/nixosConfigurations/catarina/default.nix b/nixosConfigurations/catarina/default.nix index 6b1f0cb..94d6406 100644 --- a/nixosConfigurations/catarina/default.nix +++ b/nixosConfigurations/catarina/default.nix @@ -281,8 +281,6 @@ fzf grc - gcc - cachix gnupg diff --git a/nixosConfigurations/catarina/hardware.nix b/nixosConfigurations/catarina/hardware.nix index e2e9147..c3a79da 100644 --- a/nixosConfigurations/catarina/hardware.nix +++ b/nixosConfigurations/catarina/hardware.nix @@ -150,6 +150,12 @@ defaultGateway = "192.168.156.1"; nameservers = ["192.168.156.1" "8.8.8.8"]; + + nat = { + enable = true; + externalInterface = "enp9s0"; + internalInterfaces = ["ve-+"]; + }; }; services.logind.lidSwitchExternalPower = "ignore"; diff --git a/nixosConfigurations/catarina/services/radio.nix b/nixosConfigurations/catarina/services/radio.nix index 53ae3da..52fd00a 100644 --- a/nixosConfigurations/catarina/services/radio.nix +++ b/nixosConfigurations/catarina/services/radio.nix @@ -1,32 +1,52 @@ {config, ...}: { - services.mpd = { - enable = true; - musicDirectory = "/home/l-nafaryus/Music"; - network.listenAddress = "any"; - network.startWhenNeeded = true; - user = "l-nafaryus"; - extraConfig = '' - audio_output { - type "httpd" - name "Radio" - port "6666" - bind_to_address "127.0.0.1" - encoder "lame" - max_clients "0" - website "https://radio.elnafo.ru" - always_on "yes" - tags "yes" - bitrate "128" - format "44100:16:1" - } - ''; + containers.radio-synthwave = { + autoStart = true; + privateNetwork = true; + + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/home/l-nafaryus/Music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "l-nafaryus"; + network.port = 6600; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6660" + bind_to_address "127.0.0.1" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/synthwave" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; + + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6600 6660]; + }; + }; }; services.nginx.virtualHosts."radio.elnafo.ru" = { forceSSL = true; useACMEHost = "elnafo.ru"; - locations."/synthwave".proxyPass = "http://127.0.0.1:6666"; + locations."/synthwave".proxyPass = "http://127.0.0.1:6660"; }; - networking.firewall.allowedTCPPorts = [config.services.mpd.network.port]; + networking.firewall.allowedTCPPorts = [6600]; } From 70f47e2f755fcdddae86437cf56153cd6188d4d5 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Sun, 22 Sep 2024 19:47:46 +0500 Subject: [PATCH 3/3] catarina: split radio services to containers + new radio station --- .../catarina/services/radio.nix | 136 +++++++++++++----- 1 file changed, 98 insertions(+), 38 deletions(-) diff --git a/nixosConfigurations/catarina/services/radio.nix b/nixosConfigurations/catarina/services/radio.nix index 52fd00a..84b0f39 100644 --- a/nixosConfigurations/catarina/services/radio.nix +++ b/nixosConfigurations/catarina/services/radio.nix @@ -1,43 +1,104 @@ {config, ...}: { - containers.radio-synthwave = { - autoStart = true; - privateNetwork = true; + containers = { + radio-synthwave = { + autoStart = true; + privateNetwork = true; + hostAddress = "10.231.136.1"; + localAddress = "10.231.136.2"; - config = { - config, - pkgs, - lib, - ... - }: { - services.mpd = { - enable = true; - musicDirectory = "/home/l-nafaryus/Music"; - network.listenAddress = "any"; - #network.startWhenNeeded = true; - user = "l-nafaryus"; - network.port = 6600; - extraConfig = '' - audio_output { - type "httpd" - name "Radio" - port "6660" - bind_to_address "127.0.0.1" - encoder "lame" - max_clients "0" - website "https://radio.elnafo.ru/synthwave" - always_on "yes" - tags "yes" - bitrate "128" - format "44100:16:1" - } - ''; + bindMounts = { + "/var/lib/music" = { + hostPath = "/home/l-nafaryus/Music"; + isReadOnly = true; + }; }; - system.stateVersion = "24.05"; + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/var/lib/music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "mpd"; + network.port = 6600; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6660" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/synthwave" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; - networking.firewall = { - enable = true; - allowedTCPPorts = [6600 6660]; + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6600 6660]; + }; + }; + }; + + radio-non-stop = { + autoStart = true; + privateNetwork = true; + hostAddress = "10.231.136.1"; + localAddress = "10.231.136.3"; + + bindMounts = { + "/var/lib/music" = { + hostPath = "/home/l-nafaryus/Music"; + isReadOnly = true; + }; + }; + + config = { + config, + pkgs, + lib, + ... + }: { + services.mpd = { + enable = true; + musicDirectory = "/var/lib/music"; + network.listenAddress = "any"; + #network.startWhenNeeded = true; + user = "mpd"; + network.port = 6601; + extraConfig = '' + audio_output { + type "httpd" + name "Radio" + port "6661" + encoder "lame" + max_clients "0" + website "https://radio.elnafo.ru/non-stop" + always_on "yes" + tags "yes" + bitrate "128" + format "44100:16:1" + } + ''; + }; + + system.stateVersion = "24.05"; + + networking.firewall = { + enable = true; + allowedTCPPorts = [6601 6661]; + }; }; }; }; @@ -45,8 +106,7 @@ services.nginx.virtualHosts."radio.elnafo.ru" = { forceSSL = true; useACMEHost = "elnafo.ru"; - locations."/synthwave".proxyPass = "http://127.0.0.1:6660"; + locations."/synthwave".proxyPass = "http://10.231.136.2:6660"; + locations."/non-stop".proxyPass = "http://10.231.136.3:6661"; }; - - networking.firewall.allowedTCPPorts = [6600]; }