FROM mcr.microsoft.com/vscode/devcontainers/universal:1-${VARIANT} as BASE
RUN sh <(curl -L https://nixos.org/nix/install) --no-daemon
RUN mkdir -p /home/codespace/.config/nixpkgs && echo '{ allowUnfree = true; }' >> /home/codespace/.config/nixpkgs/config.nix
RUN echo '. /home/codespace/.nix-profile/etc/profile.d/nix.sh' >> /home/codespace/.bashrc
# Install git
RUN . /home/codespace/.nix-profile/etc/profile.d/nix.sh \
&& nix-env -i git git-lfs
# This requires dotnet install so bypassing as not critical
# RUN HOMEBREW_NO_AUTO_UPDATE=1 brew install gitversion
# Install direnv
RUN . /home/codespace/.nix-profile/etc/profile.d/nix.sh \
&& nix-env -i direnv \
&& direnv hook bash >> /home/codespace/.bashrc \
&& direnv allow
I'll eventually replace the customization with chezmoi init
and ensure nix is loaded in my dotfiles.
My default.nix
file is:
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
curl
git
htop
build-essential
file
gcc
tree
wget
unzip
pv
go
git-town
hugo
chezmoi
nodejs
nixfmt
];
# pkgs.mkShell { <--- how do I configure these as requiring installation outside of my nix-shell?
# buildInputs = [
# nixpkgs.go
# nixpkgs.git-town
# nixpkgs.hugo
# nixpkgs.chezmoi
# nixpkgs.nodejs
# nixpkgs.nixfmt
# ];
}
I also setup .envrc
use nix
and then loaded my profile with . /home/codespace/.nix-profile/etc/profile.d/nix.sh
.
After having run direnv allow
, it loaded correctly.
How do I do the equivalent of:
RUN nix-env -iA nixpkgs.go \
&& nix-env -iA nixpkgs.git-town \
&& nix-env -iA nixpkgs.hugo \
&& nix-env -iA nixpkgs.chezmoi \
&& nix-env -iA nixpkgs.nodejs
into a command that would load this?
RUN nix-env install default.nix
This woudld give me flexibility to run local or in a container with the same packages getting setup and also simplify my Dockerfiles.