Skip to content

Commit 9725ec0

Browse files
authored
fix: separate dev shell and dev image nix deps (#9189)
* fix: separate dev shell and dev image nix deps * Add less
1 parent e94ebea commit 9725ec0

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

flake.nix

+28-15
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
bash
2020
cairo
2121
curl
22-
docker
2322
drpc.defaultPackage.${system}
24-
exa
2523
gcc
2624
getopt
2725
git
@@ -35,9 +33,9 @@
3533
gotestsum
3634
jq
3735
kubernetes-helm
36+
less
3837
mockgen
3938
nfpm
40-
nix
4139
nodejs
4240
nodePackages.pnpm
4341
nodePackages.prettier
@@ -52,7 +50,6 @@
5250
protobuf
5351
protoc-gen-go
5452
ripgrep
55-
screen
5653
shellcheck
5754
shfmt
5855
sqlc
@@ -67,6 +64,15 @@
6764
zsh
6865
zstd
6966
];
67+
# We separate these to reduce the size of the dev shell for packages that we only
68+
# want in the image.
69+
devImagePackages = with pkgs; [
70+
docker
71+
exa
72+
nix
73+
nixpkgs-fmt
74+
screen
75+
];
7076

7177
# This is the base image for our Docker container used for development.
7278
# Use `nix-prefetch-docker ubuntu --arch amd64 --image-tag lunar` to get this.
@@ -102,7 +108,7 @@
102108
# Environment variables that live in `/etc/environment` in the container.
103109
# These will also be applied to the container config.
104110
devEnvVars = [
105-
"PATH=${pkgs.lib.makeBinPath devShellPackages}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/coder/go/bin"
111+
"PATH=${pkgs.lib.makeBinPath (devShellPackages ++ devImagePackages)}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/coder/go/bin"
106112
# This setting prevents Go from using the public checksum database for
107113
# our module path prefixes. It is required because these are in private
108114
# repositories that require authentication.
@@ -153,6 +159,13 @@
153159
experimental-features = nix-command flakes
154160
''
155161
)
162+
# Allow people to change shells!
163+
(
164+
pkgs.writeTextDir "etc/shells" ''
165+
${pkgs.bash}/bin/bash
166+
${pkgs.zsh}/bin/zsh
167+
''
168+
)
156169
# This is the debian script for managing Docker with `sudo service docker ...`.
157170
(
158171
pkgs.writeTextFile {
@@ -189,19 +202,19 @@
189202
cp -a ${pkgs.glibcLocales}/lib/locale/locale-archive usr/lib/locale/locale-archive
190203
'';
191204

192-
config = {
193-
Env = devEnvVars;
194-
Entrypoint = [ "/bin/bash" ];
195-
User = "coder";
196-
};
205+
config = {
206+
Env = devEnvVars;
207+
Entrypoint = [ "/bin/bash" ];
208+
User = "coder";
209+
};
197210
};
198-
in
199-
{
211+
in
212+
{
200213
packages = {
201214
devEnvImage = devEnvImage;
202215
};
203216
defaultPackage = formatter; # or replace it with your desired default package.
204217
devShell = pkgs.mkShell { buildInputs = devShellPackages; };
205-
}
206-
);
207-
}
218+
}
219+
);
220+
}

0 commit comments

Comments
 (0)