seperate clash-updater

This commit is contained in:
guochao 2022-07-18 15:12:35 +08:00
parent 7270a94cde
commit 1c484f8caa
4 changed files with 80 additions and 60 deletions

View File

@ -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";
@ -21,6 +20,7 @@ let
};
currentTriple = systemTriple."${stdenv.targetPlatform.system}";
in
stdenv.mkDerivation {
name = "clash-premium";
src = fetchurl {
@ -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;
}

View 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}"
'';
}

View File

@ -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

View File

@ -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"; };
}