FROM nixos/nix:latest

# Install dependencies
RUN nix-env -iA nixpkgs.colmena nixpkgs.sops nixpkgs.age nixpkgs.yq nixpkgs.jq nixpkgs TMPEXIT=0

# Create directories
RUN mkdir -p /workspace /etc/sops/keys

# Copy files at build time (these will be part of the image)
COPY . /workspace/
COPY age.key /etc/sops/keys/age.key

# Set working directory
WORKDIR /workspace

# Set environment variables
ENV NIX_CONFIG_DIR=/root/.config/nix
ENV SOPS_AGE_KEY_FILE=/etc/sops/keys/age.key

# Create nix.conf
RUN mkdir -p /root/.config/nix && \
    echo "experimental-features = nix-command flakes" > /root/.config/nix/nix.conf

# Make age.key readable
RUN chmod 600 /etc/sops/keys/age.key

CMD ["bash"]
