Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nix sandbox #1585

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions contrib/nix/README.md
Original file line number Diff line number Diff line change
@@ -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 '<home-manager>' -A install
```

3. setup environment, and well done!
```
export NIX_PATH=~/.nix-defexpr/channels
home-manager -I home-manager=<home-manager> -f sandbox.nix switch
```
80 changes: 80 additions & 0 deletions contrib/nix/sandbox.nix
Original file line number Diff line number Diff line change
@@ -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" ] ;
} ;
}