seperate clash-updater
This commit is contained in:
parent
7270a94cde
commit
1c484f8caa
@ -1,6 +1,5 @@
|
||||
{ pkgs, stdenv, fetchurl, version, ... }: with pkgs;
|
||||
|
||||
let
|
||||
{
|
||||
clash-premium = { pkgs, stdenv, fetchurl, version, ... }: with pkgs;let
|
||||
systemTriple = {
|
||||
"x86_64-darwin" = {
|
||||
system = "darwin-amd64";
|
||||
@ -20,8 +19,9 @@ let
|
||||
};
|
||||
};
|
||||
currentTriple = systemTriple."${stdenv.targetPlatform.system}";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "clash-premium";
|
||||
src = fetchurl {
|
||||
url = "https://github.com/Dreamacro/clash/releases/download/premium/clash-${currentTriple.system}-${version}.gz";
|
||||
@ -49,26 +49,6 @@ stdenv.mkDerivation {
|
||||
fi
|
||||
'';
|
||||
|
||||
makeUpdater = { subscription, name }: stdenv.mkDerivation {
|
||||
name = "clash-updater-${name}";
|
||||
src = ./updater.sh;
|
||||
buildInputs = [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontPatchELF = true;
|
||||
dontUnpack = true;
|
||||
|
||||
checkPhase = ''
|
||||
patchShebangs bin
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
makeWrapper $src $out/bin/clash-updater-${name} --set SUBSCRIPTION_URL "${subscription}"
|
||||
'';
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "close-sourced pre-built Clash binary with TUN support and more";
|
||||
@ -80,5 +60,7 @@ stdenv.mkDerivation {
|
||||
"aarch64-linux"
|
||||
];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
clash-updater = import ./updater.nix;
|
||||
}
|
||||
|
20
pkgs/network/proxy/clash-premium/updater.nix
Normal file
20
pkgs/network/proxy/clash-premium/updater.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{ subscription, name }: with import <nixpkgs> {}; stdenv.mkDerivation {
|
||||
name = "clash-updater-${name}";
|
||||
src = ./updater.sh;
|
||||
buildInputs = [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontPatchELF = true;
|
||||
dontUnpack = true;
|
||||
|
||||
checkPhase = ''
|
||||
patchShebangs bin
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
makeWrapper $src $out/bin/clash-updater --set SUBSCRIPTION_URL "${subscription}"
|
||||
'';
|
||||
}
|
@ -3,6 +3,24 @@
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
env
|
||||
TEMP=${TEMP:-$(mktemp /tmp/clash-config-XXXXXX)}
|
||||
OUTPUT=${OUTPUT:-$HOME/.config/clash/testoutput.yaml}
|
||||
OUTDIR=$(dirname $OUTPUT)
|
||||
|
||||
sleep 10000
|
||||
LOG="/tmp/clash-updater.log"
|
||||
|
||||
|
||||
exec > ${LOG}
|
||||
set -x
|
||||
|
||||
while true; do
|
||||
curl -v --continue -o ${TEMP} ${SUBSCRIPTION_URL}
|
||||
RET=$?
|
||||
|
||||
if [[ $RET -eq 0 ]]; then
|
||||
mkdir -pv $OUTDIR
|
||||
cp -v $TEMP $OUTPUT
|
||||
fi
|
||||
|
||||
sleep $((3600*24))
|
||||
done
|
||||
|
@ -1,5 +1,5 @@
|
||||
with import <nixpkgs> {};
|
||||
with pkgs;
|
||||
{
|
||||
clash-premium = callPackage ../network/proxy/clash-premium { version = "2022.07.07"; };
|
||||
clash-premium = callPackage (import ../network/proxy/clash-premium).clash-premium { version = "2022.07.07"; };
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user