gptune / GPTune

Other
67 stars 19 forks source link

Add nix flake for building #15

Closed gdinh closed 2 years ago

gdinh commented 2 years ago

This pull request adds a nix flake for automated dependency fetching, building, and installation. Currently, this PR only includes the full GPTune; light mode will be coming soon.

In order to use it:

1. Install Nix. If you have root access, this command will perform an automatic installation: sh <(curl -L https://nixos.org/nix/install) --daemon (see the manual for full details); after running it, proceed to step 2. If you do not have root access, you can use nix-user-chroot to install a copy on your own account: download the static binaries, then run

mkdir -m 0755 ~/.nix
nix-user-chroot ~/.nix bash -c "curl -L https://nixos.org/nix/install | bash"
nix-user-chroot ~/.nix bash -l

You must then run nix-user-chroot ~/.nix bash -l in order to enter the nix chroot each time you want to access tools (including GPTune) installed with nix. Please note that this uses a tempfs on local memory to perform builds; if you run into "out of space" errors, manually set temporary location on disk, e.g. by using this command instead:

TMPDIR=/scratch/dinh/tmp nix-user-chroot /scratch/dinh/.nix bash

On Berkeley A machines, we strongly recommend replacing ~/.nix with a folder on /scratch for all commands (in the above example, we use /scratch/dinh/.nix), as /home is stored on extremely slow NFS volumes which will lead to ~10x slower build times.

2: Enable nix flakes Nix flakes are technically an experimental feature in nix (don't worry! Flakes have been out for years - the designation as experimental is more a statement that their interfaces might change than a mark of instability). Add the following line to ~/.config/nix/nix.conf or /etc/nix/nix.conf (on chroot-based nix installs, this will be /nix/etc/nix/nix.conf):

experimental-features = nix-command flakes

If the file does not exist, feel free to create it:

3: Build GPTune Clone the repo and cd into the GPTune directory (you can just download the .flake and .lock files and put them in the GPTune root directory if you have an existing copy). You can then run:

This PR still needs some fixes to python packaging, adding a shell hook modifying PYTHONPATH in nix develop, testing on linux, etc. so should be considered pre-alpha. Please let me know if you run into oddities or problems. Thanks!