From 2a3a3248def505c64c3f596acefa894959d4a20d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Dec 2017 21:06:21 +0100 Subject: cidr2glob: init Based on https://gist.github.com/speshak/b62fa28b49377cda8047cb227837244c --- krebs/5pkgs/simple/cidr2glob.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 krebs/5pkgs/simple/cidr2glob.nix (limited to 'krebs/5pkgs/simple') diff --git a/krebs/5pkgs/simple/cidr2glob.nix b/krebs/5pkgs/simple/cidr2glob.nix new file mode 100644 index 000000000..9b0b3f86b --- /dev/null +++ b/krebs/5pkgs/simple/cidr2glob.nix @@ -0,0 +1,30 @@ +{ python, writeScriptBin, ... }: + +let + pythonEnv = python.withPackages (ps: [ ps.netaddr ]); +in + writeScriptBin "cidr2glob" '' + #! ${pythonEnv}/bin/python + + import netaddr + import re + import sys + + def cidr2glob(cidr): + net = netaddr.IPNetwork(cidr) + + if net.prefixlen <= 8: + return map(lambda subnet: re.sub(r'\.0\.0\.0$', '.*', str(subnet.ip)), net.subnet(8)) + elif net.prefixlen <= 16: + return map(lambda subnet: re.sub(r'\.0\.0$', '.*', str(subnet.ip)), net.subnet(16)) + elif net.prefixlen <= 24: + return map(lambda subnet: re.sub(r'\.0$', '.*', str(subnet.ip)), net.subnet(24)) + else: + return map(lambda ip: str(ip), list(net)) + + if __name__ == "__main__": + for cidr in sys.stdin: + for glob in cidr2glob(cidr): + print glob + + '' -- cgit v1.2.3 From 939976b0cc1166f0a212b283cc1c8022a784b648 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 15 Dec 2017 00:14:30 +0100 Subject: populate: 1.2.5 -> 2.0.0 --- krebs/5pkgs/simple/populate/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'krebs/5pkgs/simple') diff --git a/krebs/5pkgs/simple/populate/default.nix b/krebs/5pkgs/simple/populate/default.nix index 78ee2f042..0880b1d38 100644 --- a/krebs/5pkgs/simple/populate/default.nix +++ b/krebs/5pkgs/simple/populate/default.nix @@ -1,24 +1,24 @@ -{ coreutils, fetchgit, git, jq, openssh, proot, rsync, stdenv, ... }: +{ coreutils, fetchgit, git, gnused, jq, openssh, rsync, stdenv, ... }: let PATH = stdenv.lib.makeBinPath [ coreutils git + gnused jq openssh - proot rsync ]; in stdenv.mkDerivation rec { name = "populate"; - version = "1.2.5"; + version = "2.0.0"; src = fetchgit { url = http://cgit.ni.krebsco.de/populate; rev = "refs/tags/v${version}"; - sha256 = "10s4x117zp5whqq991xzw1i2jc1xhl580kx8hhzv8f1b4c9carx1"; + sha256 = "01cvrg3m2ypg59in1qlr3rd8yzpf002k6pzjls2qb68jwkyf0h2n"; }; phases = [ -- cgit v1.2.3 From 92a34559eebb73cd71e9aa8e11565f1a8f2cb437 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 15 Dec 2017 03:29:00 +0100 Subject: populate: 2.0.0 -> 2.1.0 --- krebs/5pkgs/simple/populate/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'krebs/5pkgs/simple') diff --git a/krebs/5pkgs/simple/populate/default.nix b/krebs/5pkgs/simple/populate/default.nix index 0880b1d38..62e3ab216 100644 --- a/krebs/5pkgs/simple/populate/default.nix +++ b/krebs/5pkgs/simple/populate/default.nix @@ -1,24 +1,27 @@ -{ coreutils, fetchgit, git, gnused, jq, openssh, rsync, stdenv, ... }: +{ coreutils, fetchgit, findutils, git, gnused, jq, openssh, pass, rsync, stdenv +}: let PATH = stdenv.lib.makeBinPath [ coreutils + findutils git gnused jq openssh + pass rsync ]; in stdenv.mkDerivation rec { name = "populate"; - version = "2.0.0"; + version = "2.1.0"; src = fetchgit { url = http://cgit.ni.krebsco.de/populate; rev = "refs/tags/v${version}"; - sha256 = "01cvrg3m2ypg59in1qlr3rd8yzpf002k6pzjls2qb68jwkyf0h2n"; + sha256 = "0cr50y6h6nps0qgpmi01h0z9wzpv2704y5zgx2salk1grkmvcfmh"; }; phases = [ -- cgit v1.2.3