Skip to content

Commit 023784d

Browse files
author
jade
committed
🦀🦀🦀🦀🦀🦀🦀 pull request 'content/add-to-config: recommend nixpkgs for stable versions' (#58) from new-mechanism into main
Reviewed-on: https://git.lix.systems/lix-project/lix-website/pulls/58
2 parents bfdb352 + 1579252 commit 023784d

File tree

2 files changed

+110
-332
lines changed

2 files changed

+110
-332
lines changed

‎content/add-to-config.md‎

Lines changed: 55 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ Please don't edit add-to-config.md directly!
1616
If you have an existing configuration on **NixOS** or **nix-darwin**, there are
1717
a couple of ways to switch to Lix, all of which are relatively easy.
1818

19-
- Using Lix from nixpkgs:
20-
- Potentially slightly older version of Lix
21-
- Working binary caching
22-
- Programs like nix-eval-jobs and colmena still use the default version of
23-
Nix (may be unacceptable depending on your use case)
24-
- Using the Lix NixOS module:
19+
- Using Lix from nixpkgs (recommended for stable, released versions):
20+
- Official, supported builds maintained by the `nixpkgs` contributors and the Lix team
21+
- Is cached by `cache.nixos.org`, no local builds are required
22+
- Consistent compatibility with advanced features of Nixpkgs: cross compilation or static builds.
23+
- Using the Lix NixOS module, [only recommended if you run main](https://wiki.lix.systems/books/lix-contributors/page/running-lix-main)
2524
- Fresh version of Lix right out of the freezer
2625
- You will be compiling Lix yourself, for now at least
27-
- Programs like nix-eval-jobs and colmena have the version of Nix they use
28-
overridden by an overlay such that most of the system uses Lix.
26+
- Build stability may vary, as `nixpkgs` updates can occasionally introduce breaking changes
2927

30-
# Using Lix from nixpkgs
28+
Running bleeding-edge (i.e. the `main` branch) Lix should not prevent you from using your system, we
29+
take this seriously and strive to ensure it works reliably.
30+
31+
That said, issues can happen. If you choose to run bleeding-edge, make sure you
32+
have a way to recover your system in case Lix breaks.
33+
34+
# Using Lix from nixpkgs (recommended)
35+
36+
Using Lix from nixpkgs is the most recommended way if you are not using bleeding edge HEAD builds.
37+
38+
## Simplest change
3139

3240
This approach has some caveats: since it is not using an overlay, it does not
3341
set the version of Nix depended on by other tools like colmena or
@@ -41,7 +49,7 @@ Add the following code to your NixOS configuration:
4149
```nix
4250
{ pkgs, ... }:
4351
{
44-
nix.package = pkgs.lix;
52+
nix.package = pkgs.lixPackageSets.stable.lix;
4553
}
4654
```
4755

@@ -54,187 +62,68 @@ $ nix --version
5462
nix (Lix, like Nix) 2.93.3
5563
```
5664

57-
# Using the Lix NixOS module
58-
59-
The Lix NixOS module is the way to get the most consistent experience using
60-
Lix, and to have a system that has Lix as the default Nix implementation
61-
wherever possible by using an overlay to replace `pkgs.nix`. It will result in
62-
building Lix from source, which takes a few minutes on every update, which is a
63-
perfect time to get up, get some water, and stretch for a bit.
64-
65-
## Flake-based Configurations
66-
67-
Adding Lix to a flake-based configuration is relatively simple. First, add the Lix module to your _flake inputs_:
68-
69-
```nix
70-
{
71-
inputs = {
72-
73-
# Add this section to your flake inputs!
74-
#
75-
# Note that this assumes you have a flake-input called nixpkgs,
76-
# which is often the case. If you've named it something else,
77-
# you'll need to change the `nixpkgs` below.
78-
lix-module = {
79-
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.93.3-1.tar.gz";
80-
inputs.nixpkgs.follows = "nixpkgs";
81-
};
82-
83-
}
84-
85-
# <rest of configuration omitted>
86-
}
87-
```
88-
89-
Next, add the `lix-module` as one of the arguments to your output function:
90-
91-
```nix
92-
{
93-
# <configuration above omitted>
94-
95-
# Add the `lix-module` argument to your output function, as below:
96-
outputs = {nixpkgs, lix-module, ...}: {
97-
# <rest of configuration omitted>
98-
}
99-
}
100-
```
101-
102-
Add the Lix _NixOS Module_ to your configuration:
103-
104-
```nix
105-
{
106-
# <configuration above omitted>
107-
108-
# Add the `lix-module` argument to your output function, as below:
109-
outputs = {nixpkgs, lix-module, ...}: {
110-
111-
# The configuration here is an example; it will look slightly different
112-
# based on your platform (NixOS, nix-darwin) and architecture.
113-
nixosConfigurations.your-box = nixpkgs.lib.nixosSystem {
114-
system = "x86_64-linux"
115-
116-
modules = [
65+
## Advanced change
11766

118-
# This is the important part -- add this line to your module list!
119-
lix-module.nixosModules.default
120-
];
67+
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.
12168

122-
};
123-
}
124-
125-
# <configuration below omitted>
126-
}
127-
```
128-
129-
<!--
130-
FIXME: the binary cache doesn't do much good given that everyone is running a
131-
different nixpkgs than Lix is actually cached with during the release process.
132-
We need a hydra to be able to fix that.
133-
134-
Finally, if you'd prefer not to build Lix yourself, you can add our binary cache.
135-
Add the following to any NixOS module in your configuration (e.g. `configuration.nix`):
69+
Add the following code to your NixOS configuration:
13670

13771
```nix
72+
{ pkgs, ... }:
13873
{
139-
nix.settings.substituters = [
140-
"https://cache.lix.systems"
141-
];
142-
143-
nix.settings.trusted-public-keys = [
144-
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
145-
];
74+
nixpkgs.overlays = [ (final: prev: {
75+
inherit (final.lixPackageSets.stable)
76+
nixpkgs-review
77+
nix-direnv
78+
nix-eval-jobs
79+
nix-fast-build
80+
colmena;
81+
}) ];
82+
83+
nix.package = pkgs.lixPackageSets.stable.lix;
14684
}
14785
```
14886

149-
-->
87+
That's it, your environment is now consistently using Lix across supported tools.
15088

151-
Rebuild and switch into your new system (either using `nixos-rebuild` or `darwin-rebuild`).
152-
You should now be using Lix! You can verify this by asking the `nix` command to report its version:
89+
You can verify that it works by running the following command:
15390

15491
```sh
15592
$ nix --version
15693
nix (Lix, like Nix) 2.93.3
15794
```
15895

159-
As long as you see `Lix` in the output, you're good! If you're not sure what to do now, it's a
160-
great time to check out some of the [community's resources on Nix](/resources).
161-
162-
163-
## Non-Flake Configurations
164-
165-
If you're not using flakes, you can set up your configuration to automatically pull down a
166-
Lix release tarball, and then add it to your `configuration.nix`.
167-
168-
Open your `/etc/nixos/configuration.nix` in the editor of your choice. Find the `imports`
169-
section, and add the line provided in the configuration
170-
171-
```nix
172-
{ config, lib, pkgs, ... }:
173-
{
174-
imports =
175-
[ # Include the results of the hardware scan.
176-
./hardware-configuration.nix
177-
178-
# This includes the Lix NixOS module in your configuration along with the
179-
# matching version of Lix itself.
180-
#
181-
# The sha256 hashes were obtained with the following command in Lix (n.b.
182-
# this relies on --unpack, which is only in Lix and CppNix > 2.18):
183-
# nix store prefetch-file --name source --unpack https://git.lix.systems/lix-project/lix/archive/2.93.3.tar.gz
184-
#
185-
# Note that the tag (e.g. 2.93.3) in the URL here is what determines
186-
# which version of Lix you'll wind up with.
187-
(let
188-
module = fetchTarball {
189-
name = "source";
190-
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.93.3-1.tar.gz";
191-
sha256 = "sha256-KYMUrTV7H/RR5/HRnjV5R3rRIuBXMemyJzTLi50NFTs=";
192-
};
193-
lixSrc = fetchTarball {
194-
name = "source";
195-
url = "https://git.lix.systems/lix-project/lix/archive/2.93.3.tar.gz";
196-
sha256 = "sha256-Oqw04eboDM8rrUgAXiT7w5F2uGrQdt8sGX+Mk6mVXZQ=";
197-
};
198-
# This is the core of the code you need; it is an exercise to the
199-
# reader to write the sources in a nicer way, or by using npins or
200-
# similar pinning tools.
201-
in import "${module}/module.nix" { lix = lixSrc; }
202-
)
203-
];
204-
205-
# <configuration below omitted>
206-
}
207-
```
96+
---
20897

209-
<!--
210-
FIXME: as above, doesn't work, we should not recommend it.
98+
To use a different version of Lix, replace `stable` with `latest`, `git`, or a specific version like `lix_2_93`.
21199

212-
Finally, if you'd prefer not to build Lix yourself, you can add our binary cache.
213-
Add the following to any NixOS module in your configuration (e.g. `configuration.nix`):
100+
You can also rewire other packages manually. For example, to override a package so that it uses the Lix version of Nix:
214101

215102
```nix
103+
{ pkgs, ... }:
216104
{
217-
nix.settings.substituters = [
218-
"https://cache.lix.systems"
219-
];
220-
221-
nix.settings.trusted-public-keys = [
222-
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
223-
];
105+
nixpkgs.overlays = [ (final: prev: {
106+
my-new-package = prev.my-new-package.override {
107+
nix = final.lixPackageSets.stable.lix;
108+
}; # Adapt to your specific use case.
109+
110+
inherit (final.lixPackageSets.stable)
111+
nixpkgs-review
112+
nix-direnv
113+
nix-eval-jobs
114+
nix-fast-build
115+
colmena;
116+
}) ];
117+
118+
nix.package = pkgs.lixPackageSets.stable.lix;
224119
}
225120
```
226-
-->
227121

228-
Rebuild and switch into your new system (either using `nixos-rebuild` or `darwin-rebuild`).
229-
You should now be using Lix! You can verify this by asking the `nix` command to report its version:
122+
# Using the Lix NixOS module (only recommended for bleeding edge builds)
230123

231-
```sh
232-
$ nix --version
233-
nix (Lix, like Nix) 2.93.3
234-
```
124+
_Thank you for considering Lix bleeding edge, this helps us a lot to make Lix better._
235125

236-
As long as you see `Lix` in the output, you're good! If you're not sure what to do now, it's a
237-
great time to check out some of the [community's resources on Nix](/resources).
126+
The instructions are maintained on <https://wiki.lix.systems/books/lix-contributors/page/running-lix-main>.
238127

239128
## Having Trouble?
240129

0 commit comments

Comments
 (0)