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 #! /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= CHECK_ARG=
@ -20,13 +20,11 @@ find . -name '*.nix' \
\ \
! -path ./home-manager/default.nix \ ! -path ./home-manager/default.nix \
! -path ./home-manager/home-manager.nix \ ! -path ./home-manager/home-manager.nix \
! -path ./modules/accounts/email.nix \
! -path ./modules/default.nix \ ! -path ./modules/default.nix \
! -path ./modules/files.nix \ ! -path ./modules/files.nix \
! -path ./modules/home-environment.nix \ ! -path ./modules/home-environment.nix \
! -path ./modules/lib/default.nix \ ! -path ./modules/lib/default.nix \
! -path ./modules/lib/file-type.nix \ ! -path ./modules/lib/file-type.nix \
! -path ./modules/lib/types.nix \
! -path ./modules/manual.nix \ ! -path ./modules/manual.nix \
! -path ./modules/misc/dconf.nix \ ! -path ./modules/misc/dconf.nix \
! -path ./modules/misc/gtk.nix \ ! -path ./modules/misc/gtk.nix \
@ -59,8 +57,6 @@ find . -name '*.nix' \
! -path ./tests/modules/home-environment/session-variables.nix \ ! -path ./tests/modules/home-environment/session-variables.nix \
! -path ./tests/modules/programs/gpg/override-defaults.nix \ ! -path ./tests/modules/programs/gpg/override-defaults.nix \
! -path ./tests/modules/programs/tmux/default.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/programs/zsh/session-variables.nix \
! -path ./tests/modules/services/sxhkd/service.nix \ ! -path ./tests/modules/services/sxhkd/service.nix \
! -path ./tests/modules/systemd/default.nix \ ! -path ./tests/modules/systemd/default.nix \

View file

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

View file

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

View file

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

View file

@ -11,7 +11,9 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh 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
}
''; '';
}; };
} }