about summary refs log tree commit diff stats
path: root/flake.nix
blob: abac2320f2fc2e72e2f2978ae96850dc7f38c88f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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>.
{
  description = "yt";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    flake-utils.url = "github:numtide/flake-utils";
    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
    treefmt-nix,
  }: (flake-utils.lib.eachDefaultSystem (system: let
    pkgs = nixpkgs.legacyPackages."${system}";

    python = pkgs.python3.withPackages (ps: [
      ps.yt-dlp
      blake3
    ]);

    buildInputs = with pkgs; [
      mpv-unwrapped.dev
    ];

    nativeBuildInputs = with pkgs; [
      llvmPackages_latest.clang-unwrapped.lib

      # Needed for the tests in `libmpv2`
      SDL2
    ];

    yt = pkgs.callPackage ./package/package.nix {inherit blake3 tree-sitter-yts;};
    blake3 = pkgs.callPackage ./package/blake3/blake3.nix {};
    tree-sitter-yts = pkgs.callPackage ./tree-sitter-yts/package.nix {};

    treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
  in {
    packages = {
      inherit yt blake3 tree-sitter-yts;
      default = self.packages.${system}.yt;
    };

    checks = {
      inherit yt;
      formatting = treefmtEval.config.build.check self;
    };

    formatter = treefmtEval.config.build.wrapper;

    devShells.default = pkgs.mkShell {
      env = let
        clang_version =
          pkgs.lib.versions.major
          pkgs.llvmPackages_latest.clang-unwrapped.version;
      in {
        FFMPEG_LOCATION = "${pkgs.lib.getExe pkgs.ffmpeg}";
        LIBCLANG_PATH = "${pkgs.llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so";
        LIBCLANG_INCLUDE_PATH = "${pkgs.llvmPackages_latest.clang-unwrapped.lib}/lib/clang/${clang_version}/include";
        C_INCLUDE_PATH = "${pkgs.glibc.dev}/include";
      };

      inherit buildInputs nativeBuildInputs;

      packages = [
        # rust stuff
        pkgs.cargo
        pkgs.clippy
        pkgs.rustc
        pkgs.rustfmt
        pkgs.mold-wrapped

        pkgs.cargo-edit
        pkgs.cargo-expand
        pkgs.cargo-flamegraph

        # Releng
        pkgs.reuse
        pkgs.cocogitto

        # Perf
        pkgs.hyperfine

        # Sqlite
        pkgs.sqlx-cli
        pkgs.sqlite-interactive

        # yt_dlp
        python
        pkgs.jq

        # Tree-sitter
        pkgs.nodejs
        pkgs.tree-sitter
      ];
    };
  }));
}