-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
170 lines (143 loc) · 5.5 KB
/
Copy pathflake.nix
File metadata and controls
170 lines (143 loc) · 5.5 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
description = "OpenCode Desktop - AI-powered coding agent";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs, ... }:
let
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forEachSystem = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
version = "1.17.4";
in {
packages = forEachSystem (pkgs:
let
inherit (pkgs) stdenv lib fetchurl dpkg;
inherit (pkgs.buildPackages) buildFHSEnv;
platformInfo = {
x86_64-linux = {
asset = "opencode-desktop-linux-amd64.deb";
hash = "sha256-tfOUHvbQS2xtQ6+tApJWA8GIUp2w7URdcNVlLeuYw8E=";
};
aarch64-linux = {
asset = "opencode-desktop-linux-arm64.deb";
hash = "sha256-XIkQgd1iLOD+lhxdT8NXQ9erV/frxIRndwhYjLD+Pns=";
};
aarch64-darwin = {
asset = "opencode-desktop-mac-arm64.app.tar.gz";
hash = "sha256-He2TWRtKZ+aXVcg/iKvcU2VuTc79mjjVTtiB0MPxxC0=";
};
x86_64-darwin = {
asset = "opencode-desktop-mac-x64.app.tar.gz";
hash = "sha256-yv7kcGB35vCyuN+vnRirExxUiGiAJxzn0JjIc1Q9UM0=";
};
};
info = platformInfo.${pkgs.stdenv.hostPlatform.system} or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}");
# Unwrapped binary package
opencode-desktop-unwrapped = stdenv.mkDerivation {
pname = "opencode-desktop-unwrapped";
inherit version;
src = fetchurl {
url = "https://github.com/anomalyco/opencode/releases/download/v${version}/${info.asset}";
hash = info.hash;
};
nativeBuildInputs = [ dpkg ];
dontBuild = true;
dontFixup = true;
unpackPhase = lib.optionalString stdenv.isLinux ''
dpkg-deb -x $src .
'';
installPhase = lib.optionalString stdenv.isLinux ''
mkdir -p $out
cp -r opt $out/
cp -r usr/* $out/
mkdir -p $out/bin
ln -s $out/opt/OpenCode/ai.opencode.desktop $out/bin/opencode-desktop-unwrapped
'';
};
# FHS environment for running the binary
opencode-desktop-fhs = buildFHSEnv {
name = "opencode-desktop";
targetPkgs = pkgs: with pkgs; [
# Core libraries
glib
gtk3
gtk4
webkitgtk_4_1
glib-networking
gsettings-desktop-schemas
# Graphics
cairo
pango
gdk-pixbuf
librsvg
# X11/XWayland
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxcb
libxkbcommon
libdrm
libgbm
libglvnd
mesa
# Networking/Security
openssl
libsoup_3
dbus
libappindicator
# GStreamer
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
# Accessibility
at-spi2-atk
at-spi2-core
# Misc
alsa-lib
nss
nspr
expat
libuuid
udev
cups
# Fontconfig
fontconfig
freetype
];
extraInstallCommands = ''
mkdir -p $out/share/applications
mkdir -p $out/share/icons/hicolor
# Copy desktop entry
cp ${opencode-desktop-unwrapped}/share/applications/ai.opencode.desktop.desktop $out/share/applications/opencode-desktop.desktop
sed -i 's|Exec=/opt/OpenCode/ai.opencode.desktop %U|Exec=opencode-desktop %U|' $out/share/applications/opencode-desktop.desktop
sed -i 's|Icon=ai.opencode.desktop|Icon=opencode-desktop|' $out/share/applications/opencode-desktop.desktop
# Copy all shipped icon sizes; upstream does not consistently include 32x32.
for icon in ${opencode-desktop-unwrapped}/share/icons/hicolor/*/apps/ai.opencode.desktop.png; do
size=$(basename "$(dirname "$(dirname "$icon")")")
mkdir -p "$out/share/icons/hicolor/$size/apps"
cp "$icon" "$out/share/icons/hicolor/$size/apps/opencode-desktop.png"
done
# Copy metainfo
if [ -d ${opencode-desktop-unwrapped}/share/metainfo ]; then
mkdir -p $out/share/metainfo
cp ${opencode-desktop-unwrapped}/share/metainfo/* $out/share/metainfo/
fi
'';
runScript = "${opencode-desktop-unwrapped}/bin/opencode-desktop-unwrapped";
};
in {
default = opencode-desktop-fhs;
unwrapped = opencode-desktop-unwrapped;
}
);
};
}