From 9725ec071305c876b553e8cd46485af44733f177 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 18 Aug 2023 10:58:52 -0500 Subject: [PATCH] fix: separate dev shell and dev image nix deps (#9189) * fix: separate dev shell and dev image nix deps * Add less --- flake.nix | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index d48ce8d0aa..5883d218b4 100644 --- a/flake.nix +++ b/flake.nix @@ -19,9 +19,7 @@ bash cairo curl - docker drpc.defaultPackage.${system} - exa gcc getopt git @@ -35,9 +33,9 @@ gotestsum jq kubernetes-helm + less mockgen nfpm - nix nodejs nodePackages.pnpm nodePackages.prettier @@ -52,7 +50,6 @@ protobuf protoc-gen-go ripgrep - screen shellcheck shfmt sqlc @@ -67,6 +64,15 @@ zsh zstd ]; + # We separate these to reduce the size of the dev shell for packages that we only + # want in the image. + devImagePackages = with pkgs; [ + docker + exa + nix + nixpkgs-fmt + screen + ]; # This is the base image for our Docker container used for development. # Use `nix-prefetch-docker ubuntu --arch amd64 --image-tag lunar` to get this. @@ -102,7 +108,7 @@ # Environment variables that live in `/etc/environment` in the container. # These will also be applied to the container config. devEnvVars = [ - "PATH=${pkgs.lib.makeBinPath devShellPackages}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/coder/go/bin" + "PATH=${pkgs.lib.makeBinPath (devShellPackages ++ devImagePackages)}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/coder/go/bin" # This setting prevents Go from using the public checksum database for # our module path prefixes. It is required because these are in private # repositories that require authentication. @@ -153,6 +159,13 @@ experimental-features = nix-command flakes '' ) + # Allow people to change shells! + ( + pkgs.writeTextDir "etc/shells" '' + ${pkgs.bash}/bin/bash + ${pkgs.zsh}/bin/zsh + '' + ) # This is the debian script for managing Docker with `sudo service docker ...`. ( pkgs.writeTextFile { @@ -189,19 +202,19 @@ cp -a ${pkgs.glibcLocales}/lib/locale/locale-archive usr/lib/locale/locale-archive ''; - config = { - Env = devEnvVars; - Entrypoint = [ "/bin/bash" ]; - User = "coder"; + config = { + Env = devEnvVars; + Entrypoint = [ "/bin/bash" ]; + User = "coder"; + }; }; - }; - in - { + in + { packages = { devEnvImage = devEnvImage; }; defaultPackage = formatter; # or replace it with your desired default package. devShell = pkgs.mkShell { buildInputs = devShellPackages; }; - } - ); - } + } + ); +}