~f4814n/frost

frost/flake.nix -rw-r--r-- 3.3 KiB
ff15c3c0Fabian Geiselhart Add screenshots 2 months ago
                                                                                
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
{
  description = "WIP Matrix client";

  inputs = {
    nixpkgs.url = "nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-windows" ] (system:
      let
        hasSystem = nixpkgs.lib.lists.any (s: s == system);
        pkgs = import nixpkgs {
          system = system;
          config = {
            allowUnfree = true;
            android_sdk.accept_license = true;
          };
          # Fix xcode hash problems
          overlays = [
            (final: prev: let 
              xcode = prev.requireFile {
                name = "Xcode.app";
                hashMode = "recursive";
                sha256 = "1ydwkl8jxhsb5v10ym6zd06bhbzx911281148qnnrsh9hwvrlwgz";
                message = "nop";
              };
            in {
              darwin = prev.darwin // {
                xcode_10_3 = xcode;
                xcode = xcode;
              };
            })
          ];
        };
      in with pkgs; {
        devShell = let
          android = androidenv.composeAndroidPackages{
            platformVersions = [ "28" ];
            abiVersions =  [ "arm64" ];
            includeNDK = true;
            includeEmulator = !hasSystem [ "x86_64-darwin" ];
          };
          in mkShell {
            buildInputs = [
              # nix stuff
              nixfmt

              # go
              go goimports gopls golangci-lint graphviz

              # Library dependencies
              olm
            ] ++ (
              # Only pull xorg and wayland on linux
              if hasSystem [ "x86_64-linux" "aarch64-linux" "i686-linux" ] 
              then [ x11 wayland libxkbcommon libGL xorg.libXcursor xorg.libXfixes ]

              # Only pull android on supported platforms
              else if !hasSystem [ "aarch64-linux" "i686-linux" ] 
              then [ android.androidsdk openjdk ]

              else if !hasSystem [ "aarch64-linux" ]
              then [ delve ]
              else []
            );
          shellHook = ''
            export GOPATH=~/.cache/gopath
            export PATH=$(go env GOPATH)/bin:$PATH

            ${if !hasSystem [ "aarch64-linux" "i686-linux" ]
            then ''
              export PATH=${android.androidsdk}/libexec/android-sdk/build-tools/28.0.3:$PATH
              export ANDROID_SDK_ROOT=${android.androidsdk}/libexec/android-sdk
            ''
            else ""}
          '';
          };

          packages = let
            pname = "frost";
            version = "0.0.0";
            vendorSha256 = "/4dUpvfJJPGYD4bsJGemxE7vpLG1Hj8RIpbR0QfQK3A=";
          in {
            frost = callPackage ./nix/frost.nix { inherit pname version vendorSha256; crypto = true; };

            frost-web = callPackage ./nix/frost-web.nix { inherit pname version vendorSha256; crypto = false; };

            frost-android = callPackage ./nix/frost-android.nix { inherit pname version vendorSha256; crypto = false; };
          };

          defaultPackage = self.packages.${system}.frost;
          apps.frost = flake-utils.lib.mkApp { drv = self.packages.frost; };
          defaultApp = flake-utils.lib.mkApp { drv = self.packages.frost; };
        }
    );
}