Pin Nix channels and install cachix

This commit is contained in:
Qingsong Chen 2025-12-09 03:08:45 +00:00 committed by Tate, Hongliang Tian
parent dbba54b02c
commit d6ef1d143a
2 changed files with 7 additions and 3 deletions

View File

@ -7,15 +7,18 @@ SHELL ["/bin/bash", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
# Install Nix package manager
# Install Nix package manager and other Nix tools
#
# The nixpkgs and nixos channels are pinned to a particular commit (NixOS 25.05, 2025-07-01) for reproducibility.
# FIXME: Installing Nix as root is not supported in single-user mode.
RUN sh <(curl -L https://nixos.org/nix/install) --daemon --yes \
&& . /etc/profile.d/nix.sh \
&& nix-channel --add https://nixos.org/channels/nixos-25.05 nixpkgs \
&& nix-channel --add https://nixos.org/channels/nixos-25.05 nixos \
&& nix-channel --add https://github.com/NixOS/nixpkgs/archive/c0bebd16e69e631ac6e52d6eb439daba28ac50cd.tar.gz nixpkgs \
&& nix-channel --add https://github.com/NixOS/nixpkgs/archive/c0bebd16e69e631ac6e52d6eb439daba28ac50cd.tar.gz nixos \
&& nix-channel --update \
&& nix-env -iA nixpkgs.nixfmt \
&& nix-env -iA nixpkgs.nixos-install-tools \
&& nix-env -iA cachix -f https://cachix.org/api/v1/install \
&& rm /nix/var/nix/gcroots/auto/* \
&& nix-collect-garbage -d

View File

@ -85,6 +85,7 @@ cp ${DISTRO_DIR}/aster_configuration.nix ${BUILD_DIR}/etc/nixos
cp -r ${DISTRO_DIR}/modules ${BUILD_DIR}/etc/nixos
cp -r ${DISTRO_DIR}/overlays ${BUILD_DIR}/etc/nixos
export PATH=${PATH}:/run/current-system/sw/bin
nixos-install --root ${BUILD_DIR} --no-root-passwd
echo "Congratulations! Asterinas NixOS has been installed successfully!"