Update nixfmt and apply to a few more files

This commit is contained in:
Robert Helgesson 2020-04-06 12:51:11 +02:00
parent dd93c300bb
commit a128e35927
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 55 additions and 86 deletions

6
format
View file

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/b0bbacb52134a7e731e549f4c0a7a2a39ca6b481.tar.gz -i bash -p findutils nixfmt
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p findutils nixfmt
CHECK_ARG=
@ -20,13 +20,11 @@ find . -name '*.nix' \
\
! -path ./home-manager/default.nix \
! -path ./home-manager/home-manager.nix \
! -path ./modules/accounts/email.nix \
! -path ./modules/default.nix \
! -path ./modules/files.nix \
! -path ./modules/home-environment.nix \
! -path ./modules/lib/default.nix \
! -path ./modules/lib/file-type.nix \
! -path ./modules/lib/types.nix \
! -path ./modules/manual.nix \
! -path ./modules/misc/dconf.nix \
! -path ./modules/misc/gtk.nix \
@ -59,8 +57,6 @@ find . -name '*.nix' \
! -path ./tests/modules/home-environment/session-variables.nix \
! -path ./tests/modules/programs/gpg/override-defaults.nix \
! -path ./tests/modules/programs/tmux/default.nix \
! -path ./tests/modules/programs/tmux/disable-confirmation-prompt.nix \
! -path ./tests/modules/programs/tmux/secure-socket-enabled.nix \
! -path ./tests/modules/programs/zsh/session-variables.nix \
! -path ./tests/modules/services/sxhkd/service.nix \
! -path ./tests/modules/systemd/default.nix \

View file

@ -332,9 +332,7 @@ let
(mkIf (config.flavor == "gmail.com") {
userName = mkDefault config.address;
imap = {
host = "imap.gmail.com";
};
imap = { host = "imap.gmail.com"; };
smtp = {
host = "smtp.gmail.com";
@ -343,20 +341,14 @@ let
})
(mkIf (config.flavor == "runbox.com") {
imap = {
host = "mail.runbox.com";
};
imap = { host = "mail.runbox.com"; };
smtp = {
host = "mail.runbox.com";
};
smtp = { host = "mail.runbox.com"; };
})
];
};
in
{
in {
options.accounts.email = {
certificatesFile = mkOption {
type = types.path;
@ -373,9 +365,7 @@ in
default = "${config.home.homeDirectory}/Maildir";
defaultText = "$HOME/Maildir";
apply = p:
if hasPrefix "/" p
then p
else "${config.home.homeDirectory}/${p}";
if hasPrefix "/" p then p else "${config.home.homeDirectory}/${p}";
description = ''
The base directory for account maildir directories. May be a
relative path, in which case it is relative the home
@ -395,9 +385,8 @@ in
(import ../programs/neomutt-accounts.nix)
(import ../programs/notmuch-accounts.nix)
(import ../programs/offlineimap-accounts.nix)
] ++ optionals pkgs.stdenv.hostPlatform.isLinux [
(import ../services/lieer-accounts.nix)
]));
] ++ optionals pkgs.stdenv.hostPlatform.isLinux
[ (import ../services/lieer-accounts.nix) ]));
default = { };
description = "List of email accounts.";
};
@ -405,22 +394,15 @@ in
config = mkIf (cfg.accounts != { }) {
assertions = [
(
let
(let
primaries =
catAttrs "name"
(filter (a: a.primary)
(attrValues cfg.accounts));
in
{
catAttrs "name" (filter (a: a.primary) (attrValues cfg.accounts));
in {
assertion = length primaries == 1;
message =
"Must have exactly one primary mail account but found "
+ toString (length primaries)
+ optionalString (length primaries > 1)
message = "Must have exactly one primary mail account but found "
+ toString (length primaries) + optionalString (length primaries > 1)
(", namely " + concatStringsSep ", " primaries);
}
)
})
];
};
}

View file

@ -1,7 +1,5 @@
{ lib
, dag ? import ./dag.nix { inherit lib; }
, gvariant ? import ./gvariant.nix { inherit lib; }
}:
{ lib, dag ? import ./dag.nix { inherit lib; }
, gvariant ? import ./gvariant.nix { inherit lib; } }:
with lib;
@ -13,30 +11,24 @@ let
# must refer back to the type.
gvar = gvariant;
in
rec {
in rec {
inherit (typesDag) dagOf listOrDagOf;
selectorFunction = mkOptionType {
name = "selectorFunction";
description =
"Function that takes an attribute set and returns a list"
description = "Function that takes an attribute set and returns a list"
+ " containing a selection of the values of the input set";
check = isFunction;
merge = _loc: defs:
as: concatMap (select: select as) (getValues defs);
merge = _loc: defs: as: concatMap (select: select as) (getValues defs);
};
overlayFunction = mkOptionType {
name = "overlayFunction";
description =
"An overlay function, takes self and super and returns"
description = "An overlay function, takes self and super and returns"
+ " an attribute set overriding the desired attributes.";
check = isFunction;
merge = _loc: defs:
self: super:
merge = _loc: defs: self: super:
foldl' (res: def: mergeAttrs res (def.value self super)) { } defs;
};
@ -76,14 +68,13 @@ rec {
# A bit naive to just check the first entry…
sharedDefType = foldl' sameOrNull (head defTypes) defTypes;
allChecked = all (x: check x) vals;
in
if sharedDefType == null then
in if sharedDefType == null then
throw ("Cannot merge definitions of `${showOption loc}' with"
+ " mismatched GVariant types given in"
+ " ${showFiles (getFiles defs)}.")
else if gvar.isArray sharedDefType && allChecked then
(types.listOf gvariant).merge
loc (map (d: d // { value = d.value.value; } ) vdefs)
(types.listOf gvariant).merge loc
(map (d: d // { value = d.value.value; }) vdefs)
else if gvar.isTuple sharedDefType && allChecked then
mergeOneOption loc defs
else if gvar.type.string == sharedDefType && allChecked then

View file

@ -12,9 +12,7 @@ with lib;
nixpkgs.overlays = [
(self: super: {
tmuxPlugins = super.tmuxPlugins // {
sensible = super.tmuxPlugins.sensible // {
rtp = "@sensible_rtp@";
};
sensible = super.tmuxPlugins.sensible // { rtp = "@sensible_rtp@"; };
};
})
];

View file

@ -11,7 +11,9 @@ with lib;
nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileContent home-path/etc/profile.d/hm-session-vars.sh ${./hm-session-vars.sh}
assertFileContent home-path/etc/profile.d/hm-session-vars.sh ${
./hm-session-vars.sh
}
'';
};
}