summaryrefslogtreecommitdiff
path: root/pkgs/flightcore/default.nix
blob: be747a44fd08be5a9035cef7729f55719b57e46a (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
{
  lib,
  rustPlatform,
  fetchFromGitHub,
  fetchNpmDeps,
  npmHooks,
  wrapGAppsHook,
  flightcore,
  cargo-tauri,
  glib,
  glib-networking,
  libsoup,
  nodejs,
  openssl,
  pkg-config,
  webkitgtk,
}:
rustPlatform.buildRustPackage {
  pname = "flightcore";
  version = "2.19.2";

  src = fetchFromGitHub {
    owner = "R2NorthstarTools";
    repo = "FlightCore";
    rev = "v${flightcore.version}";
    hash = "sha256-Gar6qCtnk3eUGhSjRHFx7aclPPaMCL+5CV30pCMsgvA=";
  };

  prePatch = ''
    pushd $npmRoot

    ln -sf ${./package.json} package.json
    ln -sf ${./package-lock.json} package-lock.json
    substituteInPlace $(find -type f -name '*.vue' -or -name '*.ts') \
      --replace "tauri-plugin-store-api" "@tauri-apps/plugin-store"

    popd
  '';

  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "tauri-plugin-store-0.1.0" = "sha256-G7b1cIMr7YcI5cUhlYi4vhLFCe3/CMSPSB4gYY1Ynz8=";
    };
  };
  buildAndTestSubdir = flightcore.cargoRoot;
  cargoRoot = "src-tauri";

  npmDeps = fetchNpmDeps {
    name = "${flightcore.pname}-npm-deps-${flightcore.version}";
    src = ./.;
    hash = "sha256-2X5pZ0T1dR6NCB0qcSvQl0RsMA7KFYKUUI5Z8tQ7ddQ=";
  };

  npmRoot = "src-vue";
  makeCacheWritable = true;

  nativeBuildInputs = [
    cargo-tauri
    nodejs
    npmHooks.npmConfigHook
    pkg-config
    wrapGAppsHook
  ];

  buildInputs = [
    glib
    glib-networking
    libsoup
    openssl
    webkitgtk
  ];

  buildPhase = ''
    runHook preBuild

    cargo tauri build --bundles deb

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    cp -r ${flightcore.cargoRoot}/target/release/bundle/deb/*/data/usr $out

    runHook postInstall
  '';

  meta = with lib; {
    mainProgram = "flight-core";
    description = "A Northstar installer, updater, and mod-manager";
    homepage = "https://github.com/R2NorthstarTools/FlightCore";
    changelog = "https://github.com/R2NorthstarTools/FlightCore/releases/tag/v${flightcore.version}";
    license = licenses.mit;
    maintainers = with maintainers; [getchoo];
  };
}