Skip to content

Refactor playbook to use nix - #23

Open
capsulecorplab wants to merge 70 commits into
mainfrom
refactor-playbook-to-use-nix
Open

capsulecorplab wants to merge 70 commits into
mainfrom
refactor-playbook-to-use-nix

Conversation

@capsulecorplab

@capsulecorplab capsulecorplab commented Mar 14, 2025 •

Copy link
Copy Markdown
Member

This PR replaces apt-installed packages with nix installed packages.

closes #11

Dev notes

In order to get nix installed in kasm, I ran the nix installer in single-user mode as to avoid having to run the daemon during buildtime of the image. Since nix installer complains if you're installing as root in single-user mode, I had to create a nixbld group and added a dummy dev user to that group to silence the nix installer (See NixOS/nix#1559). Also, since the host machine is Ubuntu, I had to dynamically unset LD_LIBRARY_PATH during build time of the image in order to circumvent the OPENSSL_3.4.0 and GLIBC-related errors (Apparently, nix uses its own implementation of GLIBC that encounters incompatibilities with non-NixOS host machines. See NixOS/nixpkgs#327854). Likewise, I had to update /etc/profile to unset LD_LIBRARY_PATH for the runtime of the container, as well as update PATH to include the nix bin directory (technically, a directory of symlinks to the actual hashed binaries) for users of the container to be able to access nix-installed packages.

@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 84310ff to 18326b6 Compare March 18, 2025 20:15
as per https://zero-to-nix.com/start/install/

- run nix-installer with --no-confirm
@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 18326b6 to 3357c1d Compare March 18, 2025 20:22
@capsulecorplab

capsulecorplab commented Nov 18, 2025 •

Copy link
Copy Markdown
Member Author

Finally installed nix as of 936cc2a !
Screenshot from 2025-11-18 13-05-36

EDIT (for posterity): Abandoning nix-bin installation approach, as I can't seem to install keychain; encountering incompatibility issues between nix and host glibc.

@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 70cc8ff to bec8470 Compare November 19, 2025 01:42
@capsulecorplab

Copy link
Copy Markdown
Member Author

git installed with nix as of bec8470
Screenshot from 2025-11-18 19-04-27

@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 40baad6 to bd478b4 Compare November 20, 2025 06:15
@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 2cf2f04 to 1e359a3 Compare May 28, 2026 02:25
@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from 1e359a3 to 9821994 Compare May 28, 2026 02:31
@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from a23247f to 62ef4fb Compare October 23, 2026 20:45
@capsulecorplab

Copy link
Copy Markdown
Member Author

Encountering /nix/store/.../bin/nix-store: /usr/lib/x86_64-linux-gnu/libcrypto.so.3: version 'OPENSSL_3.4.0' not found (required by /nix/store/.../lib/libs2n.so.1) error as of nix version 2.35.3. See https://github.com/LearnTeachCode/ltc-workspace/actions/runs/40022750655/job/120651186020 triggered from 590956e

@capsulecorplab
capsulecorplab marked this pull request as draft October 23, 2026 23:39
@capsulecorplab

Copy link
Copy Markdown
Member Author

Giving up for now; opened an issue at NixOS/nix#16668

@capsulecorplab

Copy link
Copy Markdown
Member Author

Upon input from NixOS/nix#16668 (comment), I unset LD_LIBRARY_PATH using approach in d8fef4e, but now get error: the group 'nixbld' specified in 'build-users-group' does not exist (See https://github.com/LearnTeachCode/ltc-workspace/actions/runs/40045277084/job/120725467328)

@capsulecorplab

Copy link
Copy Markdown
Member Author

Upon input from NixOS/nix#16668 (comment), I unset LD_LIBRARY_PATH using approach in d8fef4e, but now get error: the group 'nixbld' specified in 'build-users-group' does not exist (See https://github.com/LearnTeachCode/ltc-workspace/actions/runs/40045277084/job/120725467328)

This seems relevant NixOS/nix#1559

@xokdvium

Copy link
Copy Markdown

This seems relevant NixOS/nix#1559

If you are running Nix as root, you need build users for privilege separation.

@capsulecorplab

capsulecorplab commented Oct 24, 2026 •

Copy link
Copy Markdown
Member Author

This seems relevant NixOS/nix#1559

If you are running Nix as root, you need build users for privilege separation.

Ah, thank you! How do I go about setting up a build user?

EDIT: Nevermind, I think it's just groupadd nixbld and usermod -aG nixbld dev

…bld group

rearranges setup/teardown of dev (user) to be able to add to nixbld group
- dynamically unset LD_LIBRARY_PATH per nix-related operation (i.e., installation of nix and nix packages) at buildtime of kasm container
- test nix-installed git and keychain versions at buildtime of kasm container
- unset LD_LIBRARY_PATH and add nix bin directory to PATH in /etc/profile for system-wide access to nix-installed binaries at runtime of kasm container
@capsulecorplab
capsulecorplab force-pushed the refactor-playbook-to-use-nix branch from e82a0bc to 2af639d Compare October 25, 2026 01:51
@capsulecorplab

Copy link
Copy Markdown
Member Author

Installed nix and nix packages as of 2af639d!!
Screenshot from 2026-10-24 19-21-02

@capsulecorplab
capsulecorplab marked this pull request as ready for review October 25, 2026 02:24

@E-A-N E-A-N left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing jumps out at me, the pipelines are passing, and I can follow your commits. Although I haven't tested myself. Maybe on a project I were serious about I'd suggest storing your commits in another branch then squashing the commits in this branch before merging, coupled with a comprehensive description of your PR. But honestly it all looks good to me in any case!

From Discord

Comment thread playbook.yaml Outdated
@xokdvium

Copy link
Copy Markdown

EDIT: Nevermind, I think it's just groupadd nixbld and usermod -aG nixbld dev

Note that the build users are special and shouldn't be used by any other program. Nix will regularly kill all processes running as the build user via kill(-1, SIGKILL). Also the number of build users determines the maximum number of concurrent builds so if you intend to do any builds you better get a couple more.

@capsulecorplab

Copy link
Copy Markdown
Member Author

EDIT: Nevermind, I think it's just groupadd nixbld and usermod -aG nixbld dev

Note that the build users are special and shouldn't be used by any other program. Nix will regularly kill all processes running as the build user via kill(-1, SIGKILL). Also the number of build users determines the maximum number of concurrent builds so if you intend to do any builds you better get a couple more.

Ah, good to know! For now, we're just using nix as a package manager. If we need to do any builds that require more builders, we can always open another PR.

capsulecorplab added a commit to solarpunkhomestead/solarpunk-workspace that referenced this pull request Oct 25, 2026
…pt from unpacked tarball

Uses workaround for circumventing GLIBC incompatibilities between nix and non-NixOS host machine by unsetting LD_LIBRARY_PATH

See LearnTeachCode/ltc-workspace#23
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.

refactor playbook.yaml to install packages using nix (package manager)

3 participants