From 9dd6c7326a6e924244335381bd813a6e0bb22147 Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Fri, 10 May 2024 12:52:33 -0700 Subject: [PATCH] feat(kasen): openwebrxplus raspi --- .sops.yaml | 1 + overlays/openwebrxplus.nix | 4 + packages/openwebrxplus.nix | 248 +++++++++++++++++++++++++++++++++++++ systems/kasen/default.nix | 16 +++ systems/kasen/nixos.nix | 57 +++++++++ 5 files changed, 326 insertions(+) create mode 100644 overlays/openwebrxplus.nix create mode 100644 packages/openwebrxplus.nix create mode 100644 systems/kasen/default.nix create mode 100644 systems/kasen/nixos.nix diff --git a/.sops.yaml b/.sops.yaml index cb1dbde0..c750e17d 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -15,6 +15,7 @@ keys: - &keycloak_osh age1ktmx2szedfnpe5xumnzs8vkk0ffqgga6ved3drtksg9pye6ndsnsnqq488 - &kuwubernetes_osh age1q2yjpxlqkfhsfxumtmax6zsyt669vlr9ffjks3dpkjf3cqdakcwqt2nt66 - &kuwubernetes_cluster age1nmdv4q8hcyj3s6qevrmc9w2vhd4a8tsj5j5e0cry5utex7vqeprslyjvxz +- &kasen_osh age1fjcafp0j45sz03zq5srnxyq2mujndmn25vceg3wj2cgzymqm73ssmhdgku creation_rules: - path_regex: 'nixos/secrets/.+\.yaml$' shamir_threshold: 1 diff --git a/overlays/openwebrxplus.nix b/overlays/openwebrxplus.nix new file mode 100644 index 00000000..3cf6563c --- /dev/null +++ b/overlays/openwebrxplus.nix @@ -0,0 +1,4 @@ +final: prev: let +in { + openwebrxplus = final.python3Packages.callPackage ../packages/openwebrxplus.nix {}; +} \ No newline at end of file diff --git a/packages/openwebrxplus.nix b/packages/openwebrxplus.nix new file mode 100644 index 00000000..3fdac47f --- /dev/null +++ b/packages/openwebrxplus.nix @@ -0,0 +1,248 @@ +{ stdenv, lib, buildPythonPackage, buildPythonApplication, fetchFromGitHub +, pkg-config, cmake, ninja, setuptools, python +, libsamplerate, fftwFloat +, rtl-sdr, soapysdr-with-plugins, pydigiham, direwolf, sox, wsjtx, codecserver +}: + +let + + js8py = buildPythonPackage rec { + pname = "js8py"; + version = "0.1.1"; + + src = fetchFromGitHub { + owner = "jketterl"; + repo = pname; + rev = version; + sha256 = "1j80zclg1cl5clqd00qqa16prz7cyc32bvxqz2mh540cirygq24w"; + }; + + pythonImportsCheck = [ "js8py" "test" ]; + + meta = with lib; { + homepage = "https://github.com/jketterl/js8py"; + description = "A library to decode the output of the js8 binary of JS8Call"; + license = licenses.gpl3Only; + maintainers = teams.c3d2.members; + }; + }; + +csdr-eti = stdenv.mkDerivation rec { + pname = "csdr-eti"; + version = "0.0.11"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = pname; + rev = version; + hash = "sha256-jft4zi1mLU6zZ+2gsym/3Xu8zkKL0MeoztcyMPM0RYI="; + }; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + propagatedBuildInputs = [ + fftwFloat + libsamplerate + ]; + buildInputs = [ + csdr + ]; + + hardeningDisable = lib.optional stdenv.isAarch64 "format"; + + meta = with lib; { + homepage = "https://github.com/jketterl/csdr"; + description = "A simple DSP library and command-line tool for Software Defined Radio"; + license = licenses.gpl3Only; + platforms = platforms.unix; + broken = stdenv.isDarwin; + maintainers = teams.c3d2.members; + }; +}; + +csdr = stdenv.mkDerivation rec { + pname = "csdr"; + version = "0.18.23"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = pname; + rev = version; + hash = "sha256-Q7g1OqfpAP6u78zyHjLP2ASGYKNKCAVv8cgGwytZ+cE="; + }; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + propagatedBuildInputs = [ + fftwFloat + libsamplerate + ]; + + hardeningDisable = lib.optional stdenv.isAarch64 "format"; + + postFixup = '' + substituteInPlace "$out"/lib/pkgconfig/csdr.pc \ + --replace '=''${prefix}//' '=/' \ + --replace '=''${exec_prefix}//' '=/' + ''; + + meta = with lib; { + homepage = "https://github.com/jketterl/csdr"; + description = "A simple DSP library and command-line tool for Software Defined Radio"; + license = licenses.gpl3Only; + platforms = platforms.unix; + broken = stdenv.isDarwin; + maintainers = teams.c3d2.members; + }; +}; + + +pycsdr-eti = buildPythonPackage rec { + pname = "pycsdr-eti"; + version = "0.0.11"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = "pycsdr-eti"; + rev = version; + hash = "sha256-pjY5sxHvuDTUDxpdhWk8U7ibwxHznyywEqj1btAyXBE="; + }; + + postPatch = '' + substituteInPlace setup.py \ + --replace ', "fftw3"' "" + ''; + + propagatedBuildInputs = [ pycsdr ]; + buildInputs = [ csdr-eti csdr ]; + NIX_CFLAGS_COMPILE = [ + "-I${pycsdr}/include/${python.libPrefix}" + ]; + + # has no tests + doCheck = false; + pythonImportsCheck = [ "csdreti" ]; + + meta = { + homepage = "https://github.com/jketterl/pycsdr"; + description = "bindings for the csdr library"; + license = lib.licenses.gpl3Only; + maintainers = lib.teams.c3d2.members; + }; +}; + +pycsdr = buildPythonPackage rec { + pname = "pycsdr"; + version = "0.18.23"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = "pycsdr"; + rev = version; + hash = "sha256-NjRBC7bhq2bMlRI0Q8bcGcneD/HlAO6l/0As3/lk4e8="; + }; + + buildInputs = [ csdr ]; + + # has no tests + doCheck = false; + pythonImportsCheck = [ "pycsdr" ]; + + meta = { + homepage = "https://github.com/jketterl/pycsdr"; + description = "bindings for the csdr library"; + license = lib.licenses.gpl3Only; + maintainers = lib.teams.c3d2.members; + }; +}; + + owrx_connector = stdenv.mkDerivation rec { + pname = "owrx_connector"; + version = "0.6.5"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = pname; + rev = version; + sha256 = "sha256-e0VEv9t4gVDxJEbDJm1aKSJeqlmhT/QimC3x4JJ6ke8="; + }; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + buildInputs = [ + libsamplerate fftwFloat + csdr + rtl-sdr + soapysdr-with-plugins + ]; + + meta = with lib; { + homepage = "https://github.com/jketterl/owrx_connector"; + description = "A set of connectors that are used by OpenWebRX to interface with SDR hardware"; + license = licenses.gpl3Only; + platforms = platforms.unix; + maintainers = teams.c3d2.members; + }; + }; + +in +buildPythonApplication rec { + pname = "openwebrxplus"; + version = "1.2.49"; + + src = fetchFromGitHub { + owner = "luarvique"; + repo = "openwebrx"; + rev = version; + sha256 = "sha256-QHgt0JGV4E8vOZpY3UwxbtBV38NZBXNrc2asYbHjEqo="; + }; + + nativeBuildInputs = [ + setuptools + ]; + + propagatedBuildInputs = [ + setuptools + pycsdr + pycsdr-eti + pydigiham + js8py +owrx_connector + soapysdr-with-plugins + ]; + + buildInputs = [ + direwolf + sox + wsjtx + codecserver + ]; + + pythonImportsCheck = [ "csdr" "owrx" "test" ]; + + passthru = { + inherit js8py owrx_connector pycsdr csdr; + }; + + meta = with lib; { + homepage = "https://github.com/luarvique/openwebrx"; + description = "A simple DSP library and command-line tool for Software Defined Radio"; + mainProgram = "openwebrx"; + license = licenses.gpl3Only; + maintainers = teams.c3d2.members; + }; +} \ No newline at end of file diff --git a/systems/kasen/default.nix b/systems/kasen/default.nix new file mode 100644 index 00000000..c088828a --- /dev/null +++ b/systems/kasen/default.nix @@ -0,0 +1,16 @@ +_: { + imports = [ + ]; + deploy.hostname = "10.1.1.139"; + arch = "aarch64"; + type = "NixOS"; + modules = [ + ./nixos.nix + ]; + exports = { + services = { + nginx.enable = true; + sshd.enable = true; + }; + }; +} \ No newline at end of file diff --git a/systems/kasen/nixos.nix b/systems/kasen/nixos.nix new file mode 100644 index 00000000..7e6b41d4 --- /dev/null +++ b/systems/kasen/nixos.nix @@ -0,0 +1,57 @@ +{ + meta, + config, + lib, + pkgs, + ... +}: let + inherit (lib.modules) mkForce; + inherit (config.services) nginx; +in { + imports = let + inherit (meta) nixos; + in [ + #nixos.sops + nixos.base + nixos.nginx + ]; + + boot.loader.grub.enable = false; + boot.loader.generic-extlinux-compatible.enable = true; + + networking.interfaces.enu1u1.useDHCP = true; + + hardware.rtl-sdr.enable = true; + + services.openwebrx = { + enable = true; + package = pkgs.openwebrxplus; + }; + systemd.services.openwebrx.serviceConfig = { + DynamicUser = mkForce false; + User = "openwebrx"; + Group = "openwebrx"; + }; + + users.users.openwebrx = { + isSystemUser = true; + group = "openwebrx"; + extraGroups = [ + "plugdev" + ]; + }; + users.groups.openwebrx = {}; + + networking.firewall.allowedTCPPorts = [ + 8073 + ]; + + #sops.defaultSopsFile = ./secrets.yaml; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; + fsType = "ext4"; + }; + + system.stateVersion = "24.05"; +} \ No newline at end of file