109 lines
3.1 KiB
Nix
109 lines
3.1 KiB
Nix
{ config, devshell, pkgs, self, system, ... }:
|
|
let
|
|
tritonConfig = config.environment;
|
|
cnsBaseDomain = tritonConfig.cnsBaseDomain;
|
|
dataCenters = tritonConfig.dataCenters;
|
|
mantaDomain = tritonConfig.mantaDomain;
|
|
tritonApiDomain = tritonConfig.tritonApiDomain;
|
|
in
|
|
{
|
|
# 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 = ''
|
|
PS1='\[\033[38;5;202m\][$SDC_ACCOUNT@$TRITON_DC]$(rel_root)\$ \[\033[0m\]'
|
|
'';
|
|
};
|
|
|
|
commands = [
|
|
{
|
|
package = pkgs.nodePackages.triton;
|
|
category = "triton & manta tools";
|
|
name = "triton";
|
|
help = "Triton DC CLI (https://docs.greenbaum.cloud/en/devops/triton-cli.html)";
|
|
}
|
|
{
|
|
package = pkgs.nodePackages.manta;
|
|
category = "triton & manta tools";
|
|
name = "manta";
|
|
help = "Manta CLIs (https://apidocs.joyent.com/manta/index.html#cli)";
|
|
}
|
|
{
|
|
package = self.packages.${system}.triton-utils;
|
|
category = "triton & manta tools";
|
|
name = "ttp";
|
|
help = "Quickly switch triton profiles (shell function)";
|
|
}
|
|
];
|
|
|
|
devshell.packages = with pkgs; [
|
|
bash-completion
|
|
# use docker-compose version 1.26.2 for best triton API compatibility
|
|
# see overlay.nix
|
|
docker-compose_1
|
|
# shell scripts and utilities to set and unset triton environment variables
|
|
self.packages.${system}.triton-utils
|
|
self.packages.${system}.triton-docker-env
|
|
# useful for working with JSON data
|
|
bunyan-rs
|
|
jq
|
|
nodePackages.json
|
|
];
|
|
|
|
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";
|
|
value = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
}
|
|
{
|
|
name = "CONSUL_HTTP_ADDR";
|
|
value = "http://consul.service.cgn-1.consul:8500";
|
|
}
|
|
{
|
|
name = "NOMAD_ADDR";
|
|
value = "https://nomad.service.consul:4646";
|
|
}
|
|
{
|
|
name = "VAULT_ADDR";
|
|
value = "https://vault.service.consul:8200";
|
|
}
|
|
];
|
|
|
|
bash = {
|
|
extra = ''
|
|
export \
|
|
TRITONSHELL_CNS_BASE_DOMAIN=${cnsBaseDomain} \
|
|
TRITONSHELL_DATA_CENTERS="${pkgs.lib.concatStringsSep " " dataCenters}" \
|
|
TRITONSHELL_MANTA_DOMAIN=${mantaDomain} \
|
|
TRITONSHELL_TRITON_API_DOMAIN=${tritonApiDomain}
|
|
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
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
source $DEVSHELL_DIR/share/bash-completion/bash_completion
|
|
fi
|
|
'';
|
|
};
|
|
}
|