From f74ffebc23306f5dec7380d71db2c8634e65acce Mon Sep 17 00:00:00 2001 From: jhonas Date: Tue, 11 Oct 2022 10:44:32 +0200 Subject: [PATCH] Fix infinite recursion with pkgs.devshell.mkShell --- template/flake.nix | 91 ++++++++++++++++------------------------ template/tritonshell.nix | 6 +-- 2 files changed, 40 insertions(+), 57 deletions(-) diff --git a/template/flake.nix b/template/flake.nix index 222a5c5..6a59439 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -12,63 +12,46 @@ "x86_64-darwin" "x86_64-linux" ] - (system: - let - pkgs = import nixpkgs { - inherit system; - }; - in - { + ( + system: + let + pkgs = import nixpkgs { + inherit system; + + overlays = [ + devshell.overlay + (import ./overlay.nix) + ]; + }; + in + { devshellModules.tritonshell = { config, lib, ... }: { options.environment = { - enable = lib.mkEnableOption "environment"; - # TODO: add real config here + enable = lib.mkEnableOption "triton DevOps shell environment"; }; + config = - # TODO: set some devshell config here, like add a new command - let - pkgs = import nixpkgs { - inherit system; - - overlays = [ - devshell.overlay - (import ./overlay.nix) - ]; - }; - - # HINT: add your extra devshell pkgs here, use any packages you want - # available in your devshell's PATH - # Use https://search.nixos.org/packages to find available packages - # in the unstable channel - # These get appended to devshell.packages in ./tritonshell.nix - extraDevshellPkgs = with pkgs; [ - #hello - ]; - - in - lib.optionalAttrs config.environment.enable { - devShells.default = - (import ./tritonshell.nix { inherit extraDevshellPkgs devshell pkgs self system; }); - }; + lib.mkIf config.environment.enable (import ./tritonshell.nix { inherit devshell pkgs self system; }); + }; + # Internal utility package with shell function and env vars helper. + # These get source'd in devshell.bash.extra when starting tritonshell + packages = { + triton-utils = import ./pkgs/triton-utils.nix { inherit pkgs; }; + triton-docker-env = + let + # CUSTOMIZE: + # variables used to set triton env vars in tritonshell + # adjust to suit your Triton Data Center setup + # take a look at ./pkgs/triton-docker-env-shell.nix to see how these get used + cnsBaseDomain = "greenbaum.zone"; + dataCenters = [ "cgn-1" "lev-1" ]; + mantaDomain = "eu-central.manta.greenbaum.cloud"; + tritonApiDomain = "api.greenbaum.cloud"; + in + import ./pkgs/triton-docker-env.nix { + inherit pkgs cnsBaseDomain dataCenters mantaDomain tritonApiDomain; }; - # Internal utility package with shell function and env vars helper. - # These get source'd in devshell.bash.extra when starting tritonshell - packages = { - triton-utils = import ./pkgs/triton-utils.nix { inherit pkgs; }; - triton-docker-env = - let - # CUSTOMIZE: - # variables used to set triton env vars in tritonshell - # adjust to suit your Triton Data Center setup - # take a look at ./pkgs/triton-docker-env-shell.nix to see how these get used - cnsBaseDomain = "greenbaum.zone"; - dataCenters = [ "cgn-1" "lev-1" ]; - mantaDomain = "eu-central.manta.greenbaum.cloud"; - tritonApiDomain = "api.greenbaum.cloud"; - in - import ./pkgs/triton-docker-env.nix { - inherit pkgs cnsBaseDomain dataCenters mantaDomain tritonApiDomain; - }; - }; - }); + }; + } + ); } diff --git a/template/tritonshell.nix b/template/tritonshell.nix index f0f47dd..fd52f79 100644 --- a/template/tritonshell.nix +++ b/template/tritonshell.nix @@ -1,5 +1,5 @@ -{ extraDevshellPkgs, devshell, pkgs, self, system, ... }: -pkgs.devshell.mkShell { +{ devshell, pkgs, self, system, ... }: +{ # devshell docs: https://numtide.github.io/devshell/modules_schema.html name = "tritonshell"; @@ -62,7 +62,7 @@ pkgs.devshell.mkShell { # useful for working with JSON data jq bunyan-rs - ] ++ extraDevshellPkgs; + ]; env = [ # workaround for TLS certs bug in docker-compose, CERTIFICATE_VERIFY_FAILED