Skip to content

Commit 2b48838

Browse files
authored
chore: remove legacy params - system (#254)
1 parent 1fed3fb commit 2b48838

21 files changed

Lines changed: 95 additions & 139 deletions

docs/en/development/cross-platform-compilation.md

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pkgsCross.mmix
7474
If you want to set `pkgs` to a cross-compilation toolchain globally in a flake, you only
7575
need to add a Module in `flake.nix`, as shown below:
7676

77-
```nix{15-20}
77+
```nix{12-17}
7878
{
7979
description = "NixOS running on LicheePi 4A";
8080
@@ -84,16 +84,14 @@ need to add a Module in `flake.nix`, as shown below:
8484
8585
outputs = inputs@{ self, nixpkgs, ... }: {
8686
nixosConfigurations.lp4a = nixpkgs.lib.nixosSystem {
87-
# native platform
88-
system = "x86_64-linux";
8987
modules = [
90-
91-
# add this module, to enable cross-compilation.
9288
{
93-
nixpkgs.crossSystem = {
94-
# target platform
95-
system = "riscv64-linux";
96-
};
89+
# the platform that performs the build-step
90+
nixpkgs.localSystem.system = "x86_64-linux";
91+
92+
# the platform that will execute the resulting binaries
93+
# add this to enable cross-compilation.
94+
nixpkgs.crossSystem.system = "riscv64-linux";
9795
}
9896
9997
# ...... other modules
@@ -131,7 +129,7 @@ your NixOS Module to enable the simulated build system of `aarch64-linux` and
131129
As for `flake.nix`, its setting method is very simple, even simpler than the setting of
132130
cross-compilation, as shown below:
133131

134-
```nix{11}
132+
```nix{13}
135133
{
136134
description = "NixOS running on LicheePi 4A";
137135
@@ -141,17 +139,18 @@ cross-compilation, as shown below:
141139
142140
outputs = inputs@{ self, nixpkgs, ... }: {
143141
nixosConfigurations.lp4a = nixpkgs.lib.nixosSystem {
144-
# native platform
145-
system = "riscv64-linux";
146142
modules = [
143+
# the native platform
144+
# usually this is already set in the generated `hardware-configuration.nix` and can be omit.
145+
{ nixpkgs.hostPlatform = "riscv64-linux"; }
147146
# ...... other modules
148147
];
149148
};
150149
};
151150
}
152151
```
153152

154-
You do not need to add any additional modules, just specify `system` as `riscv64-linux`.
153+
You do not need to add any additional modules, just specify `nixpkgs.hostPlatform` as `riscv64-linux`.
155154
Nix will automatically detect whether the current system is `riscv64-linux` during the
156155
build. If not, it will automatically build through the emulated system(QEMU). For users,
157156
these underlying operations are completely transparent.
@@ -223,20 +222,20 @@ Loading installable ''...
223222
Added 17755 variables.
224223

225224
# replace gcc through overlays, this will create a new instance of nixpkgs
226-
nix-repl> a = import <nixpkgs> { crossSystem = { config = "riscv64-unknown-linux-gnu"; }; overlays = [ (self: super: { gcc = self.gcc12; }) ]; }
225+
nix-repl> a = import <nixpkgs> { crossSystem = "riscv64-linux"; overlays = [ (self: super: { gcc = self.gcc13; }) ]; }
227226

228227
# check the gcc version, it is indeed changed to 12.2
229228
nix-repl> a.pkgsCross.riscv64.stdenv.cc
230-
«derivation /nix/store/jjvvwnf3hzk71p65x1n8bah3hrs08bpf-riscv64-unknown-linux-gnu-stage-final-gcc-wrapper-12.2.0.drv»
229+
«derivation /nix/store/kdi3g7px1bxz2r1jmjnr4pahscw8jj96-riscv64-unknown-linux-gnu-gcc-wrapper-13.4.0.drv»
231230

232231
# take a look at the default pkgs, it is still 11.3
233232
nix-repl> pkgs.pkgsCross.riscv64.stdenv.cc
234-
«derivation /nix/store/pq3g0wq3yfc4hqrikr03ixmhqxbh35q7-riscv64-unknown-linux-gnu-stage-final-gcc-wrapper-11.3.0.drv»
233+
«derivation /nix/store/xd8s47j71z3lym5f2j9zy3v9r0ifw209-riscv64-unknown-linux-gnu-gcc-wrapper-14.3.0.drv»
235234
```
236235

237236
So how to use this method in Flakes? The example `flake.nix` is as follows:
238237

239-
```nix{13-20}
238+
```nix{20-21}
240239
{
241240
description = "NixOS running on LicheePi 4A";
242241
@@ -247,15 +246,17 @@ So how to use this method in Flakes? The example `flake.nix` is as follows:
247246
outputs = { self, nixpkgs, ... }:
248247
{
249248
nixosConfigurations.lp4a = nixpkgs.lib.nixosSystem {
250-
system = "x86_64-linux";
251249
modules = [
252250
{
253-
nixpkgs.crossSystem = {
254-
config = "riscv64-unknown-linux-gnu";
255-
};
251+
# the platform that performs the build-step
252+
nixpkgs.localSystem.system = "x86_64-linux";
256253
257-
# replace gcc with gcc12 through overlays
258-
nixpkgs.overlays = [ (self: super: { gcc = self.gcc12; }) ];
254+
# the platform that will execute the resulting binaries
255+
# add this to enable cross-compilation.
256+
nixpkgs.crossSystem.system = "riscv64-linux";
257+
258+
# replace gcc with gcc13 through overlays
259+
nixpkgs.overlays = [ (self: super: { gcc = self.gcc13; }) ];
259260
}
260261
261262
# other modules ......
@@ -273,7 +274,7 @@ To avoid this problem, a better way is to create a new `pkgs` instance, and only
273274
instance when building the packages we want to modify. The example `flake.nix` is as
274275
follows:
275276

276-
```nix{10-19,34-37}
277+
```nix{10-17,32}
277278
{
278279
description = "NixOS running on LicheePi 4A";
279280
@@ -283,33 +284,29 @@ follows:
283284
284285
outputs = { self, nixpkgs, ... }: let
285286
# create a new pkgs instance with overlays
286-
pkgs-gcc12 = import nixpkgs {
287+
pkgs-gcc13 = import nixpkgs {
287288
localSystem = "x86_64-linux";
288-
crossSystem = {
289-
config = "riscv64-unknown-linux-gnu";
290-
};
289+
crossSystem = "riscv64-linux";
291290
292291
overlays = [
293-
(self: super: { gcc = self.gcc12; })
292+
(self: super: { gcc = self.gcc13; })
294293
];
295294
};
296295
in {
297296
nixosConfigurations.lp4a = nixpkgs.lib.nixosSystem {
298-
system = "x86_64-linux";
299297
specialArgs = {
300298
# pass the new pkgs instance to the module
301-
inherit pkgs-gcc12;
299+
inherit pkgs-gcc13;
302300
};
303301
modules = [
304302
{
305-
nixpkgs.crossSystem = {
306-
config = "riscv64-unknown-linux-gnu";
307-
};
303+
nixpkgs.localSystem.system = "x86_64-linux";
304+
nixpkgs.crossSystem.system = "riscv64-linux";
308305
}
309306
310-
({pkgs-gcc12, ...}: {
307+
({pkgs-gcc13, ...}: {
311308
# use the custom pkgs instance to build the package hello
312-
environment.systemPackages = [ pkgs-gcc12.hello ];
309+
environment.systemPackages = [ pkgs-gcc13.hello ];
313310
})
314311
315312
# other modules ......

docs/en/nix-store/add-binary-cache-servers.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ The second method is to configure `substituters` and `trusted-public-keys` using
113113
> As mentioned earlier, it is essential to configure `nix.settings.trusted-users` in this
114114
> configuration. Otherwise, the `substituters` we set here will not take effect.
115115
116-
```nix{5-23,43-47}
116+
```nix{5-23,42-46}
117117
{
118118
description = "NixOS configuration of Ryan Yin";
119119
@@ -151,7 +151,6 @@ The second method is to configure `substituters` and `trusted-public-keys` using
151151
}: {
152152
nixosConfigurations = {
153153
my-nixos = nixpkgs.lib.nixosSystem {
154-
system = "x86_64-linux";
155154
modules = [
156155
./hardware-configuration.nix
157156
./configuration.nix
@@ -207,7 +206,7 @@ the value of `extra-xxx` will be appended to the end of the `xxx` parameter:
207206

208207
In other words, you can use it like this:
209208

210-
```nix{7,13,37-60}
209+
```nix{7,13,36-58}
211210
{
212211
description = "NixOS configuration of Ryan Yin";
213212
@@ -239,7 +238,6 @@ In other words, you can use it like this:
239238
}: {
240239
nixosConfigurations = {
241240
my-nixos = nixpkgs.lib.nixosSystem {
242-
system = "x86_64-linux";
243241
modules = [
244242
./hardware-configuration.nix
245243
./configuration.nix
@@ -266,7 +264,6 @@ In other words, you can use it like this:
266264
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
267265
];
268266
};
269-
270267
}
271268
# omitting several configurations...
272269
];

docs/en/nixos-with-flakes/downgrade-or-upgrade-packages.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ modify the package version, you need to lock the git commit of the flake input.
88
Here's an example of how you can add multiple nixpkgs inputs, each using a different git
99
commit or branch:
1010

11-
```nix{8-13,19-20,27-44}
11+
```nix{8-13,19-20,27-42}
1212
{
1313
description = "NixOS configuration of Ryan Yin";
1414
@@ -33,8 +33,6 @@ commit or branch:
3333
}: {
3434
nixosConfigurations = {
3535
my-nixos = nixpkgs.lib.nixosSystem rec {
36-
system = "x86_64-linux";
37-
3836
# The `specialArgs` parameter passes the
3937
# non-default nixpkgs instances to other nix modules
4038
specialArgs = {

docs/en/nixos-with-flakes/modularize-the-configuration.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,13 @@ shorthand for `lib.mkOrder 1500`.
281281
To test the usage of `lib.mkBefore` and `lib.mkAfter`, let's create a simple Flake
282282
project:
283283

284-
```nix{10-38}
284+
```nix{8-36}
285285
# flake.nix
286286
{
287287
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
288288
outputs = {nixpkgs, ...}: {
289289
nixosConfigurations = {
290290
"my-nixos" = nixpkgs.lib.nixosSystem {
291-
system = "x86_64-linux";
292-
293291
modules = [
294292
({lib, ...}: {
295293
programs.bash.shellInit = lib.mkBefore ''

docs/en/nixos-with-flakes/nixos-flake-and-module-system.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ for use in user configuration files.
106106
Suppose you want to pass a certain dependency to a submodule for use. You can use the
107107
`specialArgs` parameter to pass the `inputs` to all submodules:
108108

109-
```nix{13}
109+
```nix{11}
110110
{
111111
inputs = {
112112
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
@@ -115,8 +115,6 @@ Suppose you want to pass a certain dependency to a submodule for use. You can us
115115
116116
outputs = inputs@{ self, nixpkgs, another-input, ... }: {
117117
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
118-
system = "x86_64-linux";
119-
120118
# Set all inputs parameters as special arguments for all submodules,
121119
# so you can directly use all dependencies in inputs in submodules
122120
specialArgs = { inherit inputs; };
@@ -130,15 +128,14 @@ Suppose you want to pass a certain dependency to a submodule for use. You can us
130128

131129
Or you can achieve the same effect using the `_module.args` option:
132130

133-
```nix{14}
131+
```nix{13}
134132
{
135133
inputs = {
136134
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
137135
another-input.url = "github:username/repo-name/branch-name";
138136
};
139137
outputs = inputs@{ self, nixpkgs, another-input, ... }: {
140138
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
141-
system = "x86_64-linux";
142139
modules = [
143140
./configuration.nix
144141
{
@@ -185,7 +182,7 @@ of Helix directly.
185182

186183
First, add the helix input data source to `flake.nix`:
187184

188-
```nix{6,12,18}
185+
```nix{6,11,17}
189186
{
190187
inputs = {
191188
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
@@ -196,7 +193,6 @@ First, add the helix input data source to `flake.nix`:
196193
197194
outputs = inputs@{ self, nixpkgs, ... }: {
198195
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
199-
system = "x86_64-linux";
200196
specialArgs = { inherit inputs; };
201197
modules = [
202198
./configuration.nix

docs/en/nixos-with-flakes/nixos-flake-configuration-explained.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Now let's look at `outputs`. It is a function that takes the dependencies from `
4040
its parameters, and its return value is an attribute set, which represents the build
4141
results of the flake:
4242

43-
```nix{11-19}
43+
```nix{9-16}
4444
{
4545
description = "A simple NixOS flake";
4646
@@ -52,7 +52,6 @@ results of the flake:
5252
outputs = { self, nixpkgs, ... }@inputs: {
5353
# The host with the hostname `my-nixos` will use this configuration
5454
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
55-
system = "x86_64-linux";
5655
modules = [
5756
./configuration.nix
5857
];
@@ -138,7 +137,7 @@ From the source code of the Nixpkgs repository, we can see that its flake output
138137
definition includes the `lib` attribute, and in our example, we use the `lib` attribute's
139138
`nixosSystem` function to configure our NixOS system:
140139

141-
```nix{8-13}
140+
```nix{8-12}
142141
{
143142
inputs = {
144143
# NixOS official package source, here using the nixos-25.05 branch
@@ -147,7 +146,6 @@ definition includes the `lib` attribute, and in our example, we use the `lib` at
147146
148147
outputs = { self, nixpkgs, ... }@inputs: {
149148
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
150-
system = "x86_64-linux";
151149
modules = [
152150
./configuration.nix
153151
];

docs/en/nixos-with-flakes/nixos-with-flakes-enabled.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Referencing this template, create the file `/etc/nixos/flake.nix` and write the
7373
configuration content. All subsequent system modifications will be taken over by Nix
7474
Flakes. Here's an example of the content:
7575

76-
```nix{16}
76+
```nix{15}
7777
{
7878
description = "A simple NixOS flake";
7979
@@ -85,7 +85,6 @@ Flakes. Here's an example of the content:
8585
outputs = { self, nixpkgs, ... }@inputs: {
8686
# Please replace my-nixos with your hostname
8787
nixosConfigurations.my-nixos = nixpkgs.lib.nixosSystem {
88-
system = "x86_64-linux";
8988
modules = [
9089
# Import the previous configuration.nix we used,
9190
# so the old configuration file still takes effect

docs/en/nixos-with-flakes/start-using-home-manager.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ After adjusting the parameters, the content of `/etc/nixos/flake.nix` is as foll
199199
nixosConfigurations = {
200200
# TODO please change the hostname to your own
201201
my-nixos = nixpkgs.lib.nixosSystem {
202-
system = "x86_64-linux";
203202
modules = [
204203
./configuration.nix
205204

docs/en/nixpkgs/overlays.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ One example of importing the above configuration as a NixOS module is as follows
8888
outputs = inputs@{ nixpkgs, ... }: {
8989
nixosConfigurations = {
9090
my-nixos = nixpkgs.lib.nixosSystem {
91-
system = "x86_64-linux";
9291
modules = [
9392
./configuration.nix
9493

docs/en/other-usage-of-flakes/module-system.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ Let's start with a simple example:
223223
outputs = {nixpkgs, ...}: {
224224
nixosConfigurations = {
225225
"test" = nixpkgs.lib.nixosSystem {
226-
system = "x86_64-linux";
227226
modules = [
228227
({config, lib, ...}: {
229228
options = {
@@ -337,7 +336,6 @@ The first thought might be to directly use `imports` in `config = { ... };`, lik
337336
outputs = {nixpkgs, ...}: {
338337
nixosConfigurations = {
339338
"test" = nixpkgs.lib.nixosSystem {
340-
system = "x86_64-linux";
341339
modules = [
342340
({config, lib, ...}: {
343341
options = {
@@ -402,7 +400,6 @@ Let's look at an example directly:
402400
outputs = {nixpkgs, ...}: {
403401
nixosConfigurations = {
404402
"test" = nixpkgs.lib.nixosSystem {
405-
system = "x86_64-linux";
406403
specialArgs = { enableFoo = true; };
407404
modules = [
408405
({config, lib, enableFoo ? false, ...}: {

0 commit comments

Comments
 (0)