Few questions on nix usage

Hi all,

I have 2 questions on the use of NixOS.

  • as it seems that I will be the only user of my computer, where is it the best to install the packages : users.users or environment.systemPackages ?

  • if I want to use an external package, for example julia language or paraview, where should I put the downloaded folder provided ? I used to put them in opt/ when using ubuntu and fedora but it doesn’t exist in NixOS.
    Small complement : I know there is an official julia package in NixOS but I had some issues with the one provided by fedora so I prefer use the folder provided by julia. But it is another question.

  • users.users or environment.systemPackages

Under user whatever is desktop/UI related, and under system packages anything that you might want to use as root. Any basic utilities like htop or zip or vim I’d install under systemPackages, but anything that’s more like tool only used by me, for example ansible, I’d put under user packages.

  • where should I put the downloaded folder provided ?

I guess /opt is a good canonical place, but remember that most binaries not compiled on Nix will not work under Nix when downloaded. So in general you should avoid that. You should make a custom derivation for every package you want to install. Here’s an example of how I do it.

I have a custom gossa package derivation under pkgs folder:

And in services/gossa.nix I just load it using callPackage(which is just a wrapper around import keyword):

And that installs it. Now, to make that happen you’ll need to learn how to make derivations, but if you want a reproducible setup that doesn’t require manual intervention to reproduce that is the way to go.

1 Like

Thanks for your answer.

Ok for the packages installation.

For the binaries, after trying julia and paraview, indeed it does not work… Well, for a new user of NixOs coming from debian-based and fedora distributions, and who has not so many skills in computer science it is a bit, let say, annoying. I will see if I use the nix packages or your method.

As you’re just starting out on NixOS, you should probably just use steam-run. Despite its name, it creates a sort of virtual environment that regular linux binaries can run in. See this amazing SO answer for an overview of different methods.

# In the folder of the paraview binary:
steam-run ./paraview

For julia specifically, nixpkgs offers the julia-bin package, which is built by downloading the official binary distribution of julia and just patching a few library paths.

This is quite a good solution; julia goes very far in its effort of correctness and is built with a patched C compiler. This makes building from source quite complicated and is probably the reason why the julia package in official repos can behave weirdly. julia-bin sidesteps that problem.

1 Like

Ok, I will give a try to the bin packages.

Just for my own culture, does this mean that NixOS can be compare to distro like gentoo or not ? (if I understand well, gentoo need the compilation of all packages and thus, the use out of the box like here for julia is not possible ?)

I am not entirely sure but i think gentoo has *-bin packages for some stuff
Like firefox-bin

And nix is source based too but it has backing binary cache so you dont build most stuff unless you override or patch stuff

1 Like

Eh, nix has *-bin packages too.

Gentoo however is fhs-based, just like Arch, ubuntu, debian, fedora, and pretty much every other distro under the sun, you can just download random binaries and they will work fine (caveat libc version shenanigans). NixOS is different in this aspect.

Gentoo does not have binary packages, so you need to compile all your software locally. NixOS is different in this aspect.

Gentoo allows you to modify the software before you build it locally, change compilation flags and such, to make it match your use case better. This is all managed through Gentoo’s package manager. NixOS allows this too, so in this aspect it’s comparable.

1 Like

Thank you for your answers and enlightenment.

As I am using nixOS for a few time, it seems that it is not suited for my use. I am too used to fhs-based distros and I don’t think that I have the computer knowledge to run it for my purposes.

Nevertheless, the idea is great, and that’s why I tried it. For a basic use that does not require to step out of the proposed packages it is clearly the one that can make me stop distro-hopping. So I will keep an eye on it and an installation.