Skip to content

Instantly share code, notes, and snippets.

@Juke34
Last active March 4, 2024 20:43
Show Gist options
  • Save Juke34/76d6427a419935b80a662c51801141ab to your computer and use it in GitHub Desktop.
Save Juke34/76d6427a419935b80a662c51801141ab to your computer and use it in GitHub Desktop.
Guix installation on Mac M2

How to install GUIX on M2 Mac computer

Downloading & installing UTM

You need to install the UTM virtual machine manager In your browser, go to mac.getutm.app, and click on the Download button.

Mount the downloaded UTM.dmg disk-image and drag the UTM app to the Applications folder. Next, launch the UTM app from your Mac’s local Applications folder. (Depending on your Mac’s security settings, you may get a confirmation dialog when you launch UTM for the first time. If such a dialog appears, choose Open.)

Install a linux distribution (ARM)

Install a linux distribution compatible to the M2 machine: ARM You can find rockylinux iso image at this address: https://rockylinux.org/download.
Or use Ubuntu Server for ARM available here: https://ubuntu.com/download/server/arm

Install GUIX

(des informatiojn complementaire sont disponible ici https://guix.gnu.org/fr/manual/devel/fr/html_node/Installation-binaire.html)

Open terminal and become root:

sudo su -

download and install guix:

wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
chmod +x guix-install.sh
./guix-install.sh

You can check where guix has been installed

type -P guix

At this point the guix daemon can be not yet working

guix pull
guix pull: erreur : impossible de se connecter à « /var/guix/daemon-socket/socket » : Connexion refusée

Running with systmclt did not work neither

systemctl start guix-daemon.service

So we visualise the service system

cat /etc/systemd/system/guix-daemon.service

and manually execute what is present in the ExecStart paragraph:

/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild --discover=yes

Then it works and you can test that everything is working fine;


guix shell hello -- hello

Todo: Find a way to make the daemon working smoothly

Install a tool

guix install nano

If you call nano it might not work out of the box you would need to set the env properly doing.

GUIX_PROFILE="/home/jdainat/.guix-profile"
     . "$GUIX_PROFILE/etc/profile"

Then you can call the tool. To see where the tool is install you can do

type -P nano
readlink -f $(type -P emacs)
guix package --list-installed # list what is installed
guix package --list-generations # list all generation. A generation is a layer of installation...
guix package --rollback # to go back to a rpevious generation

doing

guix shell gcc-toolchain openmpi

will create a subshell with gcc and openmpi installed in it. ([env]) To quit this env run exit.

The env is still leaving aroud. No need to think about disk usage (space is made automatically when needed by the computer using garbage collector) but if needed, run the following command:

guix gc # garbage collector to clean what is no longerneeded.

To not extend an existing shell it is possible to run a command to run programm in a container using -C and --container is the same e.g.:

guix -C gcc-toolchain openmpi

This time only gcc and openmpi is avialable even ls command does not exist anymore. To use ls or grep we need to add coreutils among the packages to install in the env.

The container option is not only doing a env for the tool but also load only the working directory as an isolated container. ls / you do not see the /userit re-recreate a full clean working env. To load specific file or direcotry in the container use --expose=...path... this will be read/write. Another option exists to access read only.

/!\ Do not never mix package from guix / module / spack. It is why it is important when using guix to use it with container option. So package should be fully guixor spack or module.

-C is not usable on a HPC because rely to something not avaiblable. Instead you need to use --pure? instead.

Manifest

When you need lot of packages it becomes important to use manifiest files.

guix shell python python-numpy python-scipy --export-manifest > manifest.scm

To use an existing manifest

guix shell -m manifesst.scm

Extra packages

By adding new channels e.g. guix-hpc guix-sci

Package version

There is only one version of each tool at every guix version. Top keep track of the exact version:

guix describe -f channels > channels.scm

For reproducibility we need the channels.scm and manifest.scm

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