From 47d81ed3473f33cfb48f2be079f50cdfac60f1e7 Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Sun, 6 Nov 2016 10:33:21 +0100 Subject: [PATCH] leaps: 0.5.1 + add a service + test --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/leaps.nix | 62 ++++++++++++++++ nixos/release.nix | 1 + nixos/tests/leaps.nix | 29 ++++++++ pkgs/development/tools/leaps/default.nix | 18 ++--- pkgs/development/tools/leaps/deps.nix | 91 ++++++++++++++++++++++-- 7 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 nixos/modules/services/misc/leaps.nix create mode 100644 nixos/tests/leaps.nix diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 8c0f0c2624b..c75c22472bd 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -277,6 +277,7 @@ gitlab-runner = 257; postgrey = 258; hound = 259; + leaps = 260; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -524,6 +525,7 @@ gitlab-runner = 257; postgrey = 258; hound = 259; + leaps = 260; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 08d73970408..356cb5a92ed 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -251,6 +251,7 @@ ./services/misc/gitolite.nix ./services/misc/gpsd.nix ./services/misc/ihaskell.nix + ./services/misc/leaps.nix ./services/misc/mantisbt.nix ./services/misc/mathics.nix ./services/misc/matrix-synapse.nix diff --git a/nixos/modules/services/misc/leaps.nix b/nixos/modules/services/misc/leaps.nix new file mode 100644 index 00000000000..b92cf27f58d --- /dev/null +++ b/nixos/modules/services/misc/leaps.nix @@ -0,0 +1,62 @@ +{ config, pkgs, lib, ... } @ args: + +with lib; + +let + cfg = config.services.leaps; + stateDir = "/var/lib/leaps/"; +in +{ + options = { + services.leaps = { + enable = mkEnableOption "leaps"; + port = mkOption { + type = types.int; + default = 8080; + description = "A port where leaps listens for incoming http requests"; + }; + address = mkOption { + default = ""; + type = types.str; + example = "127.0.0.1"; + description = "Hostname or IP-address to listen to. By default it will listen on all interfaces."; + }; + path = mkOption { + default = "/"; + type = types.path; + description = "Subdirectory used for reverse proxy setups"; + }; + }; + }; + + config = mkIf cfg.enable { + users = { + users.leaps = { + uid = config.ids.uids.leaps; + description = "Leaps server user"; + group = "leaps"; + home = stateDir; + createHome = true; + }; + + groups.leaps = { + gid = config.ids.gids.leaps; + }; + }; + + systemd.services.leaps = { + description = "leaps service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + User = "leaps"; + Group = "leaps"; + Restart = "on-failure"; + WorkingDirectory = stateDir; + PrivateTmp = true; + ExecStart = "${pkgs.leaps.bin}/bin/leaps -path ${toString cfg.path} -address ${cfg.address}:${toString cfg.port}"; + }; + }; + }; +} diff --git a/nixos/release.nix b/nixos/release.nix index fbd3efd16ff..639ee45b38d 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -275,6 +275,7 @@ in rec { tests.networkingProxy = callTest tests/networking-proxy.nix {}; tests.nfs3 = callTest tests/nfs.nix { version = 3; }; tests.nfs4 = callTest tests/nfs.nix { version = 4; }; + tests.leaps = callTest tests/leaps.nix { }; tests.nsd = callTest tests/nsd.nix {}; tests.openssh = callTest tests/openssh.nix {}; #tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; }); diff --git a/nixos/tests/leaps.nix b/nixos/tests/leaps.nix new file mode 100644 index 00000000000..3c390e1a169 --- /dev/null +++ b/nixos/tests/leaps.nix @@ -0,0 +1,29 @@ +import ./make-test.nix ({ pkgs, ... }: + +{ + name = "leaps"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ qknight ]; + }; + + nodes = + { + client = { }; + + server = + { services.leaps = { + enable = true; + port = 6666; + path = "/leaps/"; + }; + networking.firewall.enable = false; + }; + }; + + testScript = + '' + startAll; + $server->waitForOpenPort(6666); + $client->succeed("curl http://server:6666/leaps/ | grep -i 'leaps'"); + ''; +}) diff --git a/pkgs/development/tools/leaps/default.nix b/pkgs/development/tools/leaps/default.nix index 6db999eea54..ecc690ead05 100644 --- a/pkgs/development/tools/leaps/default.nix +++ b/pkgs/development/tools/leaps/default.nix @@ -1,26 +1,26 @@ -{ stdenv, buildGoPackage, fetchgit, fetchhg, fetchbzr, fetchsvn }: +{ stdenv, buildGoPackage, fetchFromGitHub, fetchhg, fetchbzr, fetchsvn }: buildGoPackage rec { name = "leaps-${version}"; - version = "20160626-${stdenv.lib.strings.substring 0 7 rev}"; - rev = "5cf7328a8c498041d2a887e89f22f138498f4621"; + version = "0.5.1"; goPackagePath = "github.com/jeffail/leaps"; - src = fetchgit { - inherit rev; - url = "https://github.com/jeffail/leaps"; - sha256 = "1qbgz48x9yi0w9yz39zsnnhx5nx2xmrns9v8hx28jah2bvag6sq7"; - fetchSubmodules = false; + src = fetchFromGitHub { + owner = "jeffail"; + repo = "leaps"; + sha256 = "0w63y777h5qc8fwnkrbawn3an9px0l1zz3649x0n8lhk125fvchj"; + rev = "v${version}"; }; goDeps = ./deps.nix; + meta = { description = "A pair programming tool and library written in Golang"; homepage = "https://github.com/jeffail/leaps/"; license = "MIT"; maintainers = with stdenv.lib.maintainers; [ qknight ]; meta.platforms = stdenv.lib.platforms.linux; - broken = true; }; } + diff --git a/pkgs/development/tools/leaps/deps.nix b/pkgs/development/tools/leaps/deps.nix index 0a6214a76d0..d611d9b4954 100644 --- a/pkgs/development/tools/leaps/deps.nix +++ b/pkgs/development/tools/leaps/deps.nix @@ -1,11 +1,94 @@ [ { - goPackagePath = "golang.org/x/net"; + goPackagePath = "github.com/amir/raidman"; fetch = { type = "git"; - url = "https://go.googlesource.com/net"; - rev = "07b51741c1d6423d4a6abab1c49940ec09cb1aaf"; - sha256 = "12lvdj0k2gww4hw5f79qb9yswqpy4i3bgv1likmf3mllgdxfm20w"; + url = "https://github.com/amir/raidman"; + rev = "91c20f3f475cab75bb40ad7951d9bbdde357ade7"; + sha256 = "0pkqy5hzjkk04wj1ljq8jsyla358ilxi4lkmvkk73b3dh2wcqvpp"; + }; + } + { + goPackagePath = "github.com/elazarl/go-bindata-assetfs"; + fetch = { + type = "git"; + url = "https://github.com/elazarl/go-bindata-assetfs"; + rev = "57eb5e1fc594ad4b0b1dbea7b286d299e0cb43c2"; + sha256 = "1za29pa15y2xsa1lza97jlkax9qj93ks4a2j58xzmay6rczfkb9i"; + }; + } + { + goPackagePath = "github.com/garyburd/redigo"; + fetch = { + type = "git"; + url = "https://github.com/garyburd/redigo"; + rev = "8873b2f1995f59d4bcdd2b0dc9858e2cb9bf0c13"; + sha256 = "1lzhb99pcwwf5ddcs0bw00fwf9m1d0k7b92fqz2a01jlij4pm5l2"; + }; + } + { + goPackagePath = "github.com/go-sql-driver/mysql"; + fetch = { + type = "git"; + url = "https://github.com/go-sql-driver/mysql"; + rev = "7ebe0a500653eeb1859664bed5e48dec1e164e73"; + sha256 = "1gyan3lyn2j00di9haq7zm3zcwckn922iigx3fvml6s2bsp6ljas"; + }; + } + { + goPackagePath = "github.com/golang/protobuf"; + fetch = { + type = "git"; + url = "https://github.com/golang/protobuf"; + rev = "bf531ff1a004f24ee53329dfd5ce0b41bfdc17df"; + sha256 = "10lnvmq28jp2wk1xc32mdk4745lal2bmdvbjirckb9wlv07zzzf0"; + }; + } + { + goPackagePath = "github.com/jeffail/gabs"; + fetch = { + type = "git"; + url = "https://github.com/jeffail/gabs"; + rev = "ee1575a53249b51d636e62464ca43a13030afdb5"; + sha256 = "0svv57193n8m86r7v7n0y9lny0p6nzr7xvz98va87h00mg146351"; + }; + } + { + goPackagePath = "github.com/jeffail/util"; + fetch = { + type = "git"; + url = "https://github.com/jeffail/util"; + rev = "48ada8ff9fcae546b5986f066720daa9033ad523"; + sha256 = "0k8zz7gdv4hb691fdyb5mhlixppcq8x4ny84fanflypnv258a3i0"; + }; + } + { + goPackagePath = "github.com/lib/pq"; + fetch = { + type = "git"; + url = "https://github.com/lib/pq"; + rev = "3cd0097429be7d611bb644ef85b42bfb102ceea4"; + sha256 = "1q7qfzyfgjk6rvid548r43fi4jhvsh4dhfvfjbp2pz4xqsvpsm7a"; + }; + } + { + goPackagePath = "github.com/satori/go.uuid"; + fetch = { + type = "git"; + url = "https://github.com/satori/go.uuid"; + rev = "f9ab0dce87d815821e221626b772e3475a0d2749"; + sha256 = "0z18j6zxq9kw4lgcpmhh3k7jrb9gy1lx252xz5qhs4ywi9w77xwi"; + }; + } + + { + goPackagePath = "golang.org/x/net"; + fetch = { + type = "git"; + url = "https://go.googlesource.com/net"; + rev = "07b51741c1d6423d4a6abab1c49940ec09cb1aaf"; + sha256 = "12lvdj0k2gww4hw5f79qb9yswqpy4i3bgv1likmf3mllgdxfm20w"; }; } ] +