diff --git a/contrib/nix/README.md b/contrib/nix/README.md new file mode 100644 index 0000000000000..484fcd7b252ce --- /dev/null +++ b/contrib/nix/README.md @@ -0,0 +1,42 @@ +# Nix sandbox for datahub + + +## Introduction +database is not suitable for virtualization for it's io performance. + +so we use simple nix package tool to install package and setup service on physical machine. + +we declare it, then it works. see [sandbox.nix] file for details. + +it install software on /nix directory, and run service on launchpad(darwin) and systemd(linux). + + +## Roadmap +currently i already run all service on mac os. +linux os will be tested and supportd will come sooner. + + +## Quickstart +1. install nix and channel + +``` + sudo install -d -m755 -o $(id -u) -g $(id -g) /nix + curl https://nixos.org/nix/install | sh + + nix-channel --add https://nixos.org/channels/nixos-20.03 nixos-20.03 + nix-channel --update nixos-20.03 +``` + +2. install home-manager + +``` + nix-channel --add https://github.com/clojurians-org/home-manager/archive/master.tar.gz home-manager + nix-channel --update + nix-shell '' -A install +``` + +3. setup environment, and well done! +``` + export NIX_PATH=~/.nix-defexpr/channels + home-manager -I home-manager= -f sandbox.nix switch +``` diff --git a/contrib/nix/sandbox.nix b/contrib/nix/sandbox.nix new file mode 100644 index 0000000000000..7c88463d041e2 --- /dev/null +++ b/contrib/nix/sandbox.nix @@ -0,0 +1,80 @@ +{ config, pkgs, ... }: + +{ + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "19.09"; + + + environment.systemPackages = [ + pkgs.gradle + + pkgs.postgresql_11 + pkgs.mysql57 + pkgs.elasticsearch7 + pkgs.neo4j + pkgs.zookeeper + pkgs.apacheKafka + pkgs.confluent-platform + pkgs.kafkacat + pkgs.neo4j + ]; + + services.postgresql = { + enable = true ; + package = pkgs.postgresql_11 ; + dataDir = "/opt/nix-module/data/postgresql" ; + } ; + + services.mysql = { + enable = true ; + # package = pkgs.mysql80 ; + package = pkgs.mysql57 ; + dataDir = "/opt/nix-module/data/mysql" ; + unixSocket = "/opt/nix-module/run/mysql.sock" ; + } ; + + services.elasticsearch = { + enable = true ; + package = pkgs.elasticsearch7 ; + dataDir = "/opt/nix-module/data/elasticsearch" ; + } ; + + services.neo4j = { + enable = true ; + package = pkgs.neo4j ; + directories.home = "/opt/nix-module/data/neo4j" ; + } ; + + services.zookeeper = { + enable = true ; + package = pkgs.zookeeper ; + dataDir = "/opt/nix-module/data/zookeeper" ; + } ; + + services.apache-kafka = { + enable = true ; + package = pkgs.apacheKafka ; + logDirs = [ "/opt/nix-module/data/kafka" ] ; + zookeeper = "localhost:2181" ; + extraProperties = '' + offsets.topic.replication.factor = 1 + zookeeper.session.timeout.ms = 600000 + '' ; + } ; + + services.confluent-schema-registry = { + enable = true ; + package = pkgs.confluent-platform ; + kafkas = [ "PLAINTEXT://localhost:9092" ] ; + } ; +}