Skip to content

Commit

Permalink
Merge pull request #788 from ankhers/init_cockroachdb_service
Browse files Browse the repository at this point in the history
Init CockroachDB Service
  • Loading branch information
domenkozar authored Aug 14, 2023
2 parents 507bdca + 2007303 commit 8cb67d4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/cockroachdb/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ ... }:

{
services.cockroachdb = {
enable = true;
};
}
3 changes: 3 additions & 0 deletions examples/cockroachdb/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
43 changes: 43 additions & 0 deletions src/modules/services/cockroachdb.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ pkgs, lib, config, ... }:

let
cfg = config.services.cockroachdb;
types = lib.types;
in
{
options.services.cockroachdb = {
enable = lib.mkEnableOption ''
Add CockroachDB process.
'';

listen_addr = lib.mkOption {
type = types.str;
default = "localhost:26257";
description = ''
The address/hostname and port to listen on.
'';
};

http_addr = lib.mkOption {
type = types.str;
default = "localhost:8080";
description = ''
The hostname or IP address to bind to for HTTP requests.
'';
};

package = lib.mkOption {
default = pkgs.cockroachdb-bin;
};
};

config = lib.mkIf cfg.enable {
packages = [ cfg.package ];

env.COCKROACH_DATA = config.env.DEVENV_STATE + "/cockroachdb";

processes.cockroachdb = {
exec = "${cfg.package}/bin/cockroachdb start-single-node --insecure --listen-addr=${cfg.listen_addr} --http-addr=${cfg.http_addr} --store=path=$COCKROACH_DATA";
};
};
}

0 comments on commit 8cb67d4

Please sign in to comment.