about summary refs log tree commit diff
path: root/pkgs/by-name/ga/gancio/package.nix
blob: dc9ce4dd82acf4786094bc502c7be1fd11cd205e (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
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
{
  mkYarnPackage,
  fetchFromGitLab,
  fetchYarnDeps,
  python3,
  pkg-config,
  nodePackages,
  node-gyp,
  vips,
  lib,
  nixosTests,
}:
mkYarnPackage rec {
  inherit (nodePackages) nodejs;
  version = "1.19.0";

  src = fetchFromGitLab {
    domain = "framagit.org";
    owner = "les";
    repo = "gancio";
    rev = "v${version}";
    hash = "sha256-cMUM7jqLsrw57gySiIK7DBZA7lPiXL2HAadMk+7wkzs=";
  };

  offlineCache = fetchYarnDeps {
    yarnLock = src + "/yarn.lock";
    hash = "sha256-ONPvBvT3zf8IVkIEOmiQgcjI7zPCFwDuQfo+fOvDGzM=";
  };

  packageJSON = ./package.json;

  # for pkg-config dependencies:
  yarnPreBuild = ''
    export npm_config_nodedir=${nodePackages.nodejs}
  '';
  # So that sqlite can be found:
  pkgConfig.sqlite3 = {
    nativeBuildInputs = [
      pkg-config
      nodePackages.prebuild-install
      node-gyp
      python3
    ];
    postInstall = ''
      yarn --offline run install
    '';
  };
  # Sharp need to find a vips library
  pkgConfig.sharp = {
    nativeBuildInputs = [
      pkg-config
      python3
      node-gyp
      nodePackages.semver
    ];
    buildInputs = [ vips ];
    postInstall = ''
      yarn --offline run install
    '';
  };

  # build need a writeable node_modules
  configurePhase = ''
    runHook preConfigure

    cp -r $node_modules node_modules
    chmod -R +w node_modules

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    export HOME=$(mktemp -d)
    yarn --offline build
    yarn --offline pack --filename gancio.tgz
    mkdir -p deps/gancio
    tar -C deps/gancio/ --strip-components=1 -xf gancio.tgz
    rm gancio.tgz

    runHook postBuild
  '';

  passthru = {
    updateScript = ./update.sh;
    tests = {
      inherit (nixosTests) gancio;
    };
  };

  meta = {
    description = "Shared agenda for local communities, running on nodejs";
    homepage = "https://gancio.org/";
    changelog = "https://framagit.org/les/gancio/-/raw/master/CHANGELOG.md";
    license = lib.licenses.agpl3Plus;
    platforms = lib.platforms.linux;
    mainProgram = "gancio";
    maintainers = with lib.maintainers; [ jbgi ];
  };
}