style: Apply nixpkgs-fmt and fix

Apply standard formatting and some statix conventions using;

```sh
nixpkgs-fmt **.nix && statix fix .
```

With the intent of making contribution a bit easier and reducing mental
load in hand formatting (in the same vein as [black]).

[black]: https://github.com/psf/black#the-uncompromising-code-formatter
This commit is contained in:
Chris Scutcher 2023-02-06 14:24:34 +00:00
parent b1a4ecb8ca
commit 08435eec4b
No known key found for this signature in database
GPG key ID: 19C0BED130CD39CE
23 changed files with 171 additions and 158 deletions

View file

@ -26,15 +26,15 @@
readOnly = true;
type = lib.types.functionTo diskoLib.jsonType;
default = dev:
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
lib.optionalAttrs (config.content != null) (config.content._meta dev);
description = "Metadata";
};
_create = diskoLib.mkCreateOption {
inherit config options;
default = { dev }: ''
cryptsetup -q luksFormat ${dev} ${diskoLib.maybeStr config.keyFile} ${toString config.extraArgs}
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/mapper/${config.name}";})}
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"}
${lib.optionalString (config.content != null) (config.content._create {dev = "/dev/mapper/${config.name}";})}
'';
};
_mount = diskoLib.mkMountOption {
@ -46,10 +46,10 @@
{
dev = ''
cryptsetup status ${config.name} >/dev/null 2>/dev/null ||
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (!isNull config.keyFile) "--key-file ${config.keyFile}"}
${lib.optionalString (!isNull config.content) contentMount.dev or ""}
cryptsetup luksOpen ${dev} ${config.name} ${lib.optionalString (config.keyFile != null) "--key-file ${config.keyFile}"}
${lib.optionalString (config.content != null) contentMount.dev or ""}
'';
fs = lib.optionalAttrs (!isNull config.content) contentMount.fs or { };
fs = lib.optionalAttrs (config.content != null) contentMount.fs or { };
};
};
_config = lib.mkOption {
@ -59,14 +59,14 @@
[
# TODO do we need this always in initrd and only there?
{ boot.initrd.luks.devices.${config.name}.device = dev; }
] ++ (lib.optional (!isNull config.content) (config.content._config "/dev/mapper/${config.name}"));
] ++ (lib.optional (config.content != null) (config.content._config "/dev/mapper/${config.name}"));
description = "NixOS configuration";
};
_pkgs = lib.mkOption {
internal = true;
readOnly = true;
type = lib.types.functionTo (lib.types.listOf lib.types.package);
default = pkgs: [ pkgs.cryptsetup ] ++ (lib.optionals (!isNull config.content) (config.content._pkgs pkgs));
default = pkgs: [ pkgs.cryptsetup ] ++ (lib.optionals (config.content != null) (config.content._pkgs pkgs));
description = "Packages";
};
};