{ description = "Development environment for nix'ing with triton"; inputs.devshell.url = "github:numtide/devshell"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; inputs.nixpkgsFork.url = "github:teutat3s/nixpkgs/feature/triton-completion"; inputs.nixpkgs20-09.url = "github:nixos/nixpkgs/release-20.09"; outputs = { self, flake-utils, devshell, nixpkgs, nixpkgsFork, nixpkgs20-09 }: flake-utils.lib.eachDefaultSystem (system: { packages.triton-utils = let pkgs = import nixpkgs { inherit system; }; in pkgs.stdenv.mkDerivation { pname = "triton-utils"; version = "0.0.1"; src = pkgs.lib.cleanSource ./.; installPhase = '' mkdir -p $out/bin $out/share/certs cd ./utils cp ./cacert-2021-10-26.pem $out/share/certs cp ./triton-docker.env.sh $out/bin cp ./ttp.sh $out/bin cp ./unset-env.sh $out/bin ''; }; devShell = let pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; }; pkgsFork = import nixpkgsFork { inherit system; overlays = [ devshell.overlay ]; }; pkgs20-09 = import nixpkgs20-09 { inherit system; overlays = [ devshell.overlay ]; }; in pkgs.devshell.mkShell { 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 = pkgsFork.nodePackages.triton; category = "triton & manta tools"; name = "triton"; help = "Triton DC CLI (https://docs.joyent.com/public-cloud/api/triton-cli)"; } { package = pkgsFork.nodePackages.manta; category = "triton & manta tools"; name = "manta"; help = "Manta CLI (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 self.packages.${system}.triton-utils ]; 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 = "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 ''; }; }; }); }