feat: introduce treefmt and fmt all

This commit is contained in:
steveej 2024-11-15 10:17:56 +01:00
parent 80250b0179
commit 5d5282a914
213 changed files with 4967 additions and 4423 deletions

View file

@ -4,18 +4,17 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.hardware.opinionatedDisk;
ownLib = pkgs.callPackage ../lib/default.nix {};
ownLib = pkgs.callPackage ../lib/default.nix { };
earlyDiskId = cfg:
if cfg.earlyDiskIdOverride != ""
then cfg.earlyDiskIdOverride
else cfg.diskId;
in {
earlyDiskId = cfg: if cfg.earlyDiskIdOverride != "" then cfg.earlyDiskIdOverride else cfg.diskId;
in
{
options.hardware.opinionatedDisk = {
enable = mkEnableOption "Enable opinionated filesystem layout";
diskId = mkOption {type = types.str;};
diskId = mkOption { type = types.str; };
encrypted = mkOption {
default = true;
type = types.bool;
@ -36,31 +35,30 @@ in {
fileSystems."/" = {
device = ownLib.disk.rootFsDevice cfg.diskId;
fsType = "btrfs";
options = ["subvol=nixos"];
options = [ "subvol=nixos" ];
};
fileSystems."/home" = {
device = ownLib.disk.rootFsDevice cfg.diskId;
fsType = "btrfs";
options = ["subvol=home"];
options = [ "subvol=home" ];
};
swapDevices = [{device = ownLib.disk.swapFsDevice cfg.diskId;}];
swapDevices = [ { device = ownLib.disk.swapFsDevice cfg.diskId; } ];
boot.loader.grub = {
device = ownLib.disk.bootGrubDevice (earlyDiskId cfg);
enableCryptodisk = cfg.encrypted;
};
boot.initrd.luks.devices =
lib.optionalAttrs cfg.encrypted
(builtins.listToAttrs [
boot.initrd.luks.devices = lib.optionalAttrs cfg.encrypted (
builtins.listToAttrs [
{
name = let
splitstring =
builtins.split "/" (ownLib.disk.bootLuksDevice cfg.diskId);
lastelem = (builtins.length splitstring) - 1;
in
name =
let
splitstring = builtins.split "/" (ownLib.disk.bootLuksDevice cfg.diskId);
lastelem = (builtins.length splitstring) - 1;
in
builtins.elemAt splitstring lastelem;
value = {
device = ownLib.disk.bootLuksDevice cfg.diskId;
@ -69,6 +67,7 @@ in {
allowDiscards = true;
};
}
]);
]
);
};
}