News for hackers. Stuff that matters.
Re:NixOS 22.11 “Raccoon” Released by pongo1231 on Thursday December 01, 2022 @08:20AM (#33815844)
- You will have to learn both the nix language and working with nixpkgs. Learning nix is pretty trivial IMO (great resources are nix-1p[0] and Nix Pills[1]) but the documentation, while vast, is pretty shallow at the moment. You will likely have to resort to reading random blog posts, nix configs published by others and the source code of nixpkgs itself.

- As mentioned by another commenter you will not be able to run random binaries by default. You can use nix-alien[2] which will automatically fetch the libraries required and build an FHS shell for the binary.

- It is significantly more bandwidth- / rebuild-heavy. If an input for a derivation changes it will trigger a rebuild, which means either a redownload from the binary cache or a recompilation.

[0] https://github.com/tazjin/nix-1p

[1] https://nixos.org/guides/nix-pills

[2] https://github.com/thiagokokada/nix-alien

Re:NixOS 22.11 “Raccoon” Released by codedokode on Thursday December 01, 2022 @09:00AM (#33816276)
> learn both the nix language

That seems weird to me. I don't have to learn package configuration language in other distributions. I thought that one could just install packages with a package manager.

> You can use nix-alien[2] which will automatically fetch the required libraries and build an FHS shell for the binary.

That's actually fine. I want to put closed source software into a chroot anyway.

Re:NixOS 22.11 “Raccoon” Released by preisschild on Thursday December 01, 2022 @09:05AM (#33816328)
> That seems weird to me. I don't have to learn package configuration language in other distributions. I thought that one could just install packages with a package manager.

NixOS is more like a distro bundled with Ansible, so you can describe your entire system as code.

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:27AM (#33816619)
but in contrast to ansible it uses a real programming language and not turing complete yaml
Re:NixOS 22.11 “Raccoon” Released by colordrops on Thursday December 01, 2022 @09:57AM (#33817019)
And it's reproducible since the entire system is built with it. Ansible is brittle as hell.
Re:NixOS 22.11 “Raccoon” Released by jauco on Thursday December 01, 2022 @09:07AM (#33816351)
If you want to run nixos (i.e. the linux distro) then the configuration file is written in the nix language. Given that you’ll have to configure your installation, you’ll have to learn the nix language

If you just want to use nix for packages, you can run any distro and install nix the package manager into it. This is a good way to dip your toes in the water. And in that case you can just use the cli commands for installing packages.

Re:NixOS 22.11 “Raccoon” Released by codedokode on Thursday December 01, 2022 @09:48AM (#33816915)
I remember reading that nix unlike all other distros can install multiple version of the same package and I want this feature, but I guess programming a package config might be too much for me. Maybe I'll try nix package manager then.
Re:NixOS 22.11 “Raccoon” Released by rssoconnor on Thursday December 01, 2022 @10:26AM (#33817467)
While maybe not impossible, it is quite hard to cox Nix to "install" multiple different versions of the packages. They all cannot be in your path at the same time.

I still encourage you to give it a try. You can build different versions of same package and not "install" them. Instead just execute the binary from the built version (I do this where I have a built-but-not-installed version of openssh-8.6 laying around because I have an old service that modern SSH no longer supports).

You can also run `nix-shell -p <custom-package-version>` to get a shell with a specific package available in the path, overtop of whatever might be globally installed.

Who knows, you might even be tempted to dip your toes into the Nix language by writing a custom `shell.nix` to build a shell with some more complex development environment, or to simply automate a complex `nix-shell -p` command.

Re:NixOS 22.11 “Raccoon” Released by pxc on Thursday December 01, 2022 @11:15AM (#33818291)
The Nix idioms that are used in configuring NixOS are super simple, mostly just turning things on and off.

You can browse some here: https://search.nixos.org/options

For example, to install an OpenSSH server and run it, you'd write:

  services.openssh.enable = true;
and to run it on an additional port, 2222, instead of just the default of 22, you'd write:

  services.openssh.ports = [
    22
    2222
  ];
For programs you don't need to configure but just want to put on your PATH, you just add them to a list like

  environment.systemPackages = [
    pkgs.firefox
    pkgs.jq
  ];
If configuration management isn't for you, go ahead and mess around with Nix as a standalone package manager. But it really doesn't require much effort or prior knowledge to get up and running and start playing with it!

(For NixOS, the Nix you write only starts looking like real code when you want to add new features or some packages to NixOS.)

Re:NixOS 22.11 “Raccoon” Released by mattarm on Thursday December 01, 2022 @11:41AM (#33818754)
> nix unlike all other distros can install multiple version of the same package

The above is sometimes true and sometimes not. For the most part, Nix can install multiple versions of a program but only one can be in use at any given time.

Nix is for the most part shell based workflow (as in bash, zsh, etc.). The `nix-shell` command lets you switch out the packages (and versions of packages) that are used in any given shell, but it works off of a configuration file written in the Nix language that you write. The programs that are available are controlled by environment variables such as PATH and MANPATH.

Nix is a big shift from the usual way of dealing with packages, programs, etc. It isn't really useful until you really make the effort to understand what is going on, learn the Nix language, etc. If you are not interested in "programming" your system, then it probably isn't for you.

Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:19PM (#33820249)
> Nix can install multiple versions of a program but only one can be in use at any given time.

That’s not really true and is only a limitation of how PATH works on UNIXes (the first match is used). But you can for example add an aliased name for multiple versions of the same package, or for another meaning of use you can have different executables in the same environment different versions of the same lib (e.g. one bash script references python3, the other python3-at-specific-patch/minor-version/whatever)

Re:NixOS 22.11 “Raccoon” Released by chriswarbo on Thursday December 01, 2022 @01:22PM (#33820296)
> or the most part, Nix can install multiple versions of a program but only one can be in use at any given time.

That's a bit hand-wavey. More precisely: when you run a command, like `python3`, you can only associate that with one file. If you want multiple Python 3 interpreters, you'll have to use different names (e.g. making symlinks).

Alternatively, you don't need to bother "installing" anything; e.g. I use Nix for projects which use Scala, Maven, Python, NodeJS, etc. yet I don't have any of those installed. Instead, each project includes a `shell.nix` file which specifies the tools it wants. Running `nix-shell` in different folders gives me access to different tools.

Also, with Nix we only need to care about the end result: we can "install" a bunch of different programs, even if they have incompatible dependencies, since we're not "installing" those dependencies. ("Install" just means putting a symlink in some bin/ folder, like /run/current-system/sw/bin on NixOS or $HOME/.nix-profile/bin on non-NixOS)

Re:NixOS 22.11 “Raccoon” Released by Cloudef on Monday December 05, 2022 @02:44AM (#33862700)
This is only true if you want multiple versions in the same global environment. If you really want them in global environment, you can create meta package that aliases with symlinks. Otherwise you can use nix-shell to get any environment you want.
Re:NixOS 22.11 “Raccoon” Released by opan on Thursday December 01, 2022 @10:14AM (#33817278)
On both NixOS and Guix System you can get by pretty well without learning the config langs or all the more advanced features. Only really becomes a problem if you need something new packaged. You can enjoy declarative package management with easy rollbacks without really learning more than any other distro.
Re:NixOS 22.11 “Raccoon” Released by nextaccountic on Thursday December 01, 2022 @12:07PM (#33819164)
> I thought that one could just install packages with a package manager.

You could use the command

    nix-env -iA mypackage
To install packages, which is like pacman -S mypackage or apt install mypackage.

But... the interesting part of Nix is that it lets you install packages declaratively, by editing a config (like vim and emacs packages). Besides installing packages, all configuration is done through this config file (or bunch of config files): nix generates all files in /etc for you, again, like vim or emacs, but for the whole OS

That way, you easily transfer your setup to another computer or even keep two machines in sync. And you can add it to version control. And you get a grub menu with all your previous setups (until you uninstall them)

If this doesn't appeal you, you probably won't like to use NixOS

Re:NixOS 22.11 “Raccoon” Released by SuperSandro2000 on Thursday December 01, 2022 @09:27AM (#33816631)
you can also use https://github.com/Mic92/nix-ld or build a fhs.
Re:NixOS 22.11 “Raccoon” Released by kaba0 on Thursday December 01, 2022 @01:14PM (#33820190)
> It is significantly more bandwidth- / rebuild-heavy. If an input for a derivation changes it will trigger a rebuild, which means either a redownload from the binary cache or a recompilation.

For general usage I didn’t notice it much, like, as an alternative to apt/pacman/etc. Ok, maybe don’t use it from a limited data plan (but isn’t true of every desktop OS?).

But sure, if you patch some lib n layers deep you will have to recompile many things, which is a godsend (in that you can actually do that), but will take a bit of time. But you can usually decrement its impact by really changing what has to be changed and using a “standard” channel for all the rest. With flakes it is especially easy to mix and match multiple nixpkgs repos at different versions.