flake.nix 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {
  2. description = "Another Mihomo Kernel";
  3. inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
  4. inputs.utils.url = "github:numtide/flake-utils";
  5. outputs = { self, nixpkgs, utils }:
  6. utils.lib.eachDefaultSystem
  7. (system:
  8. let
  9. pkgs = import nixpkgs {
  10. inherit system;
  11. overlays = [ self.overlay ];
  12. };
  13. in
  14. rec {
  15. packages.default = pkgs.mihomo-meta;
  16. }
  17. ) //
  18. (
  19. let version = nixpkgs.lib.substring 0 8 self.lastModifiedDate or self.lastModified or "19700101"; in
  20. {
  21. overlay = final: prev: {
  22. mihomo-meta = final.buildGo119Module {
  23. pname = "mihomo-meta";
  24. inherit version;
  25. src = ./.;
  26. vendorSha256 = "sha256-W5oiPtTRin0731QQWr98xZ2Vpk97HYcBtKoi1OKZz+w=";
  27. # Do not build testing suit
  28. excludedPackages = [ "./test" ];
  29. CGO_ENABLED = 0;
  30. ldflags = [
  31. "-s"
  32. "-w"
  33. "-X github.com/metacubex/mihomo/constant.Version=dev-${version}"
  34. "-X github.com/metacubex/mihomo/constant.BuildTime=${version}"
  35. ];
  36. tags = [
  37. "with_gvisor"
  38. ];
  39. # Network required
  40. doCheck = false;
  41. postInstall = ''
  42. mv $out/bin/mihomo $out/bin/mihomo-meta
  43. '';
  44. };
  45. };
  46. }
  47. );
  48. }