about summary refs log blame commit diff stats
path: root/flake.nix
blob: 36b212cb945148412b3a3469e4321b1a0a81ae11 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16














                                                                         




                                         




                
                













                                                    


                                                                   
      



                                           





                                                       




































                                                                                                                     
# 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:
      with ps; [
        yt-dlp
      ]);

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

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

    yt = pkgs.callPackage ./package.nix {};

    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;
    };

    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 = with pkgs; [
        # rust stuff
        cargo
        clippy
        rustc
        rustfmt
        mold-wrapped

        reuse
        cocogitto

        sqlx-cli
        sqlite-interactive

        python
        jq

        cargo-edit
        cargo-expand
        cargo-flamegraph
      ];
    };
  }));
}