Skip to content

Commit bec0dc5

Browse files
parzivaleaanderse
authored andcommitted
flake: add nixfmt-tree formatter
1 parent f2acbff commit bec0dc5

8 files changed

Lines changed: 70 additions & 33 deletions

File tree

flake.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,16 @@
2525
inherit (config._module.args) pkgs;
2626
inherit lib;
2727
};
28+
29+
formatter =
30+
let
31+
sources = import ./lon.nix;
32+
lib = import (sources.nixpkgs + "/lib");
33+
34+
pkgsFor = system: import sources.nixpkgs { inherit system; };
35+
in
36+
lib.genAttrs' [ "aarch64-linux" "x86_64-linux" ] (
37+
system: lib.nameValuePair system (pkgsFor system).nixfmt-tree
38+
);
2839
};
2940
}

modules/filesystems/default.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,13 @@ in
143143
# <file system> <mount point> <type> <options> <dump> <pass>
144144
145145
# filesystems
146-
${makeFstabEntries (lib.filter (fs: !lib.elem fs.fsType [ "luks" "lvm" ]) fileSystems) { }}
146+
${makeFstabEntries (lib.filter (
147+
fs:
148+
!lib.elem fs.fsType [
149+
"luks"
150+
"lvm"
151+
]
152+
) fileSystems) { }}
147153
148154
# swap devices
149155
${lib.concatMapStrings makeSwapEntry config.swapDevices}

modules/filesystems/fuse.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ in
1919
};
2020
in
2121
{
22-
boot = (fuseEnable true ''
23-
Whether to enable support for the `fuse` filesystem.
24-
'') // {
25-
initrd = fuseEnable false ''
26-
Whether to enable support for the `fuse` filesystem in the initial ramdisk.
27-
'';
28-
};
22+
boot =
23+
(fuseEnable true ''
24+
Whether to enable support for the `fuse` filesystem.
25+
'')
26+
// {
27+
initrd = fuseEnable false ''
28+
Whether to enable support for the `fuse` filesystem in the initial ramdisk.
29+
'';
30+
};
2931
};
3032

3133
config = lib.mkIf (cfg.enable || cfgInitrd.enable) {

modules/filesystems/luks.nix

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
packages = lib.mkOption {
1919
type = with lib.types; listOf package;
20-
default = [pkgs.cryptsetup];
20+
default = [ pkgs.cryptsetup ];
2121
description = ''
2222
Packages providing LUKS utilities in the initial ramdisk.
2323
'';
@@ -35,7 +35,7 @@
3535

3636
packages = lib.mkOption {
3737
type = with lib.types; listOf package;
38-
default = [pkgs.cryptsetup];
38+
default = [ pkgs.cryptsetup ];
3939
description = ''
4040
Packages providing LUKS utilities.
4141
'';
@@ -63,17 +63,22 @@
6363
"algif_skcipher"
6464
"cryptd"
6565
"input_leds"
66-
] ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "7.0") [ "aes_generic" ];
66+
]
67+
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "7.0") [
68+
"aes_generic"
69+
];
6770

68-
boot.initrd.fileSystemImportCommands = lib.mkOrder 500 (lib.concatStringsSep "\n" (
69-
lib.mapAttrsToList (
70-
name: dev:
71-
let
72-
fsOpts = lib.concatStringsSep " " dev.options;
73-
in
74-
"cryptsetup open ${fsOpts} ${dev.device} ${name}"
75-
) (lib.filterAttrs (_: fs: fs.fsType == "luks") config.fileSystems)
76-
));
71+
boot.initrd.fileSystemImportCommands = lib.mkOrder 500 (
72+
lib.concatStringsSep "\n" (
73+
lib.mapAttrsToList (
74+
name: dev:
75+
let
76+
fsOpts = lib.concatStringsSep " " dev.options;
77+
in
78+
"cryptsetup open ${fsOpts} ${dev.device} ${name}"
79+
) (lib.filterAttrs (_: fs: fs.fsType == "luks") config.fileSystems)
80+
)
81+
);
7782
})
7883
];
7984
}

modules/filesystems/lvm.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pkgs,
44
lib,
55
...
6-
}:
6+
}:
77
{
88
options = {
99
boot.initrd.supportedFilesystems.lvm = {
@@ -17,7 +17,7 @@
1717

1818
packages = lib.mkOption {
1919
type = with lib.types; listOf package;
20-
default = [pkgs.lvm2];
20+
default = [ pkgs.lvm2 ];
2121
description = ''
2222
Packages providing LVM utilities in the initial ramdisk.
2323
'';
@@ -35,7 +35,7 @@
3535

3636
packages = lib.mkOption {
3737
type = with lib.types; listOf package;
38-
default = [pkgs.lvm2];
38+
default = [ pkgs.lvm2 ];
3939
description = ''
4040
Packages providing lvm utilities.
4141
'';
@@ -45,11 +45,11 @@
4545

4646
config = lib.mkMerge [
4747
(lib.mkIf config.boot.supportedFilesystems.lvm.enable {
48-
boot.kernelModules = ["dm_mod"];
48+
boot.kernelModules = [ "dm_mod" ];
4949
})
5050

5151
(lib.mkIf config.boot.initrd.supportedFilesystems.lvm.enable {
52-
boot.initrd.kernelModules = ["dm_mod"];
52+
boot.initrd.kernelModules = [ "dm_mod" ];
5353

5454
boot.initrd.fileSystemImportCommands = lib.mkOrder 600 (
5555
if config.services.udev.enable || !config.services.mdevd.enable then

modules/finit/initrd.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ in
127127
128128
${lib.concatMapStringsSep "\n" mkMount (
129129
lib.filter (lib.getAttr "neededForBoot") (
130-
lib.filter (fs: !lib.elem fs.fsType [ "luks" "lvm" ]) (lib.attrValues config.fileSystems)
130+
lib.filter (
131+
fs:
132+
!lib.elem fs.fsType [
133+
"luks"
134+
"lvm"
135+
]
136+
) (lib.attrValues config.fileSystems)
131137
)
132138
)}
133139
'';

modules/nixos/meta-maintainers.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ in
4646
maintainers = mkOption {
4747
type = listOfMaintainers;
4848
default = [ ];
49-
example = lib.literalExpression ''[ lib.maintainers.alice lib.maintainers.bob ]'';
49+
example = lib.literalExpression "[ lib.maintainers.alice lib.maintainers.bob ]";
5050
description = ''
5151
List of maintainers of each module.
5252
This option should be defined at most once per module.

modules/programs/zzz/providers.resume-and-suspend.nix

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ let
1313
in
1414
padding + s;
1515

16-
mkHook = mode: k: v:
16+
mkHook =
17+
mode: k: v:
1718
let
1819
name = "zzz.d/${zeroPad 4 v.priority}-${k}.sh";
1920
script = pkgs.writeShellScript k ''
@@ -24,7 +25,8 @@ let
2425
in
2526
lib.nameValuePair name { source = script; };
2627

27-
mkResumeHook = k: v:
28+
mkResumeHook =
29+
k: v:
2830
let
2931
name = "zzz.d/${zeroPad 4 v.priority}-${k}.sh";
3032
script = pkgs.writeShellScript k ''
@@ -44,12 +46,17 @@ in
4446
config = lib.mkIf (config.providers.resumeAndSuspend.backend == "zzz") {
4547
environment.etc =
4648
let
47-
filtered = event: lib.filterAttrs (_: v: v.enable && v.event == event) config.providers.resumeAndSuspend.hooks;
49+
filtered =
50+
event: lib.filterAttrs (_: v: v.enable && v.event == event) config.providers.resumeAndSuspend.hooks;
4851

49-
suspend = lib.mapAttrs' (k: v: mkHook "suspend" k v) (filtered "suspend");
50-
hibernate = lib.mapAttrs' (k: v: mkHook "hibernate" k v) (filtered "hibernate");
52+
suspend = lib.mapAttrs' (k: v: mkHook "suspend" k v) (filtered "suspend");
53+
hibernate = lib.mapAttrs' (k: v: mkHook "hibernate" k v) (filtered "hibernate");
5154
resume = lib.mapAttrs' (k: v: mkResumeHook k v) (filtered "resume");
5255
in
53-
lib.mkMerge [ suspend hibernate resume ];
56+
lib.mkMerge [
57+
suspend
58+
hibernate
59+
resume
60+
];
5461
};
5562
}

0 commit comments

Comments
 (0)