forked from generalaction/emdash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
170 lines (146 loc) · 5.39 KB
/
flake.nix
File metadata and controls
170 lines (146 loc) · 5.39 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 = "Nix dev shell for the Emdash Electron workspace";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
nodejs = pkgs.nodejs_22;
pnpm = pkgs.pnpm_10 or pkgs.pnpm;
# Electron version must match package.json
electronVersion = "30.5.1";
# Pre-fetch Electron binary for Linux x64
# electron-builder expects zips named: electron-v${version}-linux-x64.zip
electronLinuxZip = pkgs.fetchurl {
url = "https://github.com/electron/electron/releases/download/v${electronVersion}/electron-v${electronVersion}-linux-x64.zip";
sha256 = "sha256-7EcHeD056GAF9CiZ4wrlnlDdXZx/KFMe1JTrQ/I2FAM=";
};
# Create a directory with the electron zip for electronDist
electronDistDir = pkgs.runCommand "electron-dist" {} ''
mkdir -p $out
cp ${electronLinuxZip} $out/electron-v${electronVersion}-linux-x64.zip
'';
sharedEnv =
[
nodejs
pkgs.git
pkgs.python3
pkgs.pkg-config
pkgs.openssl
pkgs.libtool
pkgs.autoconf
pkgs.automake
pkgs.coreutils
]
++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
]
++ lib.optionals pkgs.stdenv.isLinux [
pkgs.libsecret
pkgs.sqlite
pkgs.zlib
pkgs.libutempter
pkgs.patchelf
];
cleanSrc = lib.cleanSource ./.;
emdashPackage =
if pkgs.stdenv.isLinux then
pkgs.stdenv.mkDerivation rec {
pname = "emdash";
version = "0.3.34";
src = cleanSrc;
pnpmDeps = pnpm.fetchDeps {
inherit pname version src;
hash = "sha256-9NDjQ8L1thkaoSvWm6s9Q9ubT9+oPpWfLDPAnvKsq7A=";
};
dontConfigure = true;
nativeBuildInputs =
sharedEnv
++ [
pnpm.configHook
pkgs.dpkg
pkgs.rpm
];
buildInputs = [
pkgs.libsecret
pkgs.sqlite
pkgs.zlib
pkgs.libutempter
];
env = {
HOME = "$TMPDIR/emdash-home";
npm_config_build_from_source = "true";
# Skip Electron binary download during pnpm install
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
};
buildPhase = ''
runHook preBuild
mkdir -p "$TMPDIR/emdash-home"
# Build the app (renderer + main)
pnpm run build
# Run electron-builder with electronDist override to avoid download
# Use --dir to only produce unpacked output (no AppImage/deb which require network)
pnpm exec electron-builder --linux --dir \
-c.electronDist=${electronDistDir} \
-c.electronVersion=${electronVersion}
runHook postBuild
'';
installPhase = ''
runHook preInstall
# electron-builder outputs to "release" directory (configured in package.json build.directories.output)
distDir="$PWD/release"
unpackedDir="$distDir/linux-unpacked"
if [ ! -d "$unpackedDir" ]; then
echo "Expected linux-unpacked output from electron-builder, got nothing at $unpackedDir" >&2
exit 1
fi
install -d $out/share/emdash
cp -R "$unpackedDir" $out/share/emdash/
if ls "$distDir"/*.AppImage >/dev/null 2>&1; then
for image in "$distDir"/*.AppImage; do
install -Dm755 "$image" "$out/share/emdash/$(basename "$image")"
done
fi
install -d $out/bin
cat <<EOF > $out/bin/emdash
#!${pkgs.bash}/bin/bash
set -euo pipefail
APP_ROOT="$out/share/emdash/linux-unpacked"
exec "\$APP_ROOT/emdash" "\$@"
EOF
chmod +x $out/bin/emdash
runHook postInstall
'';
meta = {
description = "Emdash – multi-agent orchestration desktop app";
homepage = "https://emdash.sh";
license = lib.licenses.mit;
platforms = [ "x86_64-linux" ];
};
}
else
pkgs.writeShellScriptBin "emdash" ''
echo "The packaged Emdash app is currently only available for Linux when using Nix." >&2
exit 1
'';
in {
devShells.default = pkgs.mkShell {
packages = sharedEnv;
shellHook = ''
echo "Emdash dev shell ready"
echo "Node: $(node --version)"
echo "Run 'pnpm run d' for the full dev loop."
'';
};
packages.emdash = emdashPackage;
packages.default = emdashPackage;
apps.default = {
type = "app";
program = "${emdashPackage}/bin/emdash";
};
});
}