forked from github/schildichat-desktop
add back NixOS flake files
This commit is contained in:
parent
eff14caec3
commit
a0c40aa1af
@ -33,6 +33,7 @@
|
|||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.packages.${system}.schildichat-desktop}/bin/schildichat-desktop";
|
program = "${self.packages.${system}.schildichat-desktop}/bin/schildichat-desktop";
|
||||||
};
|
};
|
||||||
|
|
||||||
schildichat-desktop-wayland = {
|
schildichat-desktop-wayland = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${self.packages.${system}.schildichat-desktop-wayland}/bin/schildichat-desktop";
|
program = "${self.packages.${system}.schildichat-desktop-wayland}/bin/schildichat-desktop";
|
||||||
|
20
nix/overlay.nix
Normal file
20
nix/overlay.nix
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
final: prev: {
|
||||||
|
# ignore node_modules and some not needed files
|
||||||
|
cleanSource = src: with final.lib; cleanSourceWith {
|
||||||
|
filter = name: type: cleanSourceFilter name type
|
||||||
|
&& !(hasInfix "/node_modules/" name)
|
||||||
|
&& !(hasInfix "/nix/" name && hasSuffix ".nix" name);
|
||||||
|
|
||||||
|
inherit src;
|
||||||
|
};
|
||||||
|
|
||||||
|
schildichat-web = final.callPackage ./schildichat-web.nix {};
|
||||||
|
schildichat-desktop = final.callPackage ./schildichat-desktop.nix {
|
||||||
|
inherit (final.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
|
||||||
|
};
|
||||||
|
|
||||||
|
schildichat-desktop-wayland = final.callPackage ./schildichat-desktop.nix {
|
||||||
|
inherit (final.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
|
||||||
|
useWayland = true;
|
||||||
|
};
|
||||||
|
}
|
66
nix/schildichat-desktop.nix
Normal file
66
nix/schildichat-desktop.nix
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
lib, stdenv, fetchFromGitHub,
|
||||||
|
makeWrapper, makeDesktopItem, mkYarnPackage,
|
||||||
|
electron, element-desktop, schildichat-web,
|
||||||
|
callPackage, Security, AppKit, CoreServices,
|
||||||
|
useWayland ? false, cleanSource,
|
||||||
|
schildichat-desktop-src ? ../.
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
packageJSON = schildichat-desktop-src + "/element-desktop/package.json";
|
||||||
|
yarnLock = schildichat-desktop-src + "/element-desktop/yarn.lock";
|
||||||
|
version = builtins.fromJSON (builtins.readFile packageJSON).version;
|
||||||
|
electron_exec = if stdenv.isDarwin then "${electron}/Applications/Electron.app/Contents/MacOS/Electron" else "${electron}/bin/electron";
|
||||||
|
in mkYarnPackage {
|
||||||
|
pname = "schildichat-desktop";
|
||||||
|
inherit version packageJSON;
|
||||||
|
src = cleanSource (schildichat-desktop-src + "/element-desktop");
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
inherit (element-desktop) seshat keytar;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export HOME=$(mktemp -d)
|
||||||
|
pushd deps/schildichat-desktop/
|
||||||
|
npx tsc
|
||||||
|
yarn run i18n
|
||||||
|
node ./scripts/copy-res.js
|
||||||
|
popd
|
||||||
|
rm -rf node_modules/matrix-seshat node_modules/keytar
|
||||||
|
ln -s $keytar node_modules/keytar
|
||||||
|
ln -s $seshat node_modules/matrix-seshat
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p "$out/share/element"
|
||||||
|
ln -s '${schildichat-web}' "$out/share/element/webapp"
|
||||||
|
cp -r './deps/schildichat-desktop' "$out/share/element/electron"
|
||||||
|
cp -r './deps/schildichat-desktop/res/img' "$out/share/element"
|
||||||
|
rm "$out/share/element/electron/node_modules"
|
||||||
|
cp -r './node_modules' "$out/share/element/electron"
|
||||||
|
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
|
||||||
|
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
|
||||||
|
|
||||||
|
for icon in $out/share/element/electron/build/icons/*.png; do
|
||||||
|
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
|
||||||
|
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/element.png"
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "$out/share"
|
||||||
|
ln -s "${desktopItem}/share/applications" "$out/share/applications"
|
||||||
|
|
||||||
|
makeWrapper '${electron_exec}' "$out/bin/schildichat-desktop" \
|
||||||
|
--add-flags "$out/share/element/electron${lib.optionalString useWayland " --enable-features=UseOzonePlatform --ozone-platform=wayland"}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
distPhase = "true";
|
||||||
|
desktopItem = makeDesktopItem {
|
||||||
|
name = "schildichat-desktop";
|
||||||
|
exec = "schildichat-desktop %u";
|
||||||
|
icon = "schildichat";
|
||||||
|
desktopName = "SchildiChat";
|
||||||
|
genericName = "Matrix Client";
|
||||||
|
categories = "Network;InstantMessaging;Chat;";
|
||||||
|
extraEntries = "StartupWMClass=schildichat\nMimeType=x-scheme-handler/element;";
|
||||||
|
};
|
||||||
|
}
|
47
nix/schildichat-web.nix
Normal file
47
nix/schildichat-web.nix
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{ stdenv, mkYarnModules, nodejs, cleanSchildichatDesktopSource, schildichat-desktop-src ? ../. }:
|
||||||
|
|
||||||
|
let
|
||||||
|
packageJSON = schildichat-desktop-src + "/element-web/package.json";
|
||||||
|
yarnLock = schildichat-desktop-src + "/element-web/yarn.lock";
|
||||||
|
version = builtins.fromJSON (builtins.readFile packageJSON).version;
|
||||||
|
|
||||||
|
modules = mkYarnModules {
|
||||||
|
name = "schildichat-web-modules-${version}";
|
||||||
|
inherit packageJSON yarnLock;
|
||||||
|
};
|
||||||
|
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
pname = "schildichat-web";
|
||||||
|
inherit version;
|
||||||
|
src = cleanSource schildichat-desktop-src;
|
||||||
|
buildInputs = [ nodejs ];
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
patchShebangs .
|
||||||
|
cp configs/sc/config.json element-web/
|
||||||
|
cp -r ${modules}/node_modules .
|
||||||
|
chmod u+rwX -R node_modules
|
||||||
|
rm -rf node_modules/matrix-react-sdk
|
||||||
|
|
||||||
|
ln -s $PWD/matrix-react-sdk node_modules/
|
||||||
|
ln -s $PWD/node_modules matrix-react-sdk/
|
||||||
|
ln -s $PWD/node_modules element-web/
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
pushd matrix-react-sdk
|
||||||
|
node_modules/.bin/reskindex -h ../element-web/src/header
|
||||||
|
popd
|
||||||
|
pushd element-web
|
||||||
|
node scripts/copy-res.js
|
||||||
|
node_modules/.bin/reskindex -h src/header
|
||||||
|
node_modules/.bin/webpack --progress --mode production
|
||||||
|
popd
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp -r element-web/webapp $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.modules = modules;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user