diff --git a/default.nix b/default.nix new file mode 100755 index 00000000..112c3d35 --- /dev/null +++ b/default.nix @@ -0,0 +1,41 @@ +{ lib +, fetchFromGitHub +, buildGoModule +}: +buildGoModule rec { + pname = "clash-meta"; + version = "1.13.1"; + + src = fetchFromGitHub { + owner = "MetaCubeX"; + repo = "Clash.Meta"; + rev = "1684756b79a232ee8f875bcfd87371f5c0ef066b"; + sha256 = "sha256-7g/Wcll0w4EhPI+KodtLHINqaR2larQNnP9YAsgNiN4="; + }; + + vendorSha256 = "sha256-7HjYcoqWA5gvPUc5psCgy0UTc17CBzBJ/OiGvII/iBA="; + + # Do not build testing suit + excludedPackages = [ "./test" ]; + + CGO_ENABLED = 0; + + ldflags = [ + "-s" + "-w" + "-X github.com/Dreamacro/clash/constant.Version=${version}" + ]; + + # network required + doCheck = false; + + postInstall = '' + mv $out/bin/clash $out/bin/clash-meta + ''; + + meta = with lib; { + description = "Another Clash Kernel"; + homepage = "https://github.com/MetaCubeX/Clash.Meta"; + license = licenses.gpl3Only; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..df343f24 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1664614409, + "narHash": "sha256-5y+zhLMzc/k4NYnCfW+seM9oaNuUI/UeGMGPFRj8cR0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b746456c6f6ef8404ef6011df5eceba8644c49a9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..297a284f --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "Another Clash Kernel"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/master"; + + inputs.utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, utils }: + (utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + + { + defaultPackages = pkgs.callPackage ./. { }; + }) + ); +}