Skip to content

Conversation

@RyzeNGrind
Copy link

@RyzeNGrind RyzeNGrind commented May 3, 2025

Problem:

The Nix environment within the devcontainer sometimes fails to initialize correctly, particularly regarding script paths, user profiles (especially for root), and permissions (e.g., tmp ACLs affecting builds). This can lead to a non-functional Nix shell or errors during container startup or build processes.

Solution:

This PR overhauls the Nix environment setup for increased robustness:

  1. Introduced entrypoint.sh:
    • Resets tmp ACLs to prevent Nix build permission issues.
    • Ensures Nix profile/channels are initialized for the root user at runtime if needed.
    • Handles nix-daemon startup for multi-user mode.
    • Integrates direnv activation directly into the container startup flow.
  2. Dockerfile Refinements:
    • Added explicit Nix profile/channel initialization for root during the image build.
    • Created a symbolic link (/library-scripts) to ensure library-scripts are consistently found.
    • Updated user/group permissions and sudoers configuration.
  3. Devcontainer Configuration:
    • Updated docker-compose.yml to build the image using the local Dockerfile context.
    • Adjusted devcontainer.json to use the new entrypoint and configurations.
  4. Code Quality:
    • Added comments explaining key changes in Dockerfiles and scripts.
    • Formatted all .nix files using alejandra.

Testing:

  • Tested in GitHub Codespaces, resulting in a functional Nix shell and successful container startup.
  • Verified that direnv activates correctly when an .envrc is present.

Note:

These changes primarily address issues encountered for my specific use case but should provide a more reliable base Nix environment for all users of this devcontainer. The commit history has been cleaned and follows Conventional Commits.

Fixes GH Issue #56

@lucernae
Copy link
Owner

Oh hi @RyzeNGrind , very sorry that I didn't see it soon.
Do you still interested in contributing? I think most files already refactored to build the latest stable 25.05.
So your PR at the moment will mostly have conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants