From 74b40e9a433066ae6a87a32a85a229a1a4d4adbf Mon Sep 17 00:00:00 2001 From: rushmorem Date: Thu, 19 Feb 2015 11:32:02 +0200 Subject: [PATCH] Add marathon mesos framework --- lib/maintainers.nix | 1 + nixos/modules/misc/ids.nix | 1 + nixos/modules/module-list.nix | 1 + .../modules/services/scheduling/marathon.nix | 58 +++++++++++++++++++ .../networking/cluster/marathon/default.nix | 30 ++++++++++ pkgs/top-level/all-packages.nix | 2 + 6 files changed, 93 insertions(+) create mode 100644 nixos/modules/services/scheduling/marathon.nix create mode 100644 pkgs/applications/networking/cluster/marathon/default.nix diff --git a/lib/maintainers.nix b/lib/maintainers.nix index d913a28c999d..89ab1f5c3cfe 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -159,6 +159,7 @@ roelof = "Roelof Wobben "; romildo = "José Romildo Malaquias "; rszibele = "Richard Szibele "; + rushmorem = "Rushmore Mushambi "; rycee = "Robert Helgesson "; sander = "Sander van der Burg "; schristo = "Scott Christopher "; diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index f3cda7b95416..390bab907b37 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -178,6 +178,7 @@ nylon = 168; apache-kafka = 169; panamax = 170; + marathon = 171; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8ce1c6c20a36..e0255bbbe28e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -315,6 +315,7 @@ ./services/scheduling/chronos.nix ./services/scheduling/cron.nix ./services/scheduling/fcron.nix + ./services/scheduling/marathon.nix ./services/search/elasticsearch.nix ./services/search/solr.nix ./services/security/clamav.nix diff --git a/nixos/modules/services/scheduling/marathon.nix b/nixos/modules/services/scheduling/marathon.nix new file mode 100644 index 000000000000..8513d1174c38 --- /dev/null +++ b/nixos/modules/services/scheduling/marathon.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.marathon; + +in { + + ###### interface + + options.services.marathon = { + enable = mkOption { + description = "Whether to enable the marathon mesos framework."; + default = false; + type = types.uniq types.bool; + }; + + httpPort = mkOption { + description = "Marathon listening port"; + default = 8080; + type = types.int; + }; + + master = mkOption { + description = "Marathon mesos master zookeeper address"; + default = "zk://${head cfg.zookeeperHosts}/mesos"; + type = types.str; + }; + + zookeeperHosts = mkOption { + description = "Marathon mesos zookepper addresses"; + default = [ "localhost:2181" ]; + type = types.listOf types.str; + }; + }; + + ###### implementation + + config = mkIf cfg.enable { + systemd.services.marathon = { + description = "Marathon Service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network-interfaces.target" "zookeeper.service" "mesos-master.service" "mesos-slave.service" ]; + + serviceConfig = { + ExecStart = "${pkgs.marathon}/bin/marathon --master ${cfg.master} --zk zk://${head cfg.zookeeperHosts}/marathon"; + User = "marathon"; + }; + }; + + users.extraUsers.marathon = { + uid = config.ids.uids.marathon; + description = "Marathon mesos framework user"; + }; + }; +} diff --git a/pkgs/applications/networking/cluster/marathon/default.nix b/pkgs/applications/networking/cluster/marathon/default.nix new file mode 100644 index 000000000000..36ce79aaf341 --- /dev/null +++ b/pkgs/applications/networking/cluster/marathon/default.nix @@ -0,0 +1,30 @@ +{ stdenv, makeWrapper, jdk, mesos, fetchurl }: + +stdenv.mkDerivation rec { + name = "marathon-v${version}"; + version = "0.8.0"; + + src = fetchurl { + url = "https://downloads.mesosphere.com/marathon/v${version}/marathon-${version}.tgz"; + sha256 = "794c915e205aebd8273f2b40c6faea1517fc683cdc0169194c4a67ce8779fa41"; + }; + + buildInputs = [ makeWrapper jdk mesos ]; + + installPhase = '' + mkdir -p $out/{bin,libexec/marathon} + cp target/scala-*/marathon*.jar $out/libexec/marathon/${name}.jar + + makeWrapper ${jdk.jre}/bin/java $out/bin/marathon \ + --add-flags "-Xmx512m -jar $out/libexec/marathon/${name}.jar" \ + --prefix "MESOS_NATIVE_LIBRARY" : "$MESOS_NATIVE_LIBRARY" + ''; + + meta = with stdenv.lib; { + homepage = https://mesosphere.github.io/marathon; + description = "Cluster-wide init and control system for services in cgroups or Docker containers."; + license = licenses.asl20; + maintainers = with maintainers; [ rushmorem ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c43979a880f2..19838a7b7d29 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10013,6 +10013,8 @@ let magit = callPackage ../applications/editors/emacs-modes/magit { }; + marathon = callPackage ../applications/networking/cluster/marathon { }; + maudeMode = callPackage ../applications/editors/emacs-modes/maude { }; metaweblog = callPackage ../applications/editors/emacs-modes/metaweblog { };