add: flake.nix and other required files for nix build

This commit is contained in:
oluceps 2022-10-01 22:34:39 +08:00
parent 1684756b79
commit 7e9549c05a
No known key found for this signature in database
GPG key ID: ECBE55269336CCCD
3 changed files with 103 additions and 0 deletions

41
default.nix Executable file
View file

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

43
flake.lock Normal file
View file

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

19
flake.nix Normal file
View file

@ -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 ./. { };
})
);
}