Skip to content

Commit f9f7153

Browse files
committed
treewide: Format all Nix files
Format all Nix files using the officially approved formatter, making the CI check introduced in the previous commit succeed: nix-build ci -A fmt.check This is the next step of the of the [implementation](NixOS/nixfmt#153) of the accepted [RFC 166](NixOS/rfcs#166). This commit will lead to merge conflicts for a number of PRs, up to an estimated ~1100 (~33%) among the PRs with activity in the past 2 months, but that should be lower than what it would be without the previous [partial treewide format](NixOS#322537). Merge conflicts caused by this commit can now automatically be resolved while rebasing using the [auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase). If you run into any problems regarding any of this, please reach out to the [formatting team](https://nixos.org/community/teams/formatting/) by pinging @NixOS/nix-formatting.
1 parent 882c4d2 commit f9f7153

File tree

1,632 files changed

+1010172
-530943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,632 files changed

+1010172
-530943
lines changed

flake.nix

+137-100
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
{
44
description = "A collection of packages for the Nix package manager";
55

6-
outputs = { self }:
6+
outputs =
7+
{ self }:
78
let
89
libVersionInfoOverlay = import ./lib/flake-version-info.nix self;
910
lib = (import ./lib).extend libVersionInfoOverlay;
1011

1112
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
1213

13-
jobs = forAllSystems (system: import ./pkgs/top-level/release.nix {
14-
nixpkgs = self;
15-
inherit system;
16-
});
14+
jobs = forAllSystems (
15+
system:
16+
import ./pkgs/top-level/release.nix {
17+
nixpkgs = self;
18+
inherit system;
19+
}
20+
);
1721
in
1822
{
1923
/**
@@ -26,112 +30,142 @@
2630
*/
2731
# DON'T USE lib.extend TO ADD NEW FUNCTIONALITY.
2832
# THIS WAS A MISTAKE. See the warning in lib/default.nix.
29-
lib = lib.extend (final: prev: {
33+
lib = lib.extend (
34+
final: prev: {
3035

31-
/**
32-
Other NixOS-provided functionality, such as [`runTest`](https://nixos.org/manual/nixos/unstable/#sec-call-nixos-test-outside-nixos).
33-
See also `lib.nixosSystem`.
34-
*/
35-
nixos = import ./nixos/lib { lib = final; };
36+
/**
37+
Other NixOS-provided functionality, such as [`runTest`](https://nixos.org/manual/nixos/unstable/#sec-call-nixos-test-outside-nixos).
38+
See also `lib.nixosSystem`.
39+
*/
40+
nixos = import ./nixos/lib { lib = final; };
3641

37-
/**
38-
Create a NixOS system configuration.
42+
/**
43+
Create a NixOS system configuration.
3944
40-
Example:
45+
Example:
4146
42-
lib.nixosSystem {
43-
modules = [ ./configuration.nix ];
44-
}
47+
lib.nixosSystem {
48+
modules = [ ./configuration.nix ];
49+
}
4550
46-
Inputs:
51+
Inputs:
4752
48-
- `modules` (list of paths or inline modules): The NixOS modules to include in the system configuration.
53+
- `modules` (list of paths or inline modules): The NixOS modules to include in the system configuration.
4954
50-
- `specialArgs` (attribute set): Extra arguments to pass to all modules, that are available in `imports` but can not be extended or overridden by the `modules`.
55+
- `specialArgs` (attribute set): Extra arguments to pass to all modules, that are available in `imports` but can not be extended or overridden by the `modules`.
5156
52-
- `modulesLocation` (path): A default location for modules that aren't passed by path, used for error messages.
57+
- `modulesLocation` (path): A default location for modules that aren't passed by path, used for error messages.
5358
54-
Legacy inputs:
59+
Legacy inputs:
5560
56-
- `system`: Legacy alias for `nixpkgs.hostPlatform`, but this is already set in the generated `hardware-configuration.nix`, included by `configuration.nix`.
57-
- `pkgs`: Legacy alias for `nixpkgs.pkgs`; use `nixpkgs.pkgs` and `nixosModules.readOnlyPkgs` instead.
58-
*/
59-
nixosSystem = args:
60-
import ./nixos/lib/eval-config.nix (
61+
- `system`: Legacy alias for `nixpkgs.hostPlatform`, but this is already set in the generated `hardware-configuration.nix`, included by `configuration.nix`.
62+
- `pkgs`: Legacy alias for `nixpkgs.pkgs`; use `nixpkgs.pkgs` and `nixosModules.readOnlyPkgs` instead.
63+
*/
64+
nixosSystem =
65+
args:
66+
import ./nixos/lib/eval-config.nix (
67+
{
68+
lib = final;
69+
# Allow system to be set modularly in nixpkgs.system.
70+
# We set it to null, to remove the "legacy" entrypoint's
71+
# non-hermetic default.
72+
system = null;
73+
74+
modules = args.modules ++ [
75+
# This module is injected here since it exposes the nixpkgs self-path in as
76+
# constrained of contexts as possible to avoid more things depending on it and
77+
# introducing unnecessary potential fragility to changes in flakes itself.
78+
#
79+
# See: failed attempt to make pkgs.path not copy when using flakes:
80+
# https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1023287913
81+
(
82+
{
83+
config,
84+
pkgs,
85+
lib,
86+
...
87+
}:
88+
{
89+
config.nixpkgs.flake.source = self.outPath;
90+
}
91+
)
92+
];
93+
}
94+
// builtins.removeAttrs args [ "modules" ]
95+
);
96+
}
97+
);
98+
99+
checks = forAllSystems (
100+
system:
101+
{
102+
tarball = jobs.${system}.tarball;
103+
}
104+
//
105+
lib.optionalAttrs
106+
(
107+
self.legacyPackages.${system}.stdenv.hostPlatform.isLinux
108+
# Exclude power64 due to "libressl is not available on the requested hostPlatform" with hostPlatform being power64
109+
&& !self.legacyPackages.${system}.targetPlatform.isPower64
110+
)
61111
{
62-
lib = final;
63-
# Allow system to be set modularly in nixpkgs.system.
64-
# We set it to null, to remove the "legacy" entrypoint's
65-
# non-hermetic default.
66-
system = null;
67-
68-
modules = args.modules ++ [
69-
# This module is injected here since it exposes the nixpkgs self-path in as
70-
# constrained of contexts as possible to avoid more things depending on it and
71-
# introducing unnecessary potential fragility to changes in flakes itself.
72-
#
73-
# See: failed attempt to make pkgs.path not copy when using flakes:
74-
# https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1023287913
75-
({ config, pkgs, lib, ... }: {
76-
config.nixpkgs.flake.source = self.outPath;
77-
})
78-
];
79-
} // builtins.removeAttrs args [ "modules" ]
80-
);
81-
});
82-
83-
checks = forAllSystems (system: {
84-
tarball = jobs.${system}.tarball;
85-
} // lib.optionalAttrs
86-
(
87-
self.legacyPackages.${system}.stdenv.hostPlatform.isLinux
88-
# Exclude power64 due to "libressl is not available on the requested hostPlatform" with hostPlatform being power64
89-
&& !self.legacyPackages.${system}.targetPlatform.isPower64
90-
)
91-
{
92-
# Test that ensures that the nixosSystem function can accept a lib argument
93-
# Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules
94-
# alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>`
95-
nixosSystemAcceptsLib = (self.lib.nixosSystem {
96-
pkgs = self.legacyPackages.${system};
97-
lib = self.lib.extend (final: prev: {
98-
ifThisFunctionIsMissingTheTestFails = final.id;
99-
});
100-
modules = [
101-
./nixos/modules/profiles/minimal.nix
102-
({ lib, ... }: lib.ifThisFunctionIsMissingTheTestFails {
103-
# Define a minimal config without eval warnings
104-
nixpkgs.hostPlatform = "x86_64-linux";
105-
boot.loader.grub.enable = false;
106-
fileSystems."/".device = "nodev";
107-
# See https://search.nixos.org/options?show=system.stateVersion&query=stateversion
108-
system.stateVersion = lib.trivial.release; # DON'T do this in real configs!
109-
})
110-
];
111-
}).config.system.build.toplevel;
112-
});
112+
# Test that ensures that the nixosSystem function can accept a lib argument
113+
# Note: prefer not to extend or modify `lib`, especially if you want to share reusable modules
114+
# alternatives include: `import` a file, or put a custom library in an option or in `_module.args.<libname>`
115+
nixosSystemAcceptsLib =
116+
(self.lib.nixosSystem {
117+
pkgs = self.legacyPackages.${system};
118+
lib = self.lib.extend (
119+
final: prev: {
120+
ifThisFunctionIsMissingTheTestFails = final.id;
121+
}
122+
);
123+
modules = [
124+
./nixos/modules/profiles/minimal.nix
125+
(
126+
{ lib, ... }:
127+
lib.ifThisFunctionIsMissingTheTestFails {
128+
# Define a minimal config without eval warnings
129+
nixpkgs.hostPlatform = "x86_64-linux";
130+
boot.loader.grub.enable = false;
131+
fileSystems."/".device = "nodev";
132+
# See https://search.nixos.org/options?show=system.stateVersion&query=stateversion
133+
system.stateVersion = lib.trivial.release; # DON'T do this in real configs!
134+
}
135+
)
136+
];
137+
}).config.system.build.toplevel;
138+
}
139+
);
113140

114141
htmlDocs = {
115142
nixpkgsManual = builtins.mapAttrs (_: jobSet: jobSet.manual) jobs;
116-
nixosManual = (import ./nixos/release-small.nix {
117-
nixpkgs = self;
118-
}).nixos.manual;
143+
nixosManual =
144+
(import ./nixos/release-small.nix {
145+
nixpkgs = self;
146+
}).nixos.manual;
119147
};
120148

121-
devShells = forAllSystems (system:
122-
{ } // lib.optionalAttrs
123-
(
124-
# Exclude armv6l-linux because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
125-
system != "armv6l-linux"
126-
# Exclude riscv64-linux because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
127-
&& system != "riscv64-linux"
128-
# Exclude FreeBSD because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
129-
&& !self.legacyPackages.${system}.stdenv.hostPlatform.isFreeBSD
130-
)
131-
{
132-
/** A shell to get tooling for Nixpkgs development. See nixpkgs/shell.nix. */
133-
default = import ./shell.nix { inherit system; };
134-
});
149+
devShells = forAllSystems (
150+
system:
151+
{ }
152+
//
153+
lib.optionalAttrs
154+
(
155+
# Exclude armv6l-linux because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
156+
system != "armv6l-linux"
157+
# Exclude riscv64-linux because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
158+
&& system != "riscv64-linux"
159+
# Exclude FreeBSD because "Package ‘ghc-9.6.6’ in .../pkgs/development/compilers/ghc/common-hadrian.nix:579 is not available on the requested hostPlatform"
160+
&& !self.legacyPackages.${system}.stdenv.hostPlatform.isFreeBSD
161+
)
162+
{
163+
/**
164+
A shell to get tooling for Nixpkgs development. See nixpkgs/shell.nix.
165+
*/
166+
default = import ./shell.nix { inherit system; };
167+
}
168+
);
135169

136170
formatter = forAllSystems (system: (import ./ci { inherit system; }).fmt.pkg);
137171

@@ -154,10 +188,13 @@
154188
evaluation. Evaluating the attribute value tends to require a significant
155189
amount of computation, even considering lazy evaluation.
156190
*/
157-
legacyPackages = forAllSystems (system:
158-
(import ./. { inherit system; }).extend (final: prev: {
159-
lib = prev.lib.extend libVersionInfoOverlay;
160-
})
191+
legacyPackages = forAllSystems (
192+
system:
193+
(import ./. { inherit system; }).extend (
194+
final: prev: {
195+
lib = prev.lib.extend libVersionInfoOverlay;
196+
}
197+
)
161198
);
162199

163200
/**
@@ -176,7 +213,7 @@
176213
};
177214
};
178215
};
179-
*/
216+
*/
180217
nixosModules = {
181218
notDetected = ./nixos/modules/installer/scan/not-detected.nix;
182219

0 commit comments

Comments
 (0)