btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / development / compilers / dart / package-source-builders / super_native_extensions / default.nix
blob6877e75c085950ad2b7821bcedbde2fa430b76fc
2   lib,
3   rustPlatform,
4   pkg-config,
5   at-spi2-atk,
6   gdk-pixbuf,
7   cairo,
8   gtk3,
9   writeText,
10   stdenv,
13 { version, src, ... }:
15 let
16   rustDep = rustPlatform.buildRustPackage {
17     pname = "super_native_extensions-rs";
18     inherit version src;
20     sourceRoot = "${src.name}/rust";
22     cargoLock =
23       rec {
24         _0_8_22 = {
25           lockFile = ./Cargo-0.8.22.lock;
26           outputHashes = {
27             "mime_guess-2.0.4" = "sha256-KSw0YUTGqNEWY9pMvQplUGajJgoP2BRwVX6qZPpB2rI=";
28           };
29         };
30         _0_9_0-dev_3 = _0_8_22;
31         _0_8_24 = _0_8_22;
32         _0_8_21 = _0_8_22;
33         _0_8_20 = _0_8_22;
34         _0_8_19 = _0_8_22;
35         _0_8_18 = _0_8_22;
36         _0_8_17 = _0_8_22;
37       }
38       .${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw ''
39         Unsupported version of pub 'super_native_extensions': '${version}'
40         Please add ${src}/rust/Cargo.lock
41         to this path, and add corresponding entry here. If the lock
42         is the same with existing versions, add an alias here.
43       '');
45     nativeBuildInputs = [ pkg-config ];
47     buildInputs = [
48       at-spi2-atk
49       gdk-pixbuf
50       cairo
51       gtk3
52     ];
54     passthru.libraryPath = "lib/libsuper_native_extensions.so";
55   };
57   fakeCargokitCmake = writeText "FakeCargokit.cmake" ''
58     function(apply_cargokit target manifest_dir lib_name any_symbol_name)
59       target_link_libraries("''${target}" PRIVATE ${rustDep}/${rustDep.passthru.libraryPath})
60       set("''${target}_cargokit_lib" ${rustDep}/${rustDep.passthru.libraryPath} PARENT_SCOPE)
61     endfunction()
62   '';
65 stdenv.mkDerivation {
66   pname = "super_native_extensions";
67   inherit version src;
68   inherit (src) passthru;
70   installPhase = ''
71     runHook preInstall
73     cp -r "$src" "$out"
74     chmod +rwx $out/cargokit/cmake/cargokit.cmake
75     cp ${fakeCargokitCmake} $out/cargokit/cmake/cargokit.cmake
77     runHook postInstall
78   '';