summary refs log tree commit diff
path: root/flake.nix
blob: 1a7ac29938167761cefdae3617cce00b6bd026db (plain)
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
115
116
{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    fenix = {
      url = "github:nix-community/fenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    naersk = {
      url = "github:nix-community/naersk";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs =
    {
      self,
      flake-utils,
      nixpkgs,
      fenix,
      naersk,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        overlay = final: prev: {
          # whisper-cpp = prev.whisper-cpp.override {
          #   vulkanSupport = true;
          # };

          # we use the last version of gtk4 which still has the old GL renderer;
          # the new one is broken on macos
          gtk4 = prev.gtk4.overrideAttrs (finalAttrs: prevAttrs: {
            version = "4.16.12";
            src = final.fetchurl {
              url = "mirror://gnome/sources/gtk/${final.lib.versions.majorMinor finalAttrs.version}/gtk-${finalAttrs.version}.tar.xz";
              hash = "sha256-7zG9vW8ILEQBY0ogyFCwBQyb8lLvHgeXZO6VoqDEyVo=";
            };
          });
          libadwaita = prev.libadwaita.overrideAttrs (finalAttrs: prevAttrs: {
            version = "1.6.3";
            src = final.fetchFromGitLab {
              domain = "gitlab.gnome.org";
              owner = "GNOME";
              repo = "libadwaita";
              rev = finalAttrs.version;
              hash = "sha256-4rYiNI6Oj++iqbPIwe8KvwviGnh93sAZ9wp1cIPZcBA=";
            };
            mesonFlags = [];
          });
        };
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ overlay ];
        };
        fenix' = fenix.packages.${system};
        toolchain = fenix'.stable.withComponents [
          "cargo"
          "clippy"
          "rust-src"
          "rustc"
          "rustfmt"
        ];
        naersk' = naersk.lib.${system}.override {
          cargo = toolchain;
          rustc = toolchain;
        };
        rustPlatform = pkgs.makeRustPlatform {
          cargo = toolchain;
          rustc = toolchain;
        };
      in
      rec {
        defaultPackage = naersk'.buildPackage {
          src = ./.;

          nativeBuildInputs = with pkgs; [
            pkg-config
            rustPlatform.bindgenHook
            wrapGAppsHook4
            glib
          ];

          buildInputs = with pkgs; [
            gtk4
            libadwaita
            gst_all_1.gstreamer
            gst_all_1.gst-plugins-base
            gst_all_1.gst-plugins-good
            gst_all_1.gst-plugins-bad
            gst_all_1.gst-plugins-ugly
            gst_all_1.gst-libav
            #gst_all_1.gst-vaapi
            ffmpeg_8-full.dev
          ];

          postInstall = ''
            install -D -m444 -t $out/share/glib-2.0/schemas data/*.gschema.xml
            glib-compile-schemas $out/share/glib-2.0/schemas
          '';
        };

        devShell = pkgs.mkShell {
          inputsFrom = [ defaultPackage ];
          buildInputs = [
            fenix'.rust-analyzer
            rustPlatform.bindgenHook
          ];

          # this fixes tls-related gstreamer error when playing https streams
          shellHook = ''
            export GIO_MODULE_DIR=${pkgs.glib-networking}/lib/gio/modules/
          '';
        };
      }
    );
}