90 lines
2.5 KiB
Nix
90 lines
2.5 KiB
Nix
|
{ extraDevshellPkgs, devshell, pkgs, pkgsUnstable, pkgs20-09, self, system, ... }:
|
||
|
pkgs.devshell.mkShell {
|
||
|
# 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\][$TRITON_PROFILE@tritonshell]$(rel_root)\$ \[\033[0m\]'
|
||
|
'';
|
||
|
};
|
||
|
|
||
|
commands = [
|
||
|
{
|
||
|
package = pkgs.devshell.cli;
|
||
|
help = "Per project developer environments";
|
||
|
}
|
||
|
{
|
||
|
package = pkgsUnstable.nodePackages.triton;
|
||
|
category = "triton & manta tools";
|
||
|
name = "triton";
|
||
|
help = "Triton DC CLI (https://docs.joyent.com/public-cloud/api/triton-cli)";
|
||
|
}
|
||
|
{
|
||
|
package = pkgsUnstable.nodePackages.manta;
|
||
|
category = "triton & manta tools";
|
||
|
name = "manta";
|
||
|
help = "Manta CLIs (https://apidocs.joyent.com/manta/index.html#cli)";
|
||
|
}
|
||
|
];
|
||
|
|
||
|
devshell.packages = [
|
||
|
pkgs.bash-completion
|
||
|
# use docker-compose version 1.26.2 for best triton API compatibility
|
||
|
pkgs20-09.docker-compose
|
||
|
# used in ./utils/triton-docker.env.sh
|
||
|
pkgs.nodePackages.json
|
||
|
pkgs.bunyan-rs
|
||
|
self.packages.${system}.triton-utils
|
||
|
pkgs.ansible
|
||
|
] ++ extraDevshellPkgs;
|
||
|
|
||
|
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 = "${self.packages.${system}.triton-utils}/share/certs/cacert-2021-10-26.pem";
|
||
|
}
|
||
|
{
|
||
|
name = "CONSUL_HTTP_ADDR";
|
||
|
value = "http://consul.service.consul:8500";
|
||
|
}
|
||
|
{
|
||
|
name = "NOMAD_ADDR";
|
||
|
value = "https://nomad.service.consul:4646";
|
||
|
}
|
||
|
{
|
||
|
name = "VAULT_ADDR";
|
||
|
value = "https://nomad.service.consul:8200";
|
||
|
}
|
||
|
];
|
||
|
|
||
|
bash = {
|
||
|
extra = ''
|
||
|
source ${self.packages.${system}.triton-utils}/bin/triton-docker.env.sh
|
||
|
source ${self.packages.${system}.triton-utils}/bin/ttp.sh
|
||
|
if [ "$(uname)" == "Darwin" ]; then
|
||
|
source $DEVSHELL_DIR/share/bash-completion/bash_completion
|
||
|
fi
|
||
|
'';
|
||
|
};
|
||
|
}
|