flake.nix

52 lines · 1341 bytes

 1{
 2  inputs = {
 3    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
 4    flake-utils.url = "github:numtide/flake-utils";
 5    rust-overlay.url = "github:oxalica/rust-overlay";
 6  };
 7
 8  outputs = {
 9    self,
10    nixpkgs,
11    flake-utils,
12    rust-overlay,
13    ...
14  }:
15    flake-utils.lib.eachDefaultSystem (system: let
16      overlays = [(import rust-overlay)];
17      pkgs = import nixpkgs {inherit system overlays;};
18      rustVersion = pkgs.rust-bin.stable.latest.default;
19      toml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
20
21      rustPlatform = pkgs.makeRustPlatform {
22        cargo = rustVersion;
23        rustc = rustVersion;
24      };
25
26      youtube-tui = rustPlatform.buildRustPackage {
27        pname =
28          toml.package.name; # make this what ever your cargo.toml package.name is
29        version = "v${toml.package.version}";
30        src = ./.; # the folder with the cargo.toml
31
32        cargoLock.lockFile = ./Cargo.lock;
33
34        buildInputs = with pkgs; [
35          openssl
36          xorg.libxcb
37          libsixel
38          mpv
39        ];
40
41        nativeBuildInputs = with pkgs; [
42          pkg-config
43          python3
44        ];
45      };
46    in {
47      defaultPackage = youtube-tui;
48      devShell = pkgs.mkShell {
49        buildInputs = [(rustVersion.override {extensions = ["rust-src"];})];
50      };
51    });
52}