Skip to content

fix: separate dev shell and dev image nix deps #9189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
bash
cairo
curl
docker
drpc.defaultPackage.${system}
exa
gcc
getopt
git
Expand All @@ -35,9 +33,9 @@
gotestsum
jq
kubernetes-helm
less
mockgen
nfpm
nix
nodejs
nodePackages.pnpm
nodePackages.prettier
Expand All @@ -52,7 +50,6 @@
protobuf
protoc-gen-go
ripgrep
screen
shellcheck
shfmt
sqlc
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -153,6 +159,13 @@
experimental-features = nix-command flakes
''
)
# Allow people to change shells!
(
pkgs.writeTextDir "etc/shells" ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need slash?

Suggested change
pkgs.writeTextDir "etc/shells" ''
pkgs.writeTextDir "/etc/shells" ''

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it adds that automatically

${pkgs.bash}/bin/bash
${pkgs.zsh}/bin/zsh
''
)
# This is the debian script for managing Docker with `sudo service docker ...`.
(
pkgs.writeTextFile {
Expand Down Expand Up @@ -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; };
}
);
}
}
);
}