treewide: add complete nix package

This commit is contained in:
2026-05-08 12:35:51 -04:00
parent 7d6373e38b
commit afcf5facb0
6 changed files with 190 additions and 16 deletions
+1
View File
@@ -2,3 +2,4 @@
.env .env
.venv .venv
__pycache__ __pycache__
result
+5 -12
View File
@@ -6,11 +6,7 @@
}; };
outputs = outputs =
{ { flake-parts, self, ... }@inputs:
flake-parts,
self,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"aarch64-linux" "aarch64-linux"
@@ -22,20 +18,17 @@
{ {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
name = "errornocord"; name = "errornocord";
buildInputs = [ self'.packages.default ];
buildInputs = with pkgs; [ inputsFrom = [ self'.packages.default ];
ffmpeg
self'.packages.default
];
}; };
packages = rec { packages = rec {
errornocord = pkgs.callPackage ./. { inherit self; }; errornocord = pkgs.callPackage ./nix/package.nix { inherit self; };
default = errornocord; default = errornocord;
}; };
}; };
flake.pins = import ./npins; flake.pins = import ./nix/npins;
}; };
description = "Hot-reloadable Discord music bot"; description = "Hot-reloadable Discord music bot";
+138
View File
@@ -0,0 +1,138 @@
{
cmake,
lib,
ninja,
nlohmann_json,
openssl,
python3Packages,
self,
stdenv,
}:
let
mlspp = stdenv.mkDerivation {
pname = "mlspp";
version = self.pins.mlspp.revision;
src = self.pins.mlspp;
nativeBuildInputs = [
cmake
ninja
];
buildInputs = [
openssl
nlohmann_json
];
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace-fail "-Wextra -Werror -Wmissing-declarations" "-Wextra -Wmissing-declarations"
'';
cmakeFlags = [
"-DDISABLE_GREASE=ON"
"-DMLS_CXX_NAMESPACE=mlspp"
"-DBUILD_TESTING=OFF"
];
meta = {
description = "Cisco MLS C++ library";
homepage = "https://github.com/cisco/mlspp";
license = lib.licenses.bsd2;
platforms = lib.platforms.unix;
};
};
in
python3Packages.buildPythonPackage {
pname = "dave.py";
version = self.pins."dave.py".revision;
pyproject = true;
src = self.pins."dave.py";
build-system = with python3Packages; [
nanobind
scikit-build-core
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail "nanobind~=2.10.2" "nanobind>=2.10.2"
substituteInPlace CMakeLists.txt \
--replace-fail \
'set(VCPKG_MANIFEST_DIR "''${LIBDAVE_SRC_PATH}/vcpkg-alts/''${LIBDAVE_CRYPTO}" CACHE STRING "")' \
'set(VCPKG_MANIFEST_DIR "''${LIBDAVE_SRC_PATH}/vcpkg-alts/''${LIBDAVE_CRYPTO}" CACHE STRING "")
option(DAVE_USE_SYSTEM_DEPS "Use system CMake packages instead of the bundled vcpkg toolchain" OFF)' \
--replace-fail \
'set(_VCPKG_TOOLCHAIN "''${LIBDAVE_SRC_PATH}/vcpkg/scripts/buildsystems/vcpkg.cmake")' \
'if (NOT DAVE_USE_SYSTEM_DEPS)
set(_VCPKG_TOOLCHAIN "''${LIBDAVE_SRC_PATH}/vcpkg/scripts/buildsystems/vcpkg.cmake")' \
--replace-fail \
'message(STATUS "Using vcpkg toolchain ''${CMAKE_TOOLCHAIN_FILE}")' \
'message(STATUS "Using vcpkg toolchain ''${CMAKE_TOOLCHAIN_FILE}")
else()
message(STATUS "Using system dependencies")
endif()'
substituteInPlace scripts/collect_licenses.py \
--replace-fail \
'parser.add_argument("vcpkg_installed_dir", type=Path)' \
'parser.add_argument("--skip-vcpkg-deps", action="store_true")
parser.add_argument("vcpkg_installed_dir", type=Path)' \
--replace-fail \
'vcpkg_deps = [
"mlspp",
"nlohmann-json",
"boringssl" if args.crypto == "boringssl" else "openssl",
]
LICENSE_PATHS.update(
{dep: (args.vcpkg_installed_dir / "share" / dep / "copyright") for dep in vcpkg_deps}
)' \
'if not args.skip_vcpkg_deps:
vcpkg_deps = [
"mlspp",
"nlohmann-json",
"boringssl" if args.crypto == "boringssl" else "openssl",
]
LICENSE_PATHS.update(
{dep: (args.vcpkg_installed_dir / "share" / dep / "copyright") for dep in vcpkg_deps}
)'
substituteInPlace CMakeLists.txt \
--replace-fail \
'COMMAND "''${Python_EXECUTABLE}" "scripts/collect_licenses.py"' \
'COMMAND "''${Python_EXECUTABLE}" "scripts/collect_licenses.py" --skip-vcpkg-deps'
'';
nativeBuildInputs = [
cmake
ninja
];
dontUseCmakeConfigure = true;
buildInputs = [
openssl
nlohmann_json
mlspp
];
dependencies = [ ];
nativeCheckInputs = with python3Packages; [
pytestCheckHook
];
SKBUILD_CMAKE_ARGS = "-DDAVE_USE_SYSTEM_DEPS=ON";
pythonImportsCheck = [ "dave" ];
meta = {
description = "Python bindings for libdave, Discord's audio & video end-to-end encryption";
homepage = "https://github.com/DisnakeDev/dave.py";
changelog = "https://github.com/DisnakeDev/dave.py/blob/main/docs/CHANGELOG.md";
license = lib.licenses.mit;
};
}
@@ -1,5 +1,18 @@
{ {
"pins": { "pins": {
"dave.py": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "DisnakeDev",
"repo": "dave.py"
},
"branch": "main",
"submodules": true,
"revision": "6653dd0f53553ab8af1593eae32f6128f969c8ff",
"url": null,
"hash": "sha256-bfHVl+KHeMEQNBYcmmEcdw8ZNtP2Apxhjix85yqJ+3M="
},
"disnake": { "disnake": {
"type": "Git", "type": "Git",
"repository": { "repository": {
@@ -20,6 +33,19 @@
"version": "1.0.8", "version": "1.0.8",
"url": "https://files.pythonhosted.org/packages/8c/db/3a86b247c7653a3f1676d16a316daf400edcf76295098ab60544f2a8f8b7/disnake_paginator-1.0.8.tar.gz", "url": "https://files.pythonhosted.org/packages/8c/db/3a86b247c7653a3f1676d16a316daf400edcf76295098ab60544f2a8f8b7/disnake_paginator-1.0.8.tar.gz",
"hash": "sha256-Sn0qbKNkJIdX8GCRRRPxwWutBtG9c1Zt7JnQAsl5I4s=" "hash": "sha256-Sn0qbKNkJIdX8GCRRRPxwWutBtG9c1Zt7JnQAsl5I4s="
},
"mlspp": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "cisco",
"repo": "mlspp"
},
"branch": "main",
"submodules": false,
"revision": "92aaa4134fa45ec39957a7c81a342401fba7feb2",
"url": "https://github.com/cisco/mlspp/archive/92aaa4134fa45ec39957a7c81a342401fba7feb2.tar.gz",
"hash": "sha256-HElw0fvL7ClDSXBDYRw1qcPw73oWvbMfi7skQokyftY="
} }
}, },
"version": 7 "version": 7
+20 -4
View File
@@ -1,10 +1,14 @@
{ {
callPackage,
ffmpeg,
lib, lib,
libopus,
python3Packages, python3Packages,
self, self,
...
}: }:
let let
dave_py = callPackage ./dave_py.nix { inherit self; };
disnake = python3Packages.disnake.overrideAttrs (old: { disnake = python3Packages.disnake.overrideAttrs (old: {
src = self.pins.disnake; src = self.pins.disnake;
@@ -12,6 +16,7 @@ let
with python3Packages; with python3Packages;
old.propagatedBuildInputs old.propagatedBuildInputs
++ [ ++ [
dave_py
typing-extensions typing-extensions
versioningit versioningit
]; ];
@@ -39,7 +44,7 @@ python3Packages.buildPythonApplication {
pname = "errornocord"; pname = "errornocord";
version = "0.1.0"; version = "0.1.0";
src = lib.cleanSource ./.; src = lib.cleanSource ../.;
pyproject = true; pyproject = true;
build-system = [ python3Packages.setuptools ]; build-system = [ python3Packages.setuptools ];
@@ -47,13 +52,24 @@ python3Packages.buildPythonApplication {
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = with python3Packages; [
aiohttp aiohttp
audioop-lts audioop-lts
disnake
disnake_paginator
psutil psutil
typing-extensions typing-extensions
youtube-transcript-api youtube-transcript-api
yt-dlp yt-dlp
disnake
disnake_paginator
ffmpeg
libopus
]; ];
doCheck = false; doCheck = false;
meta = {
description = "Hot-reloadable Discord music bot";
homepage = "https://github.com/ErrorNoInternet/ErrorNoCord";
license = lib.licenses.gpl3Only;
mainProgram = "errornocord";
};
} }