在 NixOS 上安裝新版 Heptabase

Heptabase 更新很快,在 NixOS 上安裝最新版的 Heptabase 最好下載 AppImage 後自己寫 nix 安裝。

假設資料夾結構有:

1
2
3
4
home-common.nix
hosts/
pc/
configuration.nix

下載的 AppImage 放在 root directory。

增加 heptabase.nix

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
{
lib,
appimageTools,
fetchurl,
}:
let
pname = "heptabase";
version = "1.82.4";

src = builtins.path {
path = ./Heptabase-${version}.AppImage;
name = "heptabase";
};

appimageContents = appimageTools.extractType2 { inherit pname version src; };
in
appimageTools.wrapType2 {
inherit pname version src;

extraInstallCommands = ''
install -Dm444 ${appimageContents}/project-meta.desktop -T $out/share/applications/heptabase.desktop
install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/0x0/apps/project-meta.png $out/share/icons/hicolor/512x512/apps/${pname}.png

substituteInPlace $out/share/applications/heptabase.desktop \
--replace-fail 'Exec=AppRun --no-sandbox %U' 'Exec=heptabase %U' \
--replace-fail 'Icon=project-meta' 'Icon=${pname}'

'';

meta = {
changelog = "https://github.com/heptameta/project-meta/releases/tag/v${version}";
description = "Visual note-taking tool for learning complex topics";
homepage = "https://heptabase.com/";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ luftmensch-luftmensch ];
mainProgram = "heptabase";
platforms = [ "x86_64-linux" ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
}

hosts/pc/ 底下增加 overlay.nix

1
2
3
self: super: {
heptabase = super.callPackage ../../heptabase.nix { };
}

configuration.nix 增加 overlays

1
2
3
4
5
6
7
8
9
10
{
config,
pkgs,
...
}:
{
nixpkgs.overlays = [
(import ./overlay.nix)
];
}

Home Manager 安裝 heptabase:

1
2
3
4
5
6
in
{
home.packages = with pkgs; [
heptabase
];
}