diff options
Diffstat (limited to '')
-rw-r--r-- | package/package.nix | 141 |
1 files changed, 95 insertions, 46 deletions
diff --git a/package/package.nix b/package/package.nix index c3bc338..5a29fad 100644 --- a/package/package.nix +++ b/package/package.nix @@ -8,68 +8,117 @@ # You should have received a copy of the License along with this program. # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. { - ffmpeg, - glibc, lib, - llvmPackages_latest, - makeWrapper, - mpv-unwrapped, - python3, rustPlatform, + installShellFiles, + # buildInputs + mpv-unwrapped, + python3Packages, + ffmpeg, + openssl, + libffi, + # NativeBuildInputs + makeWrapper, + llvmPackages_latest, + glibc, sqlite, - tree-sitter-yts, fd, -}: let - version = "0.1.0"; + pkg-config, + SDL2, + # Passthru + tree-sitter-yts, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "yt"; + inherit + ((builtins.fromTOML (builtins.readFile + ../Cargo.toml)).workspace.package) + version + ; - src = ./..; + src = lib.cleanSourceWith { + src = lib.cleanSource ./..; + filter = name: type: + (type == "directory") + || (builtins.elem (builtins.baseNameOf name) [ + "Cargo.toml" + "Cargo.lock" + "mkdb.sh" + "help.str" + "raw_error_warning.txt" + ]) + || (lib.strings.hasSuffix ".rs" (builtins.baseNameOf name)) + || (lib.strings.hasSuffix ".h" (builtins.baseNameOf name)) + || (lib.strings.hasSuffix ".sql" (builtins.baseNameOf name)); + }; + + nativeBuildInputs = [ + installShellFiles + makeWrapper + sqlite + fd + pkg-config + ]; buildInputs = [ - (python3.withPackages (ps: [ps.yt-dlp])) + python3Packages.yt-dlp mpv-unwrapped.dev ffmpeg + openssl + libffi ]; -in - rustPlatform.buildRustPackage { - inherit version src buildInputs; - pname = "yt"; - nativeBuildInputs = [ - makeWrapper - sqlite - fd - ]; + checkInputs = [ + # Needed for the tests in `libmpv2` + SDL2 + ]; - env = let - clang_version = - lib.versions.major - llvmPackages_latest.clang-unwrapped.version; - in { - FFMPEG_LOCATION = "${lib.getExe ffmpeg}"; - PYO3_PYTHON = lib.getExe (python3.withPackages (ps: [ps.yt-dlp])); + env = let + clang_version = + lib.versions.major + llvmPackages_latest.clang-unwrapped.version; + in { + # Needed for the compile time sqlite checks. + DATABASE_URL = "sqlite://database.sqlx"; - C_INCLUDE_PATH = "${glibc.dev}/include"; - DATABASE_URL = "sqlite://target/database.sqlx"; - LIBCLANG_INCLUDE_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/clang/${clang_version}/include"; - LIBCLANG_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so"; - }; + # Required by yt_dlp + FFMPEG_LOCATION = "${lib.getExe ffmpeg}"; - doCheck = false; + # Needed for the libmpv2. + C_INCLUDE_PATH = "${glibc.dev}/include"; + LIBCLANG_INCLUDE_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/clang/${clang_version}/include"; + LIBCLANG_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so"; + }; - prePatch = '' - bash ./scripts/mkdb.sh - ''; + doCheck = true; - passthru = { - inherit tree-sitter-yts; - }; + prePatch = '' + # Generate the sqlite db, so that we can run the comp-time sqlite checks. + bash ./scripts/mkdb.sh + ''; - cargoLock = { - lockFile = ../Cargo.lock; + passthru = { + inherit tree-sitter-yts; + }; + + cargoLock = { + lockFile = ../Cargo.lock; + outputHashes = { + "ruff_python_ast-0.0.0" = "sha256-/CVpNBOBpvQhz7X80nUHC2x7ZxxCJH8O0WAABJKEriA="; + "rustpython-0.4.0" = "sha256-hsWqLRiqA0pUNFkHPwvu+Myh5a3p/VXotkPq5ZexqaQ="; + "rustpython-doc-0.3.0" = "sha256-34ERuLFKzUD9Xmf1zlafe42GLWZfUlw17ejf/NN6yH4="; }; + }; + + postInstall = '' + installShellCompletion --cmd yt \ + --bash <(COMPLETE=bash $out/bin/yt) \ + --fish <(COMPLETE=fish $out/bin/yt) \ + --zsh <(COMPLETE=zsh $out/bin/yt) - postInstall = '' - wrapProgram $out/bin/yt \ - --prefix PATH : ${lib.makeBinPath buildInputs} - ''; - } + # NOTE: We cannot clear the path, because we need access to the $EDITOR. <2025-04-04> + wrapProgram $out/bin/yt \ + --prefix PATH : ${lib.makeBinPath finalAttrs.buildInputs} \ + --set YTDLP_NO_PLUGINS 1 + ''; +}) |