summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 7f503927abec2ca2c18f88718da49ed7af6e7e3a (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
  inputs = {
    nixpkgs = {
      url = "github:NixOS/nixpkgs/nixos-unstable";
    };
  };

  outputs = { self, nixpkgs }: let
    overlays = [
      (self: super: {
        notcurses = super.notcurses.overrideAttrs (oldAttrs: {
          patches = [
            ./subprojects/packagefiles/notcurses/duration_and_ffmpeg_fix.diff
          ];
        });
      })
    ];
    forAllSupportedSystems = function:
      nixpkgs.lib.genAttrs [
        "x86_64-linux"
        "i686-linux"
        "aarch64-linux"
      ] (system:
        function (import nixpkgs {
          inherit system;
          inherit overlays;
        }));
    forAllDevSystems = function:
      nixpkgs.lib.genAttrs [
        "x86_64-linux"
        "i686-linux"
      ] (system:
        function (import nixpkgs {
          inherit system;
          inherit overlays;
        }));
  in rec {
    packages = forAllSupportedSystems (pkgs: {
      default = with pkgs; stdenv.mkDerivation rec {
        name = "mauri";
        version = "0.14";
        src = fetchgit {
          url = "https://git.akon.city/mauri";
          rev = "0864ca575cc60877228ad938efcbd5676de21d69";
          postFetch = ''
            export NIX_SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt

            cd "$out"
            ${lib.getExe meson} subprojects download \
              libalabaster libnaunet stela janus s3tc-dxt-decompression

            cd "$out/subprojects/libalabaster-b5b7657"
            ${lib.getExe meson} subprojects download c89atomic

            cd "$out/subprojects/libnaunet-1e0f603"
            ${lib.getExe meson} subprojects download libev

            cd "$out"

            find subprojects -type d -name .git -prune -execdir rm -r {} +
          '';
          sha256 = "su8G30rcoI1yqPe5AbfYPgPBCsyweZjf2D2uCiB/dyc=";
        };
        window = "wayland";
        audio = false;
        nativeBuildInputs = [
          git
          gcc
          pkg-config
          ninja
          meson
          cmake
          wayland-scanner.bin
          makeWrapper
        ];
        buildInputs = [
          lz4
          stb
          libGL
          glm
          nlohmann_json
          jansson
          notcurses
        ] ++ lib.optionals audio [
          fftw
        ] ++ lib.optionals (window == "wayland") [
          wayland
          wayland-protocols
          wlr-protocols
          egl-wayland
        ] ++ lib.optionals (window == "x11") [
          xorg.libX11
          xorg.libXext
          xorg.libXrandr
          xorg.libXfixes
          xorg.libXcursor
          libxkbcommon
        ] ++ lib.optionals (window == "glfw") [
          glfw3
        ];
        mesonFlags = [
          "-Dwindow=${window}"
        ] ++ lib.optionals audio [
          "-Daudio=enabled"
        ];
        fixupPhase = ''
          wrapProgram $out/bin/mauri --set __EGL_VENDOR_LIBRARY_DIRS "${pkgs.mesa}/share/glvnd/egl_vendor.d:${pkgs.linuxPackages.nvidia_x11}/share/glvnd/egl_vendor.d"
          wrapProgram $out/bin/taro --prefix LD_LIBRARY_PATH : "$out/lib64"
        '';
        meta = with lib; {
          homepage = "https://git.akon.city/mauri";
          description = "";
          changelog = "";
          license = [ licenses.gpl3Only ];
          maintainers = [];
        };
      };
    });

    devShells = forAllDevSystems (pkgs: {
      default = with pkgs; mkShell {
        NIX_HARDENING_ENABLE = "";
        nativeBuildInputs = packages.${stdenv.hostPlatform.system}.default.nativeBuildInputs ++ [
          gdb
          clang-tools
          perf-tools
          valgrind
          asciidoctor
          (python3.withPackages (python-pkgs: [
            python-pkgs.pygments
          ]))
        ];
        buildInputs = packages.${stdenv.hostPlatform.system}.default.buildInputs ++ [
          # sway build
          json_c
          pcre2
          libxkbcommon
          cairo
          pango
          libevdev
          libinput
          libdrm
          gdk-pixbuf
          xwayland
          libxcb-wm
          # wlroots build
          mesa
          vulkan-headers
          vulkan-loader
          glslang
          seatd
          libdisplay-info
          libliftoff
          hwdata
          # notcurses build
          libdeflate
          libunistring
          ncurses
          ffmpeg-headless
        ];
        shellHook = ''
          export SHELL="${pkgs.bashInteractive}/bin/bash"
          export __EGL_VENDOR_LIBRARY_DIRS="${pkgs.mesa}/share/glvnd/egl_vendor.d:$__EGL_VENDOR_LIBRARY_DIRS"
          export NIX_BUILD_SHELL=$SHELL
          export NIX_SHELL="mauri"
          export PS1="(\$NIX_SHELL)"$PS1
          echo -en '\033]2;'nix-shell: $NIX_SHELL'\007'
        '';
      };

      mingw64 = with pkgs; let
        gcc = pkgsCross.ucrt64.buildPackages.wrapCC
          (pkgsCross.ucrt64.buildPackages.gcc-unwrapped.override ({
            threadsCross = { model = "win32"; package = null; };
          }));
        gccWin32Stdenv = overrideCC pkgsCross.ucrt64.stdenv gcc;
      in mkShell.override { stdenv = gccWin32Stdenv; } {
        NIX_HARDENING_ENABLE = "";
        nativeBuildInputs = [
          git
          buildPackages.gcc
          gdb
          pkg-config
          ninja
          meson
          cmake
          wineWowPackages.staging
        ];
        buildInputs = with pkgsCross.ucrt64; [
          (zlib.override { shared = false; static = true; })
        ];
        shellHook = ''
          export SHELL="${pkgs.bashInteractive}/bin/bash"
          export NIX_BUILD_SHELL=$SHELL
          export NIX_SHELL="mauri-mingw64"
          export PS1="(\$NIX_SHELL)"$PS1
        '';
      };
    });
  };
}