fix(nix): restore desktop integration (#37197)
Co-authored-by: Test User <test@test.com>
This commit is contained in:
parent
9da9ed9de6
commit
b95fe7b2d7
1 changed files with 49 additions and 23 deletions
|
|
@ -8,6 +8,8 @@
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
writableTmpDirAsHomeHook,
|
writableTmpDirAsHomeHook,
|
||||||
autoPatchelfHook,
|
autoPatchelfHook,
|
||||||
|
copyDesktopItems,
|
||||||
|
makeDesktopItem,
|
||||||
opencode,
|
opencode,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -27,9 +29,12 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
nodejs
|
nodejs
|
||||||
makeWrapper
|
makeWrapper
|
||||||
writableTmpDirAsHomeHook
|
writableTmpDirAsHomeHook
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
]
|
||||||
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||||
autoPatchelfHook
|
autoPatchelfHook
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
copyDesktopItems
|
||||||
|
]
|
||||||
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||||
# Ad-hoc sign the .app: --config.mac.identity=null below skips signing.
|
# Ad-hoc sign the .app: --config.mac.identity=null below skips signing.
|
||||||
darwin.autoSignDarwinBinariesHook
|
darwin.autoSignDarwinBinariesHook
|
||||||
];
|
];
|
||||||
|
|
@ -38,6 +43,16 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
(lib.getLib stdenv.cc.cc)
|
(lib.getLib stdenv.cc.cc)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
desktopItems = lib.optional stdenv.hostPlatform.isLinux (makeDesktopItem {
|
||||||
|
name = "ai.opencode.desktop";
|
||||||
|
desktopName = "OpenCode";
|
||||||
|
exec = "opencode-desktop %U";
|
||||||
|
icon = "ai.opencode.desktop";
|
||||||
|
# Electron 41 derives X11 WM_CLASS from app.name.
|
||||||
|
startupWMClass = "OpenCode";
|
||||||
|
categories = [ "Development" ];
|
||||||
|
});
|
||||||
|
|
||||||
env = opencode.env // {
|
env = opencode.env // {
|
||||||
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||||
};
|
};
|
||||||
|
|
@ -83,8 +98,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase =
|
installPhase = ''
|
||||||
''
|
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
''
|
''
|
||||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||||
|
|
@ -95,6 +109,18 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
+ lib.optionalString stdenv.hostPlatform.isLinux ''
|
+ lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||||
mkdir -p $out/opt/opencode-desktop
|
mkdir -p $out/opt/opencode-desktop
|
||||||
cp -r dist/linux*-unpacked/{resources,LICENSE*} $out/opt/opencode-desktop
|
cp -r dist/linux*-unpacked/{resources,LICENSE*} $out/opt/opencode-desktop
|
||||||
|
install -Dm644 resources/icons/32x32.png \
|
||||||
|
"$out/share/icons/hicolor/32x32/apps/ai.opencode.desktop.png"
|
||||||
|
install -Dm644 resources/icons/64x64.png \
|
||||||
|
"$out/share/icons/hicolor/64x64/apps/ai.opencode.desktop.png"
|
||||||
|
install -Dm644 resources/icons/128x128.png \
|
||||||
|
"$out/share/icons/hicolor/128x128/apps/ai.opencode.desktop.png"
|
||||||
|
install -Dm644 resources/icons/128x128@2x.png \
|
||||||
|
"$out/share/icons/hicolor/256x256/apps/ai.opencode.desktop.png"
|
||||||
|
install -Dm644 resources/icons/icon.png \
|
||||||
|
"$out/share/icons/hicolor/512x512/apps/ai.opencode.desktop.png"
|
||||||
|
install -Dm644 resources/ai.opencode.desktop.metainfo.xml \
|
||||||
|
"$out/share/metainfo/ai.opencode.desktop.metainfo.xml"
|
||||||
makeWrapper ${lib.getExe electron} $out/bin/opencode-desktop \
|
makeWrapper ${lib.getExe electron} $out/bin/opencode-desktop \
|
||||||
--inherit-argv0 \
|
--inherit-argv0 \
|
||||||
--set ELECTRON_FORCE_IS_PACKAGED 1 \
|
--set ELECTRON_FORCE_IS_PACKAGED 1 \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue