2022-10-12 11:01:33 +00:00
|
|
|
{ config, devshell, pkgs, self, system, ... }:
|
|
|
|
let
|
|
|
|
tritonConfig = config.environment;
|
|
|
|
cnsBaseDomain = tritonConfig.cnsBaseDomain;
|
|
|
|
dataCenters = tritonConfig.dataCenters;
|
|
|
|
mantaDomain = tritonConfig.mantaDomain;
|
|
|
|
tritonApiDomain = tritonConfig.tritonApiDomain;
|
|
|
|
in
|
2022-10-11 08:44:32 +00:00
|
|
|
{
|
2022-02-01 00:59:09 +00:00
|
|
|
# devshell docs: https://numtide.github.io/devshell/modules_schema.html
|
|
|
|
name = "tritonshell";
|
|
|
|
|
|
|
|
devshell.interactive = {
|
|
|
|
PS1_util = pkgs.lib.noDepEntry ''
|
|
|
|
if [[ -n "''${PRJ_ROOT:-}" ]]; then
|
|
|
|
# Print the path relative to $PRJ_ROOT
|
|
|
|
rel_root() {
|
|
|
|
local path
|
|
|
|
path=$(${pkgs.coreutils}/bin/realpath --relative-to "$PRJ_ROOT" "$PWD")
|
|
|
|
if [[ $path != . ]]; then
|
|
|
|
echo " $path "
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# If PRJ_ROOT is unset, print only the current directory name
|
|
|
|
rel_root() {
|
|
|
|
echo " \W "
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
PS1.text = ''
|
2022-02-01 03:04:42 +00:00
|
|
|
PS1='\[\033[38;5;202m\][$SDC_ACCOUNT@$TRITON_DC]$(rel_root)\$ \[\033[0m\]'
|
2022-02-01 00:59:09 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
commands = [
|
|
|
|
{
|
2022-02-22 14:09:03 +00:00
|
|
|
package = pkgs.nodePackages.triton;
|
2022-02-01 00:59:09 +00:00
|
|
|
category = "triton & manta tools";
|
|
|
|
name = "triton";
|
2022-02-22 14:09:03 +00:00
|
|
|
help = "Triton DC CLI (https://docs.greenbaum.cloud/en/devops/triton-cli.html)";
|
2022-02-01 00:59:09 +00:00
|
|
|
}
|
|
|
|
{
|
2022-02-22 14:09:03 +00:00
|
|
|
package = pkgs.nodePackages.manta;
|
2022-02-01 00:59:09 +00:00
|
|
|
category = "triton & manta tools";
|
|
|
|
name = "manta";
|
|
|
|
help = "Manta CLIs (https://apidocs.joyent.com/manta/index.html#cli)";
|
|
|
|
}
|
2022-02-22 14:08:29 +00:00
|
|
|
{
|
|
|
|
package = self.packages.${system}.triton-utils;
|
|
|
|
category = "triton & manta tools";
|
|
|
|
name = "ttp";
|
|
|
|
help = "Quickly switch triton profiles (shell function)";
|
|
|
|
}
|
2022-02-01 00:59:09 +00:00
|
|
|
];
|
|
|
|
|
2022-06-09 12:25:46 +00:00
|
|
|
devshell.packages = with pkgs; [
|
|
|
|
bash-completion
|
2022-02-01 00:59:09 +00:00
|
|
|
# use docker-compose version 1.26.2 for best triton API compatibility
|
2022-06-09 12:25:46 +00:00
|
|
|
# see overlay.nix
|
|
|
|
docker-compose_1
|
2022-03-02 23:34:18 +00:00
|
|
|
# shell scripts and utilities to set and unset triton environment variables
|
2022-11-27 20:30:47 +00:00
|
|
|
self.packages.${system}.triton-utils
|
2022-03-02 23:34:18 +00:00
|
|
|
self.packages.${system}.triton-docker-env
|
|
|
|
# useful for working with JSON data
|
2022-06-09 12:25:46 +00:00
|
|
|
bunyan-rs
|
2022-10-12 11:01:33 +00:00
|
|
|
jq
|
|
|
|
nodePackages.json
|
2022-10-11 08:44:32 +00:00
|
|
|
];
|
2022-02-01 00:59:09 +00:00
|
|
|
|
|
|
|
env = [
|
|
|
|
# workaround for TLS certs bug in docker-compose, CERTIFICATE_VERIFY_FAILED
|
|
|
|
# see: https://github.com/joyent/triton-docker-cli/issues/17
|
|
|
|
{
|
|
|
|
name = "CURL_CA_BUNDLE";
|
2022-11-27 20:30:47 +00:00
|
|
|
value = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
2022-02-01 00:59:09 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "CONSUL_HTTP_ADDR";
|
2022-08-10 10:03:55 +00:00
|
|
|
value = "http://consul.service.cgn-1.consul:8500";
|
2022-02-01 00:59:09 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "NOMAD_ADDR";
|
|
|
|
value = "https://nomad.service.consul:4646";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "VAULT_ADDR";
|
2022-02-28 15:19:35 +00:00
|
|
|
value = "https://vault.service.consul:8200";
|
2022-02-01 00:59:09 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
bash = {
|
|
|
|
extra = ''
|
2022-10-12 11:01:33 +00:00
|
|
|
export \
|
|
|
|
TRITONSHELL_CNS_BASE_DOMAIN=${cnsBaseDomain} \
|
2022-11-25 15:08:16 +00:00
|
|
|
TRITONSHELL_DATA_CENTERS="${pkgs.lib.concatStringsSep " " dataCenters}" \
|
2022-10-12 11:01:33 +00:00
|
|
|
TRITONSHELL_MANTA_DOMAIN=${mantaDomain} \
|
|
|
|
TRITONSHELL_TRITON_API_DOMAIN=${tritonApiDomain}
|
2022-08-14 20:31:58 +00:00
|
|
|
if [ -z "$TRITON_DONT_SOURCE_PROFILE" ]; then
|
|
|
|
source ${self.packages.${system}.triton-docker-env}/bin/triton-docker-env.sh
|
|
|
|
source ${self.packages.${system}.triton-utils}/bin/ttp.sh
|
|
|
|
fi
|
2022-02-01 00:59:09 +00:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
source $DEVSHELL_DIR/share/bash-completion/bash_completion
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|