diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 6e9958a9bb..36accb3b59 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -85,4 +85,6 @@ magicard-cups-driver = pkgs.callPackage ./magicard-cups-driver { }; world-of-goo2 = pkgs.callPackage ./world-of-goo2.nix { }; + srsran5g = pkgs.callPackage ./srsran5g { }; + open5gs = pkgs.callPackage ./open5gs { }; } // (import ./heptapod-runner args) diff --git a/nix/pkgs/open5gs/default.nix b/nix/pkgs/open5gs/default.nix new file mode 100644 index 0000000000..4e1f8bdaca --- /dev/null +++ b/nix/pkgs/open5gs/default.nix @@ -0,0 +1,118 @@ +{ stdenv +, lib +, fetchFromGitHub +, meson +, cmake +, ninja +, pkg-config +, flex +, bison +, lksctp-tools +, talloc +, mongoc +, libyaml +, libmicrohttpd_1_0 +, libgcrypt +, libidn +, gnutls +, openssl +, nghttp2 +, curl + +# webui +, buildNpmPackage +, jq +}: + +let + subprojects = { + prometheus-client-c = fetchFromGitHub { + owner = "open5gs"; + repo = "prometheus-client-c"; + rev = "a58ba25bf87a9b1b7c6be4e6f4c62047d620f402"; # open5gs branch + hash = "sha256-COZV4UeB7YRfpLwloIfc/WdlTP9huwVfXrJWH4jmvB8="; + }; + freeDiameter = fetchFromGitHub { + owner = "open5gs"; + repo = "freeDiameter"; + rev = "20196a265aecb7b1573ceb526bb619e092c1fd3f"; # r1.5.0 + hash = "sha256-0sxzQtKBx313+x3TRsmeswAq90Vk5jNA//rOJcEZJTQ="; + }; + libtins = fetchFromGitHub { + owner = "open5gs"; + repo = "libtins"; + rev = "bf22438172d269e6db70e27246dffd8e1f0b96e3"; # r4.5 + hash = "sha256-BxSBNKI+jwI33lN+vmYCYSDAxsVDXS190byAzq6lB/A="; + }; + usrsctp = fetchFromGitHub { + owner = "sctplab"; + repo = "usrsctp"; + rev = "refs/tags/0.9.5.0"; + hash = "sha256-Sengtkg4UoA03cPy5+dRSr5qKIttWHEKn48udOP8zYI="; + }; + }; + + version = "2.7.2"; + src = fetchFromGitHub { + owner = "open5gs"; + repo = "open5gs"; + rev = "v${version}"; + hash = "sha256-XSDjVW+5l2trrilKMcSfX6QIfh/ijWxjoJg33Bn1DBU="; + }; + + webui = buildNpmPackage { + pname = "open5gs-webui"; + inherit version src; + sourceRoot = "source/webui"; + + nativeBuildInputs = [ jq ]; + postPatch = '' + jq '. * {"bin": {"open5gs-webui": "server/index.js"}}' package.json > package.json.new + mv package.json.new package.json + ''; + postInstall = '' + wrapProgram "$out/bin/open5gs-webui" \ + --chdir "$out/lib/node_modules/open5gs" \ + --set NODE_ENV production + ''; + + npmDepsHash = "sha256-IpqineYa15GBqoPDJ7RpaDsq+MQIIDcdq7yhwmH4Lzo="; + }; +in +stdenv.mkDerivation { + pname = "open5gs"; + inherit version src; + + postPatch = '' + ${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: '' + ln -s "${value}" "subprojects/${name}" + '') subprojects)} + ''; + + nativeBuildInputs = [ + meson + cmake + ninja + pkg-config + flex + bison + ]; + + buildInputs = [ + lksctp-tools + talloc + mongoc + libyaml + libmicrohttpd_1_0 + libgcrypt + libidn + gnutls + openssl + nghttp2 + curl + ]; + + passthru = { + inherit subprojects webui; + }; +} diff --git a/nix/pkgs/srsran5g/default.nix b/nix/pkgs/srsran5g/default.nix new file mode 100644 index 0000000000..e28a5fcd4b --- /dev/null +++ b/nix/pkgs/srsran5g/default.nix @@ -0,0 +1,54 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, ninja +, pkg-config +, fftw +, lksctp-tools +, yaml-cpp +, mbedtls +, gtest +, elfutils +, libbfd +, libdwarf +}: + +stdenv.mkDerivation { + pname = "srsran5g"; + version = "24.04"; + + src = fetchFromGitHub { + owner = "srsran"; + repo = "srsRAN_Project"; + rev = "release_24_04"; + hash = "sha256-ZgOeWpmcqQE7BYgiaVysnRkcJxD4fTCfKSQC5hIGTfk="; + }; + + env.CFLAGS = "-D_SCTP_H"; + env.CXXFLAGS = lib.concatStringsSep " " [ + "-D_SCTP_H" # lksctp and glibc do not agree + + # /build/source/tests/unittests/phy/lower/processors/downlink/lower_phy_downlink_processor_test.cpp:796:75: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare] + # 796 | ASSERT_TRUE(md.tx_start.has_value() && (md.tx_start.value() == std::abs(t_offset))); + # | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ + "-Wno-error=sign-compare" + ]; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + buildInputs = [ + fftw + lksctp-tools + yaml-cpp + mbedtls + gtest + elfutils # libdw + libbfd + libdwarf + ]; +} diff --git a/ops/nixos/nausicaa/default.nix b/ops/nixos/nausicaa/default.nix index e8fd23b320..2c2c75219b 100644 --- a/ops/nixos/nausicaa/default.nix +++ b/ops/nixos/nausicaa/default.nix @@ -16,6 +16,7 @@ in { ../lib/quadv-ca/default.nix ((import ../../../third_party/lanzaboote.nix { }).nixosModules.lanzaboote) ../lib/hackyplayer.nix + ../lib/open5gs.nix ]; boot = lib.mkMerge [{ @@ -155,6 +156,12 @@ in { efibootmgr -n 0003 systemctl reboot '') + + limesuiteWithGui + srsran + ]; + services.udev.packages = with pkgs; [ + limesuiteWithGui ]; # Enable CUPS to print documents. @@ -225,6 +232,8 @@ in { iw obs-studio vulkan-tools + depot.nix.pkgs.world-of-goo2 + yt-dlp ]); }; @@ -315,6 +324,8 @@ in { hostname = "hackyplayer.localhost"; }; + my.services.open5gs.enable = true; + # This value determines the NixOS release with which your system is to be # compatible, in order to avoid breaking some software such as database # servers. You should change this only after NixOS release notes say you