flake.nix

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