about summary refs log tree commit diff
path: root/pkgs/development/compilers/flutter/sdk-symlink.nix
blob: 044a508805f58bb9a82b353b1aec79e38630e6a3 (plain) (blame)
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
{ symlinkJoin
, makeWrapper
}: flutter:

let
  self =
    symlinkJoin {
      name = "${flutter.name}-sdk-links";
      paths = [ flutter flutter.cacheDir flutter.sdk ];

      nativeBuildInputs = [ makeWrapper ];
      postBuild = ''
        wrapProgram "$out/bin/flutter" \
          --set-default FLUTTER_ROOT "$out"

        # symlinkJoin seems to be missing the .git directory for some reason.
        if [ -d '${flutter.sdk}/.git' ]; then
          ln -s '${flutter.sdk}/.git' "$out"
        fi
      '';

      passthru = flutter.passthru // {
        # Update the SDK attribute.
        # This allows any modified SDK files to be included
        # in future invocations.
        sdk = self;
      };

      meta = flutter.meta // {
        longDescription = ''
          ${flutter.meta.longDescription}
          Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK.
        '';
      };
    };
in
self