Switching To Lix

Apr 27, 2024

or: how to make your existing configuration Delicious

If you have an existing configuration on NixOS or nix-darwin, there are a couple of ways to switch to Lix, all of which are relatively easy.

  • Using Lix from nixpkgs (recommended for stable, released versions):
    • Official, supported builds maintained by the nixpkgs contributors and the Lix team
    • Is cached by cache.nixos.org, no local builds are required
    • Consistent compatibility with advanced features of Nixpkgs: cross compilation or static builds.
  • Using the Lix NixOS module, only recommended if you run main
    • Fresh version of Lix right out of the freezer
    • You will be compiling Lix yourself, for now at least
    • Build stability may vary, as nixpkgs updates can occasionally introduce breaking changes

Running bleeding-edge (i.e. the main branch) Lix should not prevent you from using your system, we take this seriously and strive to ensure it works reliably.

That said, issues can happen. If you choose to run bleeding-edge, make sure you have a way to recover your system in case Lix breaks.

Using Lix from nixpkgs (recommended)

Using Lix from nixpkgs is the most recommended way if you are not using bleeding edge HEAD builds.

Simplest change

This approach has some caveats: since it is not using an overlay, it does not set the version of Nix depended on by other tools like colmena or nix-eval-jobs. Consequently, those tools will be using whichever version of CppNix is default in nixpkgs, likely leading to an inconsistent experience. It is, however, easy, and it does not take the few minutes to compile Lix from source.

Add the following code to your NixOS configuration:

{ pkgs, ... }:
{
  nix.package = pkgs.lixPackageSets.stable.lix;
}

That’s it, you’re done.

You can verify that it works by running the following command:

$ nix --version
nix (Lix, like Nix) 2.93.3

Advanced change

This approach is more robust, as it uses an overlay to rewire other tools that depend on Nix, ensuring consistency across your setup. Tools like colmena or nix-eval-jobs, which often hardcode a reference to Nix, will now use the version provided by Lix.

Add the following code to your NixOS configuration:

{ pkgs, ... }:
{
  nixpkgs.overlays = [ (final: prev: {
    inherit (prev.lixPackageSets.stable)
      nixpkgs-review
      nix-eval-jobs
      nix-fast-build
      colmena;
  }) ];

  nix.package = pkgs.lixPackageSets.stable.lix;
}

That’s it, your environment is now consistently using Lix across supported tools.

You can verify that it works by running the following command:

$ nix --version
nix (Lix, like Nix) 2.93.3

To use a different version of Lix, replace stable with latest, git, or a specific version like lix_2_93.

You can also rewire other packages manually. For example, to override a package so that it uses the Lix version of Nix:

{ pkgs, ... }:
{
  nixpkgs.overlays = [ (final: prev: {
    my-new-package = prev.my-new-package.override {
      nix = final.lixPackageSets.stable.lix;
    }; # Adapt to your specific use case.

    inherit (final.lixPackageSets.stable)
      nixpkgs-review
      nix-direnv
      nix-eval-jobs
      nix-fast-build
      colmena;
  }) ];

  nix.package = pkgs.lixPackageSets.stable.lix;
}

Using the Lix NixOS module (only recommended for bleeding edge builds)

Thank you for considering Lix bleeding edge, this helps us a lot to make Lix better.

The instructions are maintained on https://wiki.lix.systems/books/lix-contributors/page/running-lix-main.

Having Trouble?

One quick thing to check: have you set nix.package anywhere in your configuration? If so, your configuration option will override the Lix module. You’ll want to remove it, first — or, if you’re feeling savvy, point it to the provided Lix package.

Otherwise: If you’re having difficulty installing Lix, don’t panic! Hop on over to our community page, and check out the various ways to find help.