146: style: Add config for style normalisation and re-apply r=Lassulus a=cscutcher



Co-authored-by: Chris Scutcher <chris@scutcher.uk>
This commit is contained in:
bors[bot] 2023-02-14 05:03:24 +00:00 committed by GitHub
commit 9afae0ba36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 73 additions and 47 deletions

View file

@ -16,7 +16,7 @@ let
}; };
in in
{ {
inherit types; types = types;
create = cfg: types.diskoLib.create (eval cfg).config.devices; create = cfg: types.diskoLib.create (eval cfg).config.devices;
createScript = cfg: pkgs: pkgs.writeScript "disko-create" '' createScript = cfg: pkgs: pkgs.writeScript "disko-create" ''
#!/usr/bin/env bash #!/usr/bin/env bash

View file

@ -19,7 +19,7 @@ let
]; ];
}; };
options = nixosOptionsDoc { options = nixosOptionsDoc {
inherit (eval) options; options = eval.options;
}; };
md = (runCommand "disko-options.md" { } '' md = (runCommand "disko-options.md" { } ''
cat >$out <<EOF cat >$out <<EOF

View file

@ -1,8 +1,8 @@
{ { pkgs
pkgs, , lib
lib, , ...
... }:
}: let let
# We just import from the repository for testing here: # We just import from the repository for testing here:
disko = import ../../. { disko = import ../../. {
inherit lib; inherit lib;
@ -41,7 +41,8 @@
}; };
}; };
}; };
in { in
{
imports = [ imports = [
(disko.config cfg) (disko.config cfg)
]; ];

View file

@ -1,7 +1,7 @@
# Example to create a bios compatible gpt partition # Example to create a bios compatible gpt partition
{ disks ? [ "/dev/vdb" ], lib, ... }: { { disks ? [ "/dev/vdb" ], lib, ... }: {
disk = lib.genAttrs [ (lib.head disks) ] (device: { disk = lib.genAttrs [ (lib.head disks) ] (device: {
inherit device; device = device;
type = "disk"; type = "disk";
content = { content = {
type = "table"; type = "table";

View file

@ -57,5 +57,22 @@
''; '';
in in
nixosTests // { inherit shellcheck; }); nixosTests // { inherit shellcheck; });
formatter = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.writeShellApplication {
name = "normalise_nix";
runtimeInputs = with pkgs; [
nixpkgs-fmt
statix
];
text = ''
set -o xtrace
nixpkgs-fmt "$@"
statix fix "$@"
'';
}
);
}; };
} }

View file

@ -2,7 +2,7 @@
let let
types = import ./types { types = import ./types {
inherit lib; inherit lib;
inherit (config.disko) rootMountPoint; rootMountPoint = config.disko.rootMountPoint;
}; };
cfg = config.disko; cfg = config.disko;
in in

4
statix.toml Normal file
View file

@ -0,0 +1,4 @@
disabled = [
"manual_inherit", # Prefer `inherit types;` instead of `types = types;`
"manual_inherit_from", # Prefer `inherit (eval) options;` instead of `options = eval.options`.
]

View file

@ -14,11 +14,13 @@ makeDiskoTest {
extraConfig = { extraConfig = {
boot.supportedFilesystems = [ "bcachefs" ]; boot.supportedFilesystems = [ "bcachefs" ];
# disable zfs so we can support latest kernel # disable zfs so we can support latest kernel
nixpkgs.overlays = [(final: super: { nixpkgs.overlays = [
(final: super: {
zfs = super.zfs.overrideAttrs (_: { zfs = super.zfs.overrideAttrs (_: {
meta.platforms = [ ]; meta.platforms = [ ];
}); });
})]; })
];
boot.kernelPackages = pkgs.lib.mkForce (pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux-bcachefs)); boot.kernelPackages = pkgs.lib.mkForce (pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux-bcachefs));
}; };
} }

View file

@ -3,12 +3,14 @@
, pkgs ? (import <nixpkgs> { }) , pkgs ? (import <nixpkgs> { })
}@args: }@args:
let let
inherit (pkgs) lib; lib = pkgs.lib;
inherit ((pkgs.callPackage ./lib.nix { inherit makeTest eval-config; })) makeDiskoTest; makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest eval-config; }).makeDiskoTest;
evalTest = name: configFile: let evalTest = name: configFile:
let
disko-config = import configFile; disko-config = import configFile;
in { in
{
"${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config); "${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
"${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config); "${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
}; };

View file

@ -17,7 +17,7 @@
, testBoot ? true # if we actually want to test booting or just create/mount , testBoot ? true # if we actually want to test booting or just create/mount
}: }:
let let
inherit (pkgs) lib; lib = pkgs.lib;
makeTest' = args: makeTest' = args:
makeTest args { makeTest args {
inherit pkgs; inherit pkgs;

View file

@ -189,7 +189,7 @@ rec {
internal = true; internal = true;
readOnly = true; readOnly = true;
type = lib.types.functionTo diskoLib.jsonType; type = lib.types.functionTo diskoLib.jsonType;
inherit (attrs) default; default = attrs.default;
description = "Mount script"; description = "Mount script";
}; };

View file

@ -42,7 +42,7 @@
vgchange -a y vgchange -a y
${lib.concatMapStrings (x: x.dev or "") (lib.attrValues lvMounts)} ${lib.concatMapStrings (x: x.dev or "") (lib.attrValues lvMounts)}
''; '';
inherit (lvMounts) fs; fs = lvMounts.fs;
}; };
}; };
_config = lib.mkOption { _config = lib.mkOption {

View file

@ -54,8 +54,8 @@
readOnly = true; readOnly = true;
default = [{ default = [{
fileSystems.${config.mountpoint} = { fileSystems.${config.mountpoint} = {
inherit (config) device; device = config.device;
inherit (config) fsType; fsType = config.fsType;
options = config.mountOptions; options = config.mountOptions;
}; };
}]; }];

View file

@ -40,7 +40,7 @@
default = dev: [{ default = dev: [{
swapDevices = [{ swapDevices = [{
device = dev; device = dev;
inherit (config) randomEncryption; randomEncryption = config.randomEncryption;
}]; }];
}]; }];
description = "NixOS configuration"; description = "NixOS configuration";