mirror of
https://github.com/Melorise/cp-nix.git
synced 2026-11-07 14:39:34 +00:00
init
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
{ self }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.programs.clash-party;
|
||||
system = pkgs.stdenv.hostPlatform.system;
|
||||
package = cfg.package.override {
|
||||
commandLineArgs = cfg.extraArgs;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.programs.clash-party = {
|
||||
enable = lib.mkEnableOption "Clash Party";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${system}.clash-party;
|
||||
defaultText = lib.literalExpression "clash-party-flake.packages.${system}.clash-party";
|
||||
description = "Clash Party package to install.";
|
||||
};
|
||||
|
||||
autoStart = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Start Clash Party automatically in graphical sessions.";
|
||||
};
|
||||
|
||||
extraArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "--ozone-platform-hint=auto" ];
|
||||
description = "Additional command-line arguments passed to Electron.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ package ];
|
||||
|
||||
security.wrappers.clash-party-mihomo = {
|
||||
source = lib.getExe package.mihomo;
|
||||
owner = "root";
|
||||
group = "root";
|
||||
capabilities = "cap_net_admin,cap_net_raw,cap_net_bind_service=+ep";
|
||||
};
|
||||
|
||||
environment.etc."xdg/autostart/clash-party.desktop" = lib.mkIf cfg.autoStart {
|
||||
source = "${package}/share/applications/clash-party.desktop";
|
||||
};
|
||||
};
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
{
|
||||
lib,
|
||||
callPackage,
|
||||
stdenv,
|
||||
electron_41,
|
||||
makeWrapper,
|
||||
copyDesktopItems,
|
||||
makeDesktopItem,
|
||||
wrapGAppsHook3,
|
||||
autoPatchelfHook,
|
||||
alsa-lib,
|
||||
at-spi2-core,
|
||||
glib,
|
||||
libGL,
|
||||
libayatana-appindicator,
|
||||
libsecret,
|
||||
libnotify,
|
||||
libXScrnSaver,
|
||||
libXtst,
|
||||
nspr,
|
||||
nss,
|
||||
openssl,
|
||||
udev,
|
||||
src,
|
||||
sysproxySrc,
|
||||
country,
|
||||
geoip,
|
||||
geosite,
|
||||
metadb,
|
||||
asn,
|
||||
subStore,
|
||||
subStoreFrontend,
|
||||
notoFontsColorEmoji,
|
||||
mihomo,
|
||||
commandLineArgs ? [ ],
|
||||
}:
|
||||
|
||||
let
|
||||
sysproxy = callPackage ./sysproxy.nix { inherit sysproxySrc; };
|
||||
|
||||
unwrapped = callPackage ./unwrapped.nix {
|
||||
inherit
|
||||
src
|
||||
sysproxy
|
||||
country
|
||||
geoip
|
||||
geosite
|
||||
metadb
|
||||
asn
|
||||
subStore
|
||||
subStoreFrontend
|
||||
notoFontsColorEmoji
|
||||
mihomo
|
||||
;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "clash-party";
|
||||
version = "2.0.0";
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
makeWrapper
|
||||
wrapGAppsHook3
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
alsa-lib
|
||||
at-spi2-core
|
||||
glib
|
||||
libGL
|
||||
libayatana-appindicator
|
||||
libnotify
|
||||
libsecret
|
||||
libXScrnSaver
|
||||
libXtst
|
||||
nspr
|
||||
nss
|
||||
openssl
|
||||
stdenv.cc.cc.lib
|
||||
udev
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/clash-party
|
||||
cp -r ${unwrapped}/lib/clash-party/resources $out/lib/clash-party/
|
||||
cp -r ${unwrapped}/share $out/
|
||||
chmod -R u+w $out/share
|
||||
|
||||
makeWrapper ${lib.getExe electron_41} $out/bin/clash-party \
|
||||
--inherit-argv0 \
|
||||
--add-flags "$out/lib/clash-party/resources/app.asar" \
|
||||
--add-flags ${lib.escapeShellArg (lib.escapeShellArgs commandLineArgs)} \
|
||||
--set-default ELECTRON_OZONE_PLATFORM_HINT auto
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "clash-party";
|
||||
desktopName = "Clash Party";
|
||||
genericName = "Proxy Client";
|
||||
comment = "A GUI client based on Mihomo";
|
||||
exec = "clash-party %U";
|
||||
icon = "clash-party";
|
||||
startupWMClass = "clash-party";
|
||||
categories = [ "Utility" ];
|
||||
mimeTypes = [
|
||||
"x-scheme-handler/clash"
|
||||
"x-scheme-handler/mihomo"
|
||||
];
|
||||
})
|
||||
];
|
||||
|
||||
passthru = {
|
||||
inherit mihomo sysproxy unwrapped;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Clash Party desktop client built from source";
|
||||
homepage = "https://github.com/mihomo-party-org/clash-party";
|
||||
license = lib.licenses.gpl3Only;
|
||||
mainProgram = "clash-party";
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
})
|
||||
Generated
+1155
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
fetchPnpmDeps,
|
||||
nodejs_22,
|
||||
pnpm_10,
|
||||
pnpmConfigHook,
|
||||
sysproxySrc,
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "clash-party-sysproxy";
|
||||
version = "0.5.1";
|
||||
src = sysproxySrc;
|
||||
|
||||
cargoLock.lockFile = ./sysproxy-Cargo.lock;
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
pname = finalAttrs.pname;
|
||||
version = finalAttrs.version;
|
||||
src = sysproxySrc;
|
||||
pnpm = pnpm_10;
|
||||
fetcherVersion = 4;
|
||||
prePnpmInstall = ''
|
||||
pnpm config set fetch-retries 5
|
||||
pnpm config set fetch-timeout 120000
|
||||
pnpm config set network-concurrency 4
|
||||
'';
|
||||
hash = "sha256-n/unBCkpSSShYliEeeWOAjM7r7ZUdfROBYyqzw8JLB0=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs_22
|
||||
pnpmConfigHook
|
||||
pnpm_10
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
rm -f .cargo/config.toml
|
||||
cp ${./sysproxy-Cargo.lock} Cargo.lock
|
||||
chmod u+w Cargo.lock
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
pnpm exec napi build --platform --release
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# N-API symbols are supplied by Node/Electron when the module is loaded, so
|
||||
# Cargo's standalone test-link step cannot resolve them.
|
||||
doCheck = false;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out
|
||||
cp sysproxy.*.node $out/
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
@@ -0,0 +1,139 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
autoPatchelfHook,
|
||||
electron_41,
|
||||
fetchPnpmDeps,
|
||||
nodejs_22,
|
||||
pnpm_10,
|
||||
pnpmConfigHook,
|
||||
alsa-lib,
|
||||
at-spi2-core,
|
||||
glib,
|
||||
libGL,
|
||||
libayatana-appindicator,
|
||||
libnotify,
|
||||
libsecret,
|
||||
libXScrnSaver,
|
||||
libXtst,
|
||||
nspr,
|
||||
nss,
|
||||
openssl,
|
||||
pkg-config,
|
||||
udev,
|
||||
src,
|
||||
sysproxy,
|
||||
country,
|
||||
geoip,
|
||||
geosite,
|
||||
metadb,
|
||||
asn,
|
||||
subStore,
|
||||
subStoreFrontend,
|
||||
notoFontsColorEmoji,
|
||||
mihomo,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "clash-party-unwrapped";
|
||||
version = "2.0.0";
|
||||
inherit src;
|
||||
|
||||
patches = [
|
||||
../patches/branding.patch
|
||||
../patches/disable-updater.patch
|
||||
../patches/stable-core-only.patch
|
||||
../patches/nix-tun-wrapper.patch
|
||||
../patches/system-electron-resources.patch
|
||||
];
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
pname = finalAttrs.pname;
|
||||
version = finalAttrs.version;
|
||||
inherit src;
|
||||
pnpm = pnpm_10;
|
||||
fetcherVersion = 4;
|
||||
prePnpmInstall = ''
|
||||
pnpm config set fetch-retries 5
|
||||
pnpm config set fetch-timeout 120000
|
||||
pnpm config set network-concurrency 4
|
||||
'';
|
||||
hash = "sha256-plsb9TjmprG5k2kYkqItEunTeyJWopRBH0SzzU/qM/8=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
nodejs_22
|
||||
pkg-config
|
||||
pnpmConfigHook
|
||||
pnpm_10
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
alsa-lib
|
||||
at-spi2-core
|
||||
glib
|
||||
libGL
|
||||
libayatana-appindicator
|
||||
libnotify
|
||||
libsecret
|
||||
libXScrnSaver
|
||||
libXtst
|
||||
nspr
|
||||
nss
|
||||
openssl
|
||||
stdenv.cc.cc.lib
|
||||
udev
|
||||
];
|
||||
|
||||
env = {
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||
npm_config_build_from_source = "true";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p extra/sidecar extra/files
|
||||
ln -s ${mihomo}/bin/mihomo extra/sidecar/mihomo
|
||||
cp ${sysproxy}/sysproxy.linux-${if stdenv.hostPlatform.isx86_64 then "x64" else "arm64"}-gnu.node \
|
||||
extra/sidecar/
|
||||
|
||||
install -Dm444 ${country} extra/files/country.mmdb
|
||||
install -Dm444 ${geoip} extra/files/geoip.dat
|
||||
install -Dm444 ${geosite} extra/files/geosite.dat
|
||||
install -Dm444 ${metadb} extra/files/geoip.metadb
|
||||
install -Dm444 ${asn} extra/files/ASN.mmdb
|
||||
install -Dm444 ${subStore}/share/sub-store/sub-store.bundle.js \
|
||||
extra/files/sub-store.bundle.cjs
|
||||
cp -r ${subStoreFrontend} extra/files/sub-store-frontend
|
||||
find ${notoFontsColorEmoji} -name NotoColorEmoji.ttf -exec \
|
||||
install -Dm444 {} src/renderer/src/assets/NotoColorEmoji.ttf \;
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir .electron-dist
|
||||
cp -RL ${electron_41.dist}/. .electron-dist/
|
||||
chmod -R u+w .electron-dist
|
||||
|
||||
node_modules/.bin/electron-vite build
|
||||
npm_config_nodedir=${electron_41.headers} \
|
||||
node_modules/.bin/electron-builder --dir \
|
||||
--config=electron-builder.yml \
|
||||
--config.electronDist=$PWD/.electron-dist \
|
||||
--config.electronVersion=${electron_41.version}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/clash-party
|
||||
cp -r dist/linux-unpacked/resources $out/lib/clash-party/
|
||||
install -Dm644 build/icon.png $out/share/icons/hicolor/512x512/apps/clash-party.png
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user