I’ve long been a fan of functional programming, so when I learned about NixOS, I just had to try it. I ran into issues installing it on my laptop, though, so I decided it might be best to install its Nix package manager on top of a barebones Arch installation. Before I tried it on my laptop, though, I wanted to play around with it in Docker to get a feel for how it would go.
docker run -it vlpro/arch-yaourt /bin/bash
This drops me into a shell in an Arch environment.
useradd builder passwd builder # set password for user "builder" so I can sudo later mkdir /home/builder chown builder /home/builder mkdir /nix chown builder /nix pacman -S sudo vim # replace "vim" with "nano" if you're not a Vim fan EDITOR=vim visudo # again, you can use "nano" if you like
This will open the editor with the sudoers file. Scroll down until you find where it says
root ALL=(ALL) ALL, and add a line below that says
builder ALL=(ALL) ALL. Save and quit.
Switch to the
builder user, install
nix, and update the package index:
su builder cd bash <(curl https://nixos.org/nix/install) nix-channel --update
The installer tells you to add a line to your shell profile. In this case, the shell profile is
~/.profile. If this were an actual computer I’d set up, I’d add it to
~/.zshrc because I prefer ZSH.
echo '. /home/builder/.nix-profile/etc/profile.d/nix.sh' >> .profile
Now it’s time to search for packages!
nix-env --query --available cowsay
This returns a single result on my system,
cowsay-3.03. I’m going to install that:
nix-env -i cowsay
The installer will pull the files from the NixOS cache and place them on your system. Time to test our installation!
[builder@9295696d3c6d ~]$ cowsay 'Hello Nix!' ____________ < Hello Nix! > ------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
Hooray! We’re now ready to go with Nix, and can reap all the benefits of using a functional package manager.
You can watch me fumble through the process below.