Last active
April 28, 2025 02:52
-
-
Save mgreenly/3d65e1336b8c8adb417afe0ae8b636c4 to your computer and use it in GitHub Desktop.
nix-docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nixos/nix AS build | |
RUN nix-channel --update | |
# Build a profile and package store in the /scratch directory. Only the files we install | |
# during this docker build will end up in this profile. | |
RUN mkdir -p /scratch/store | |
# Install all desired packages into the scratch profile. It's important to know that the | |
# packages themselve are installed in /nix/store during this step and the /scratch/profile | |
# simply symlinks to them. | |
RUN nix-env --profile /scratch/profile -i cowsay | |
# Now copy all the files associated with /scratch/profile into /scratch/store. | |
RUN cp -va $(nix-store -qR scratch/profile) /scratch/store | |
FROM scratch | |
# Copy the /scratch directory created above to /nix, fixing the symlinks. | |
COPY --from=build /scratch/profile /nix/profile | |
COPY --from=build /scratch/store /nix/store | |
ENV PATH=/nix/profile/bin:$PATH | |
CMD ["cowsay", "moooooo!!!"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment