about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 13:10:32 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 14:47:37 +0200
commit4907705f19ba5299247c4a16fc0675c6b6f5f016 (patch)
treecf9a5a6ab0209f1567149c686897201694a00828
parentstyle(treewide): Reformat (diff)
downloadyt-4907705f19ba5299247c4a16fc0675c6b6f5f016.tar.gz
yt-4907705f19ba5299247c4a16fc0675c6b6f5f016.zip
build(flake): Add package definition
Diffstat (limited to '')
-rw-r--r--flake.nix5
-rw-r--r--package.nix90
2 files changed, 70 insertions, 25 deletions
diff --git a/flake.nix b/flake.nix
index 2c79390..36b212c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -47,6 +47,11 @@
 
     treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
   in {
+    packages = {
+      inherit yt;
+      default = self.packages.${system}.yt;
+    };
+
     checks = {
       inherit yt;
       formatting = treefmtEval.config.build.check self;
diff --git a/package.nix b/package.nix
index d57477b..ef218a3 100644
--- a/package.nix
+++ b/package.nix
@@ -1,31 +1,71 @@
+# 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>.
 {
   rustPlatform,
   python3,
   makeWrapper,
-  fetchurl,
-}:
-rustPlatform.buildRustPackage (finalAttrs: {
-  pname = "yt";
+  sqlite,
+  lib,
+  ffmpeg,
+  llvmPackages_latest,
+  glibc,
+  mpv-unwrapped,
+}: let
   version = "0.1.0";
 
-  src = fetchurl {
-    url = "https://git.vhack.eu/soispha/clients/yt/${finalAttrs.pname}-${finalAttrs.version}.tar.xz";
-    sha256 = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
-  };
-
-  nativeBuildInputs = [
-    makeWrapper
-    python3.withPackages
-    (ps: [ps.yt-dlp])
-  ];
-
-  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 : $out/bin/
-  '';
-})
+  src = ./.;
+in
+  rustPlatform.buildRustPackage {
+    inherit version src;
+    pname = "yt";
+
+    nativeBuildInputs = [
+      makeWrapper
+      sqlite
+    ];
+
+    buildInputs = [
+      (python3.withPackages (ps: [ps.yt-dlp]))
+      mpv-unwrapped.dev
+    ];
+
+    env = let
+      clang_version =
+        lib.versions.major
+        llvmPackages_latest.clang-unwrapped.version;
+    in {
+      FFMPEG_LOCATION = "${lib.getExe ffmpeg}";
+      LIBCLANG_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so";
+      LIBCLANG_INCLUDE_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/clang/${clang_version}/include";
+      C_INCLUDE_PATH = "${glibc.dev}/include";
+
+      PYO3_PYTHON = lib.getExe (python3.withPackages (ps: [ps.yt-dlp]));
+      DATABASE_URL = "sqlite://target/database.sqlite";
+    };
+
+    prePatch = ''
+      echo "$PATH"
+      bash ./scripts/mkdb.sh
+    '';
+
+    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 : $out/bin/
+    '';
+  }