2024-04-28 02:32:25 +00:00
|
|
|
---
|
2024-04-28 03:13:54 +00:00
|
|
|
title: "Switching To Lix"
|
2024-05-06 03:33:58 +00:00
|
|
|
description: "or: how to make your existing configuration Delicious"
|
2024-04-28 02:32:25 +00:00
|
|
|
date: "2024-04-27"
|
|
|
|
author: "Lix Team"
|
|
|
|
---
|
|
|
|
|
2024-06-20 06:53:19 +00:00
|
|
|
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:
|
|
|
|
- Potentially slightly older version of Lix
|
|
|
|
- Working binary caching
|
|
|
|
- Programs like nix-eval-jobs and colmena still use the default version of
|
|
|
|
Nix (may be unacceptable depending on your use case)
|
|
|
|
- Using the Lix NixOS module:
|
|
|
|
- Fresh version of Lix right out of the freezer
|
|
|
|
- You will be compiling Lix yourself, for now at least
|
|
|
|
- Programs like nix-eval-jobs and colmena have the version of Nix they use
|
|
|
|
overridden by an overlay such that most of the system uses Lix.
|
|
|
|
|
|
|
|
# Using Lix from nixpkgs
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
|
|
|
nix.package = pkgs.lix;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
That's it, you're done.
|
|
|
|
|
|
|
|
You can verify that it works by running the following command:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ nix --version
|
|
|
|
nix (Lix, like Nix) 2.90.0-rc1
|
|
|
|
```
|
|
|
|
|
|
|
|
# Using the Lix NixOS module
|
|
|
|
|
|
|
|
The Lix NixOS module is the way to get the most consistent experience using
|
|
|
|
Lix, and to have a system that has Lix as the default Nix implementation
|
|
|
|
wherever possible by using an overlay to replace `pkgs.nix`. It will result in
|
|
|
|
building Lix from source, which takes a few minutes on every update, which is a
|
|
|
|
perfect time to get up, get some water, and stretch for a bit.
|
2024-04-28 03:13:54 +00:00
|
|
|
|
2024-05-06 02:48:34 +00:00
|
|
|
## Flake-based Configurations
|
2024-04-28 02:32:25 +00:00
|
|
|
|
2024-05-06 02:48:34 +00:00
|
|
|
Adding Lix to a flake-based configuration is relatively simple. First, add the Lix module to your _flake inputs_:
|
2024-04-28 03:13:54 +00:00
|
|
|
|
2024-05-06 02:48:34 +00:00
|
|
|
```nix
|
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
|
|
|
|
# Add this section to your flake inputs!
|
|
|
|
#
|
|
|
|
# Note that this assumes you have a flake-input called nixpkgs,
|
2024-06-19 12:52:28 +00:00
|
|
|
# which is often the case. If you've named it something else,
|
2024-05-06 02:48:34 +00:00
|
|
|
# you'll need to change the `nixpkgs` below.
|
|
|
|
lix-module = {
|
2024-06-20 06:53:19 +00:00
|
|
|
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0-rc1.tar.gz";
|
2024-05-06 02:48:34 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# <rest of configuration omitted>
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Next, add the `lix-module` as one of the arguments to your output function:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
|
|
|
# <configuration above omitted>
|
|
|
|
|
|
|
|
# Add the `lix-module` argument to your output function, as below:
|
|
|
|
outputs = {nixpkgs, lix-module, ...}: {
|
|
|
|
# <rest of configuration omitted>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Add the Lix _NixOS Module_ to your configuration:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
|
|
|
# <configuration above omitted>
|
|
|
|
|
|
|
|
# Add the `lix-module` argument to your output function, as below:
|
|
|
|
outputs = {nixpkgs, lix-module, ...}: {
|
|
|
|
|
|
|
|
# The configuration here is an example; it will look slightly different
|
|
|
|
# based on your platform (NixOS, nix-darwin) and architecture.
|
|
|
|
nixosConfigurations.your-box = nixpkgs.lib.nixosSystem {
|
|
|
|
system = "x86_64-linux"
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
|
|
|
|
# This is the important part -- add this line to your module list!
|
|
|
|
lix-module.nixosModules.default
|
|
|
|
];
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# <configuration below omitted>
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-06-20 06:53:19 +00:00
|
|
|
<!--
|
|
|
|
FIXME: the binary cache doesn't do much good given that everyone is running a
|
|
|
|
different nixpkgs than Lix is actually cached with during the release process.
|
|
|
|
We need a hydra to be able to fix that.
|
|
|
|
|
2024-06-19 12:52:28 +00:00
|
|
|
Finally, if you'd prefer not to build Lix yourself, you can add our binary cache.
|
2024-05-06 02:48:34 +00:00
|
|
|
Add the following to any NixOS module in your configuration (e.g. `configuration.nix`):
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
2024-05-06 05:22:47 +00:00
|
|
|
nix.settings.substituters = [
|
2024-05-06 02:48:34 +00:00
|
|
|
"https://cache.lix.systems"
|
|
|
|
];
|
|
|
|
|
|
|
|
nix.settings.trusted-public-keys = [
|
|
|
|
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
|
|
|
|
];
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-06-20 06:53:19 +00:00
|
|
|
-->
|
|
|
|
|
2024-05-06 02:48:34 +00:00
|
|
|
Rebuild and switch into your new system (either using `nixos-rebuild` or `darwin-rebuild`).
|
|
|
|
You should now be using Lix! You can verify this by asking the `nix` command to report its version:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ nix --version
|
2024-06-20 06:53:19 +00:00
|
|
|
nix (Lix, like Nix) 2.90.0-rc1
|
2024-05-06 02:48:34 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
As long as you see `Lix` in the output, you're good! If you're not sure what to do now, it's a
|
|
|
|
great time to check out some of the [community's resources on Nix](/resources).
|
|
|
|
|
|
|
|
|
|
|
|
## Non-Flake Configurations
|
|
|
|
|
|
|
|
If you're not using flakes, you can set up your configuration to automatically pull down a
|
|
|
|
Lix release tarball, and then add it to your `configuration.nix`.
|
|
|
|
|
|
|
|
Open your `/etc/nixos/configuration.nix` in the editor of your choice. Find the `imports`
|
2024-06-19 12:52:28 +00:00
|
|
|
section, and add the line provided in the configuration
|
2024-05-06 02:48:34 +00:00
|
|
|
|
|
|
|
```nix
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{
|
|
|
|
imports =
|
|
|
|
[ # Include the results of the hardware scan.
|
|
|
|
./hardware-configuration.nix
|
|
|
|
|
2024-06-20 06:53:19 +00:00
|
|
|
# This includes the Lix NixOS module in your configuration along with the
|
|
|
|
# matching version of Lix itself.
|
|
|
|
#
|
|
|
|
# The sha256 hashes were obtained with the following command in Lix (n.b.
|
|
|
|
# this relies on --unpack, which is only in Lix and CppNix > 2.18):
|
|
|
|
# nix store prefetch-file --name source --unpack https://git.lix.systems/lix-project/lix/archive/2.90.0-rc1.tar.gz
|
2024-05-06 02:48:34 +00:00
|
|
|
#
|
|
|
|
# Note that the tag (e.g. v2.90) in the URL here is what determines
|
|
|
|
# which version of Lix you'll wind up with.
|
2024-06-20 06:53:19 +00:00
|
|
|
(let
|
|
|
|
module = fetchTarball {
|
|
|
|
name = "source";
|
|
|
|
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.90.0-rc1.tar.gz";
|
|
|
|
sha256 = "sha256-64lB/NO6AQ6z6EDCemPSYZWX/Qc6Rt04cPia5T5v01g=";
|
|
|
|
};
|
|
|
|
lixSrc = fetchTarball {
|
|
|
|
name = "source";
|
|
|
|
url = "https://git.lix.systems/lix-project/lix/archive/2.90.0-rc1.tar.gz";
|
|
|
|
sha256 = "sha256-WY7BGnu5PnbK4O8cKKv9kvxwzZIGbIQUQLGPHFXitI0=";
|
|
|
|
};
|
|
|
|
# This is the core of the code you need; it is an exercise to the
|
|
|
|
# reader to write the sources in a nicer way, or by using npins or
|
|
|
|
# similar pinning tools.
|
|
|
|
in import "${module}/module.nix" { lix = lixSrc; }
|
2024-05-06 02:48:34 +00:00
|
|
|
)
|
|
|
|
];
|
|
|
|
|
|
|
|
# <configuration below omitted>
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-06-20 06:53:19 +00:00
|
|
|
<!--
|
|
|
|
FIXME: as above, doesn't work, we should not recommend it.
|
|
|
|
|
2024-06-19 12:52:28 +00:00
|
|
|
Finally, if you'd prefer not to build Lix yourself, you can add our binary cache.
|
2024-05-06 02:48:34 +00:00
|
|
|
Add the following to any NixOS module in your configuration (e.g. `configuration.nix`):
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
2024-05-06 05:22:47 +00:00
|
|
|
nix.settings.substituters = [
|
2024-05-06 02:48:34 +00:00
|
|
|
"https://cache.lix.systems"
|
|
|
|
];
|
|
|
|
|
|
|
|
nix.settings.trusted-public-keys = [
|
|
|
|
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
|
|
|
|
];
|
|
|
|
}
|
|
|
|
```
|
2024-06-20 06:53:19 +00:00
|
|
|
-->
|
2024-05-06 02:48:34 +00:00
|
|
|
|
|
|
|
Rebuild and switch into your new system (either using `nixos-rebuild` or `darwin-rebuild`).
|
|
|
|
You should now be using Lix! You can verify this by asking the `nix` command to report its version:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ nix --version
|
2024-06-19 12:52:28 +00:00
|
|
|
nix (Lix, like Nix) 2.90.0-rc1-lixpre20240615-253546d
|
2024-05-06 02:48:34 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
As long as you see `Lix` in the output, you're good! If you're not sure what to do now, it's a
|
|
|
|
great time to check out some of the [community's resources on Nix](/resources).
|
|
|
|
|
|
|
|
## Having Trouble?
|
|
|
|
|
2024-06-19 12:52:28 +00:00
|
|
|
**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 --
|
2024-05-06 02:48:34 +00:00
|
|
|
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](/community), and check out the various ways to find help.
|