about summary refs log tree commit diff
path: root/pkgs/by-name/wi/wireguard-ui/package.nix
blob: b046bdc5a3028553abea3b285b3d49db5321fca4 (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
{
  buildGoModule,
  lib,
  fetchFromGitHub,
  fetchYarnDeps,
  yarn,
  fixup-yarn-lock,
  nodejs,
  fetchpatch2,
}:

buildGoModule rec {
  pname = "wireguard-ui";
  version = "0.6.2";

  src = fetchFromGitHub {
    owner = "ngoduykhanh";
    repo = "wireguard-ui";
    rev = "refs/tags/v${version}";
    hash = "sha256-fK7l9I2s0zSxG1g1oQ1KjJZUcypwS9DxnNN7lhVI+1s=";
  };

  patches = [
    (fetchpatch2 {
      url = "https://github.com/ngoduykhanh/wireguard-ui/commit/2fdafd34ca6c8f7f1415a3a1d89498bb575a7171.patch?full_index=1";
      hash = "sha256-nq/TX+TKDB29NcPQ3pLWD0jcXubULuwqisn9IcEW8B8=";
    })
  ];

  offlineCache = fetchYarnDeps {
    yarnLock = "${src}/yarn.lock";
    hash = "sha256-ps/GtdtDKA3y5o1GZpRG+z08lSzk8d9zgxb95kjr/gc=";
  };

  vendorHash = "sha256-FTjZ6wf0ym6kFJ58Z3E3shmbq9SaMwlXWeueHQXwkX4=";

  nativeBuildInputs = [
    yarn
    fixup-yarn-lock
    nodejs
  ];

  ldflags = [
    "-X main.appVersion=v${version}"
  ];

  preConfigure = ''
    # This is what prepare_assets.sh do.
    export HOME=$(mktemp -d)
    yarn config --offline set yarn-offline-mirror "$offlineCache"
    fixup-yarn-lock yarn.lock
    yarn --offline install

    mkdir -p "./assets/dist/js" "./assets/dist/css" && \
    cp -r "./node_modules/admin-lte/dist/js/adminlte.min.js" "./assets/dist/js/adminlte.min.js" && \
    cp -r "./node_modules/admin-lte/dist/css/adminlte.min.css" "./assets/dist/css/adminlte.min.css"

    cp -r "./custom" "./assets"

    mkdir -p "./assets/plugins" && \
    cp -r "./node_modules/admin-lte/plugins/jquery" \
    "./node_modules/admin-lte/plugins/fontawesome-free" \
    "./node_modules/admin-lte/plugins/bootstrap" \
    "./node_modules/admin-lte/plugins/icheck-bootstrap" \
    "./node_modules/admin-lte/plugins/toastr" \
    "./node_modules/admin-lte/plugins/jquery-validation" \
    "./node_modules/admin-lte/plugins/select2" \
    "./node_modules/jquery-tags-input" \
    "./assets/plugins/"
  '';

  meta = {
    description = "Web user interface to manage your WireGuard setup";
    changelog = "https://github.com/ngoduykhanh/wireguard-ui/releases/tag/v${version}";
    homepage = "https://github.com/ngoduykhanh/wireguard-ui";
    license = lib.licenses.mit;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ bot-wxt1221 ];
    mainProgram = "wireguard-ui";
  };
}