at 25.11-pre 1.4 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8{ 9 imports = [ 10 (lib.mkRemovedOptionModule [ "programs" "clash-verge" "tunMode" ] '' 11 The tunMode will work with service mode which is enabled by default. 12 '') 13 ]; 14 options.programs.clash-verge = { 15 enable = lib.mkEnableOption "Clash Verge"; 16 package = lib.mkOption { 17 type = lib.types.package; 18 description = '' 19 The clash-verge package to use. Available options are 20 clash-verge-rev and clash-nyanpasu, both are forks of 21 the original clash-verge project. 22 ''; 23 default = pkgs.clash-verge-rev; 24 defaultText = lib.literalExpression "pkgs.clash-verge-rev"; 25 }; 26 autoStart = lib.mkEnableOption "Clash Verge auto launch"; 27 }; 28 29 config = 30 let 31 cfg = config.programs.clash-verge; 32 in 33 lib.mkIf cfg.enable { 34 35 environment.systemPackages = [ 36 cfg.package 37 (lib.mkIf cfg.autoStart ( 38 pkgs.makeAutostartItem { 39 name = "clash-verge"; 40 package = cfg.package; 41 } 42 )) 43 ]; 44 45 systemd.services.clash-verge = { 46 enable = true; 47 description = "Clash Verge Service Mode"; 48 serviceConfig = { 49 ExecStart = "${cfg.package}/bin/clash-verge-service"; 50 Restart = "on-failure"; 51 }; 52 wantedBy = [ "multi-user.target" ]; 53 }; 54 }; 55 56 meta.maintainers = with lib.maintainers; [ 57 bot-wxt1221 58 Guanran928 59 ]; 60}