about summary refs log blame commit diff stats
path: root/package/package.nix
blob: efadab8cd86d86d3596dd7d319e411786843654c (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                                         
 
         
        

                      
                


               
      
                    
             
                 
                                                   

                     
                                 
                                    





                         




                                                    
                                                                        
                                              
                                                       
                                                                                                              

                 

                            


                     
                 
                               







                                                                             
                                                               
       
# yt - A fully featured command line YouTube client
#
# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of Yt.
#
# 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,
  sqlite,
  blake3,
}: let
  version = "0.1.0";

  src = ./..;

  buildInputs = [
    (python3.withPackages (ps: [ps.yt-dlp blake3]))
    mpv-unwrapped.dev
    ffmpeg
  ];
in
  rustPlatform.buildRustPackage {
    inherit version src buildInputs;
    pname = "yt";

    nativeBuildInputs = [
      makeWrapper
      sqlite
    ];

    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]));

      C_INCLUDE_PATH = "${glibc.dev}/include";
      DATABASE_URL = "sqlite://target/database.sqlite";
      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
    '';

    passthru = {
      inherit blake3;
    };

    cargoLock = {
      lockFile = ../Cargo.lock;
    };

    postBuild = ''
      install -m755 ./python_update/raw_update.py -D "$out/bin/raw_update.py"
      patchShebangs "$out/bin/raw_update.py"
    '';

    postInstall = ''
      wrapProgram $out/bin/yt \
        --prefix PATH : ${lib.makeBinPath buildInputs}:$out/bin
    '';
  }