Installing Nix on Crostini: Difference between revisions

From NixOS Wiki
imported>Thiagokokada
Add nixGL instructions
imported>Thiagokokada
No edit summary
Line 25: Line 25:
[Service]
[Service]
Environment="PATH=%h/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/local/games:/usr/sbin:/usr/bin:/usr/games:/sbin:/bin"
Environment="PATH=%h/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/local/games:/usr/sbin:/usr/bin:/usr/games:/sbin:/bin"
Environment="XDG_DATA_DIRS=%h/.nix-profile/share:%h/.local/share:/usr/local/share:/usr/share"
Environment="XDG_DATA_DIRS=%h/.nix-profile/share:%h/.local/share:%h/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share"
EOF
</pre>
</pre>



Revision as of 11:51, 4 January 2024

This Wiki page describes the process required to get up and running on Chrome OS within Crostini. This does not talk about Crouton and assumes you have already installed Nix. Guide to Installation.

Once you have Nix installed, there are a few things that need to be done.

Home-Manager

Using Home-manager is pretty straight-forward, and is an easy way to manage Nix and install packages. The documentation on the Github repo is sufficient.

Registering Applications with Chrome OS

This feature of Crostini expects .desktop files to be dropped in the appropriate places. (namely somewhere under $XDG_DATA).

Applications are registered with Chrome OS using a service running within the container called cros-garcon. As it is a simple systemd service, we can easily extend it to look in nix-specific locations.

First we extend the service with new environment variables

mkdir -p ~/.config/systemd/user/cros-garcon.service.d/

followed by.

cat > ~/.config/systemd/user/cros-garcon.service.d/override.conf <<EOF
[Service]
Environment="PATH=%h/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/local/games:/usr/sbin:/usr/bin:/usr/games:/sbin:/bin"
Environment="XDG_DATA_DIRS=%h/.nix-profile/share:%h/.local/share:%h/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share"

Then we need to restart our container. I found restarting the whole laptop to be the easiest and most effective method.

After this, we can simply start adding GUI packages to our home-manager configuration. Alternatively, if we are not using home-manager, then we can directly install packages:

nix-env -i slack

Note: These instructions were adapted from the following post on Reddit

Graphical applications

Thanks to the usage of VirtGL as the GPU driver, you can easily run applications that depend on OpenGL/Vulkan by using NixGL:

nix run --impure github:guibou/nixGL -- program