From 7e4e2667ae95b19ae5982c33c498a100349daccd Mon Sep 17 00:00:00 2001 From: Wei-Ming Yang Date: Tue, 26 Sep 2017 03:03:16 +0800 Subject: [PATCH] softether: 4.18 -> 4.20 --- .../modules/services/networking/softether.nix | 55 +++++++++++-------- pkgs/servers/softether/4.20.nix | 53 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 +- 3 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 pkgs/servers/softether/4.20.nix diff --git a/nixos/modules/services/networking/softether.nix b/nixos/modules/services/networking/softether.nix index 16530078b978..9087b75c29c1 100644 --- a/nixos/modules/services/networking/softether.nix +++ b/nixos/modules/services/networking/softether.nix @@ -3,7 +3,6 @@ with lib; let - pkg = pkgs.softether; cfg = config.services.softether; in @@ -17,6 +16,15 @@ in enable = mkEnableOption "SoftEther VPN services"; + package = mkOption { + type = types.package; + default = pkgs.softether; + defaultText = "pkgs.softether"; + description = '' + softether derivation to use. + ''; + }; + vpnserver.enable = mkEnableOption "SoftEther VPN Server"; vpnbridge.enable = mkEnableOption "SoftEther VPN Bridge"; @@ -41,7 +49,7 @@ in dataDir = mkOption { type = types.string; - default = "${pkg.dataDir}"; + default = "${cfg.package.dataDir}"; description = '' Data directory for SoftEther VPN. ''; @@ -57,12 +65,13 @@ in mkMerge [{ environment.systemPackages = [ - (pkgs.lib.overrideDerivation pkg (attrs: { + (pkgs.lib.overrideDerivation cfg.package (attrs: { dataDir = cfg.dataDir; })) ]; systemd.services."softether-init" = { description = "SoftEther VPN services initial task"; + wantedBy = [ "network.target" ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = false; @@ -71,11 +80,11 @@ in for d in vpnserver vpnbridge vpnclient vpncmd; do if ! test -e ${cfg.dataDir}/$d; then ${pkgs.coreutils}/bin/mkdir -m0700 -p ${cfg.dataDir}/$d - install -m0600 ${pkg}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2 + install -m0600 ${cfg.package}${cfg.dataDir}/$d/hamcore.se2 ${cfg.dataDir}/$d/hamcore.se2 fi done rm -rf ${cfg.dataDir}/vpncmd/vpncmd - ln -s ${pkg}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd + ln -s ${cfg.package}${cfg.dataDir}/vpncmd/vpncmd ${cfg.dataDir}/vpncmd/vpncmd ''; }; } @@ -83,17 +92,17 @@ in (mkIf (cfg.vpnserver.enable) { systemd.services.vpnserver = { description = "SoftEther VPN Server"; - after = [ "softether-init.service" "network.target" ]; - wants = [ "softether-init.service" ]; - wantedBy = [ "multi-user.target" ]; + after = [ "softether-init.service" ]; + requires = [ "softether-init.service" ]; + wantedBy = [ "network.target" ]; serviceConfig = { Type = "forking"; - ExecStart = "${pkg}/bin/vpnserver start"; - ExecStop = "${pkg}/bin/vpnserver stop"; + ExecStart = "${cfg.package}/bin/vpnserver start"; + ExecStop = "${cfg.package}/bin/vpnserver stop"; }; preStart = '' rm -rf ${cfg.dataDir}/vpnserver/vpnserver - ln -s ${pkg}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver + ln -s ${cfg.package}${cfg.dataDir}/vpnserver/vpnserver ${cfg.dataDir}/vpnserver/vpnserver ''; postStop = '' rm -rf ${cfg.dataDir}/vpnserver/vpnserver @@ -104,17 +113,17 @@ in (mkIf (cfg.vpnbridge.enable) { systemd.services.vpnbridge = { description = "SoftEther VPN Bridge"; - after = [ "softether-init.service" "network.target" ]; - wants = [ "softether-init.service" ]; - wantedBy = [ "multi-user.target" ]; + after = [ "softether-init.service" ]; + requires = [ "softether-init.service" ]; + wantedBy = [ "network.target" ]; serviceConfig = { Type = "forking"; - ExecStart = "${pkg}/bin/vpnbridge start"; - ExecStop = "${pkg}/bin/vpnbridge stop"; + ExecStart = "${cfg.package}/bin/vpnbridge start"; + ExecStop = "${cfg.package}/bin/vpnbridge stop"; }; preStart = '' rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge - ln -s ${pkg}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge + ln -s ${cfg.package}${cfg.dataDir}/vpnbridge/vpnbridge ${cfg.dataDir}/vpnbridge/vpnbridge ''; postStop = '' rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge @@ -125,17 +134,17 @@ in (mkIf (cfg.vpnclient.enable) { systemd.services.vpnclient = { description = "SoftEther VPN Client"; - after = [ "softether-init.service" "network.target" ]; - wants = [ "softether-init.service" ]; - wantedBy = [ "multi-user.target" ]; + after = [ "softether-init.service" ]; + requires = [ "softether-init.service" ]; + wantedBy = [ "network.target" ]; serviceConfig = { Type = "forking"; - ExecStart = "${pkg}/bin/vpnclient start"; - ExecStop = "${pkg}/bin/vpnclient stop"; + ExecStart = "${cfg.package}/bin/vpnclient start"; + ExecStop = "${cfg.package}/bin/vpnclient stop"; }; preStart = '' rm -rf ${cfg.dataDir}/vpnclient/vpnclient - ln -s ${pkg}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient + ln -s ${cfg.package}${cfg.dataDir}/vpnclient/vpnclient ${cfg.dataDir}/vpnclient/vpnclient ''; postStart = '' sleep 1 diff --git a/pkgs/servers/softether/4.20.nix b/pkgs/servers/softether/4.20.nix new file mode 100644 index 000000000000..c6ef5a3a4df2 --- /dev/null +++ b/pkgs/servers/softether/4.20.nix @@ -0,0 +1,53 @@ +{ stdenv, fetchurl +, openssl, readline, ncurses, zlib }: + +let + os = if stdenv.isLinux then "1" + else if stdenv.isFreeBSD then "2" + else if stdenv.isSunOS then "3" + else if stdenv.isDarwin then "4" + else if stdenv.isOpenBSD then "5" + else ""; + cpuBits = if stdenv.is64bit then "2" else "1"; + +in + +stdenv.mkDerivation rec { + name = "softether-${version}"; + version = "4.20"; + build = "9608"; + compiledDate = "2016.04.17"; + dataDir = "/var/lib/softether"; + + src = fetchurl { + url = "http://www.softether-download.com/files/softether/v${version}-${build}-rtm-${compiledDate}-tree/Source_Code/softether-src-v${version}-${build}-rtm.tar.gz"; + sha256 = "e559644e34ec6feba43d99f4083f77f9b082dd0574d0bb1e416a65f32ccbc51e"; + }; + + buildInputs = [ openssl readline ncurses zlib ]; + + preConfigure = '' + echo "${os} + ${cpuBits} + " | ./configure + rm configure + ''; + + buildPhase = '' + mkdir -p $out/bin + sed -i \ + -e "/INSTALL_BINDIR=/s|/usr/bin|/bin|g" \ + -e "/_DIR=/s|/usr|${dataDir}|g" \ + -e "s|\$(INSTALL|$out/\$(INSTALL|g" \ + -e "/echo/s|echo $out/|echo |g" \ + Makefile + ''; + + meta = with stdenv.lib; { + description = "An Open-Source Free Cross-platform Multi-protocol VPN Program"; + homepage = https://www.softether.org/; + license = licenses.gpl2; + maintainers = [ maintainers.rick68 ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6cbb7961f3ed..fb040034fcca 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11713,7 +11713,8 @@ with pkgs; oracleXE = callPackage ../servers/sql/oracle-xe { }; softether_4_18 = callPackage ../servers/softether/4.18.nix { }; - softether = softether_4_18; + softether_4_20 = callPackage ../servers/softether/4.20.nix { }; + softether = softether_4_20; qboot = callPackage ../applications/virtualization/qboot { stdenv = stdenv_32bit; };