Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created July 11, 2015 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/238717587ab075127eb1 to your computer and use it in GitHub Desktop.
Save cleverca22/238717587ab075127eb1 to your computer and use it in GitHub Desktop.
{ lib, config, pkgs, ... }:
{
services = {
toxvpn.enable = true;
toxvpn.localip = "192.168.123.10";
};
imports = [ <nixpkgs/nixos/modules/profiles/all-hardware.nix> "/etc/nixos/toxvpn_module.nix" ];
}
#{ stdenv, fetchFromGitHub, libtoxcore, cmake, jsoncpp, lib, ... }:
with import <nixpkgs> {};
with lib;
let libtoxcoreLocked = stdenv.lib.overrideDerivation libtoxcore (oldAttrs: {
name = "libtoxcore-20150424";
src = fetchFromGitHub {
owner = "irungentoo";
repo = "toxcore";
rev = "964233b0bf8240e70bb8bfddce17262756171231";
sha256 = "1vcx9qjbnnjvqmc3xwjvisc31wrs4hpcy27qd6icbdl6npls1vgd";
};
});
stdenv2 = stdenvAdapters.keepDebugInfo stdenv;
in
stdenv2.mkDerivation {
name = "toxvpn-20150614";
buildInputs = [ cmake libtoxcoreLocked jsoncpp ];
src = fetchFromGitHub {
owner = "cleverca22";
repo = "toxvpn";
rev = "90bd373c1ac4594be7e78bf9668801985da6cea6";
sha256 = "0l6r9k4hq65g76s071q1rv64w3125ir3v4l47qdgn5p9hjb8d2hy";
};
meta = {
description = "a tox based vpn program";
license = stdenv.lib.licenses.gpl3;
platforms = stdenv.lib.platforms.linux;
};
}
{ config, stdenv, pkgs, lib, ... }:
#with import <nixpkgs> {};
with lib;
{
options = {
services.toxvpn = {
enable = mkOption {
type = types.bool;
default = false;
description = "enable toxvpn running on startup";
};
localip = mkOption {
type = types.string;
default = "10.123.123.1";
description = "your ip on the vpn";
};
};
};
config = mkIf config.services.toxvpn.enable {
nixpkgs.config = {
packageOverrides = pkgs: {
toxvpn = (import "/etc/nixos/toxvpn.nix");
};
};
#environment.systemPackages = [ pkgs.toxvpn ];
systemd = let
service = {
description = "toxvpn daemon";
#path = [ config.programs.toxvpn.package ];
serviceConfig = {
ExecStart = "${pkgs.toxvpn}/bin/toxvpn -si ${config.services.toxvpn.localip}";
#ExecStart = "/root/toxvpn/toxvpn -si ${config.services.toxvpn.localip}";
KillMode = "process";
Restart = "on-success";
StandardInput = "socket";
StandardOutput = "journal";
};
};
socket = {
socketConfig = {
ListenStream = "/run/toxvpn";
};
};
in {
services.toxvpn = service;
sockets.toxvpn = socket;
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment