nixpkgs-fmt everything

This commit is contained in:
willemml 2023-03-20 08:49:39 -07:00
parent be200a87c2
commit 4a2bef980b
Signed by: willemml
GPG key ID: C3DE5DF6198DACBD
10 changed files with 98 additions and 89 deletions

View file

@ -1,7 +1,6 @@
{ writeShellApplication { writeShellApplication
, home-manager , home-manager
, stdenv , stdenv
,
}: }:
writeShellApplication { writeShellApplication {
name = "home-switch"; name = "home-switch";

View file

@ -5,11 +5,11 @@
# https://github.com/terlar/nix-config/blob/00c8a3622e8bc4cb522bbf335e6ede04ca07da40/flake-parts/apps.nix # https://github.com/terlar/nix-config/blob/00c8a3622e8bc4cb522bbf335e6ede04ca07da40/flake-parts/apps.nix
{lib, ...}: { { lib, ... }: {
perSystem = {pkgs, ...}: perSystem = { pkgs, ... }:
lib.pipe ../apps [ lib.pipe ../apps [
lib.filesystem.listFilesRecursive lib.filesystem.listFilesRecursive
(map (file: pkgs.callPackage file {})) (map (file: pkgs.callPackage file { }))
(map (drv: { (map (drv: {
apps.${drv.name} = { apps.${drv.name} = {
type = "app"; type = "app";
@ -17,6 +17,6 @@
}; };
checks."app-${drv.name}" = drv; checks."app-${drv.name}" = drv;
})) }))
(lib.fold lib.recursiveUpdate {}) (lib.fold lib.recursiveUpdate { })
]; ];
} }

View file

@ -4,13 +4,13 @@ let
inherit (flake-parts-lib) mkTransposedPerSystemModule; inherit (flake-parts-lib) mkTransposedPerSystemModule;
in in
mkTransposedPerSystemModule mkTransposedPerSystemModule
{ {
name = "homeConfigurations"; name = "homeConfigurations";
file = ./configurations.nix; file = ./configurations.nix;
option = mkOption { option = mkOption {
type = types.lazyAttrsOf types.unspecified; type = types.lazyAttrsOf types.unspecified;
default = { }; default = { };
description = "Home Manager user configurations."; description = "Home Manager user configurations.";
}; };
} }

View file

@ -5,29 +5,30 @@
# https://github.com/terlar/nix-config/blob/00c8a3622e8bc4cb522bbf335e6ede04ca07da40/flake-parts/home-manager/default.nix # https://github.com/terlar/nix-config/blob/00c8a3622e8bc4cb522bbf335e6ede04ca07da40/flake-parts/home-manager/default.nix
{ { lib
lib, , flake-parts-lib
flake-parts-lib, , self
self, , ...
... }:
}: let let
inherit inherit
(lib) (lib)
mkOption mkOption
types types
; ;
inherit (flake-parts-lib) mkSubmoduleOptions; inherit (flake-parts-lib) mkSubmoduleOptions;
in { in
imports = [./modules.nix ./users.nix ./configurations.nix]; {
imports = [ ./modules.nix ./users.nix ./configurations.nix ];
options = { options = {
flake = mkSubmoduleOptions { flake = mkSubmoduleOptions {
homeManagerModules = mkOption { homeManagerModules = mkOption {
type = types.lazyAttrsOf types.unspecified; type = types.lazyAttrsOf types.unspecified;
default = {}; default = { };
apply = lib.mapAttrs (k: v: { apply = lib.mapAttrs (k: v: {
_file = "${toString self.outPath}/flake.nix#homeManagerModules.${k}"; _file = "${toString self.outPath}/flake.nix#homeManagerModules.${k}";
imports = [v]; imports = [ v ];
}); });
description = '' description = ''
Home Manager modules. Home Manager modules.

View file

@ -18,7 +18,7 @@
default = { default = {
imports = builtins.attrValues modules; imports = builtins.attrValues modules;
}; };
nixpkgs-Config = { nixpkgs-Config = {
nixpkgs.config.allowUnfreePredicate = (_: true); nixpkgs.config.allowUnfreePredicate = (_: true);
nixpkgs.config.allowUnsupportedSystem = true; nixpkgs.config.allowUnsupportedSystem = true;

View file

@ -30,7 +30,7 @@
})) }))
builtins.listToAttrs builtins.listToAttrs
]; ];
mk-mac-binpkg = import ../../packages/mk-mac-binpkg.nix; mk-mac-binpkg = import ../../packages/mk-mac-binpkg.nix;
}; };
} }

View file

@ -23,10 +23,10 @@
]; ];
systems = [ systems = [
# "x86_64-linux" # "x86_64-linux"
# "x86_64-darwin" # "x86_64-darwin"
"aarch64-darwin" "aarch64-darwin"
# "aarch64-linux" # "aarch64-linux"
]; ];
}; };
} }

View file

@ -31,13 +31,15 @@ in
{ {
accounts.email.accounts = { accounts.email.accounts = {
gmail = (gmailAccount "willemleitso@gmail.com") // { realName = "Willem Leitso"; }; gmail = (gmailAccount "willemleitso@gmail.com") // { realName = "Willem Leitso"; };
icloud = (pkgs.lib.attrsets.recursiveUpdate { icloud = (pkgs.lib.attrsets.recursiveUpdate
flavor = "plain"; {
imap.host = "imap.mail.me.com"; flavor = "plain";
imap.port = 993; imap.host = "imap.mail.me.com";
smtp.host = "smtp.mail.me.com"; imap.port = 993;
smtp.port = 587; smtp.host = "smtp.mail.me.com";
} (generalAccount "coalminecraft@icloud.com")) // { folders.inbox = "INBOX"; }; smtp.port = 587;
}
(generalAccount "coalminecraft@icloud.com")) // { folders.inbox = "INBOX"; };
leitso = (gmailAccount "willem@leit.so") // { primary = true; realName = "Willem Leitso"; }; leitso = (gmailAccount "willem@leit.so") // { primary = true; realName = "Willem Leitso"; };
wnuke9 = gmailAccount "wnuke9@gmail.com"; wnuke9 = gmailAccount "wnuke9@gmail.com";
}; };

View file

@ -219,42 +219,45 @@ let
}; };
config = mkIf config.enable { config = mkIf config.enable {
assembly = let assembly =
quoted = v: ''"${escape [ ''"'' ] v}"''; let
mkBindHelper = cmd: prefix: bs: quoted = v: ''"${escape [ ''"'' ] v}"'';
optionals (bs != { }) ([ ":${cmd} (${prefix}" ] mkBindHelper = cmd: prefix: bs:
++ mapAttrsToList (n: v: " (${quoted n} . ${v})") bs ++ [ ")" ]); optionals (bs != { }) ([ ":${cmd} (${prefix}" ]
++ mapAttrsToList (n: v: " (${quoted n} . ${v})") bs ++ [ ")" ]);
mkAfter = vs: optional (vs != [ ]) ":after (${toString vs})"; mkAfter = vs: optional (vs != [ ]) ":after (${toString vs})";
mkCommand = vs: optional (vs != [ ]) ":commands (${toString vs})"; mkCommand = vs: optional (vs != [ ]) ":commands (${toString vs})";
mkDefines = vs: optional (vs != [ ]) ":defines (${toString vs})"; mkDefines = vs: optional (vs != [ ]) ":defines (${toString vs})";
mkDiminish = vs: optional (vs != [ ]) ":diminish (${toString vs})"; mkDiminish = vs: optional (vs != [ ]) ":diminish (${toString vs})";
mkMode = map (v: ":mode ${v}"); mkMode = map (v: ":mode ${v}");
mkFunctions = vs: optional (vs != [ ]) ":functions (${toString vs})"; mkFunctions = vs: optional (vs != [ ]) ":functions (${toString vs})";
mkBind = mkBindHelper "bind" ""; mkBind = mkBindHelper "bind" "";
mkBindLocal = bs: mkBindLocal = bs:
let mkMap = n: v: mkBindHelper "bind" ":map ${n}" v; let mkMap = n: v: mkBindHelper "bind" ":map ${n}" v;
in flatten (mapAttrsToList mkMap bs); in flatten (mapAttrsToList mkMap bs);
mkBindKeyMap = mkBindHelper "bind-keymap" ""; mkBindKeyMap = mkBindHelper "bind-keymap" "";
mkChords = mkBindHelper "chords" ""; mkChords = mkBindHelper "chords" "";
mkHook = map (v: ":hook ${v}"); mkHook = map (v: ":hook ${v}");
mkDefer = v: mkDefer = v:
if isBool v then if isBool v then
optional v ":defer t" optional v ":defer t"
else else
[ ":defer ${toString v}" ]; [ ":defer ${toString v}" ];
mkDemand = v: optional v ":demand t"; mkDemand = v: optional v ":demand t";
in concatStringsSep "\n " ([ "(use-package ${name}" ] in
++ mkAfter config.after ++ mkBind config.bind concatStringsSep "\n "
++ mkBindKeyMap config.bindKeyMap ++ mkBindLocal config.bindLocal ([ "(use-package ${name}" ]
++ mkChords config.chords ++ mkCommand config.command ++ mkAfter config.after ++ mkBind config.bind
++ mkDefer config.defer ++ mkDefines config.defines ++ mkBindKeyMap config.bindKeyMap ++ mkBindLocal config.bindLocal
++ mkFunctions config.functions ++ mkDemand config.demand ++ mkChords config.chords ++ mkCommand config.command
++ mkDiminish config.diminish ++ mkHook config.hook ++ mkDefer config.defer ++ mkDefines config.defines
++ mkMode config.mode ++ mkFunctions config.functions ++ mkDemand config.demand
++ optionals (config.init != "") [ ":init" config.init ] ++ mkDiminish config.diminish ++ mkHook config.hook
++ optionals (config.config != "") [ ":config" config.config ] ++ mkMode config.mode
++ optional (config.extraConfig != "") config.extraConfig) + ")"; ++ optionals (config.init != "") [ ":init" config.init ]
++ optionals (config.config != "") [ ":config" config.config ]
++ optional (config.extraConfig != "") config.extraConfig) + ")";
}; };
}); });
@ -390,7 +393,8 @@ let
;; hm-init.el ends here ;; hm-init.el ends here
''; '';
in { in
{
options.programs.emacs.init = { options.programs.emacs.init = {
enable = mkEnableOption "Emacs configuration"; enable = mkEnableOption "Emacs configuration";
@ -469,27 +473,29 @@ in {
home.packages = concatMap (v: v.extraPackages) home.packages = concatMap (v: v.extraPackages)
(filter (getAttr "enable") (builtins.attrValues cfg.usePackage)); (filter (getAttr "enable") (builtins.attrValues cfg.usePackage));
programs.emacs.init.earlyInit = let programs.emacs.init.earlyInit =
let
standardEarlyInit = mkBefore '' standardEarlyInit = mkBefore ''
${optionalString cfg.recommendedGcSettings gcSettings} ${optionalString cfg.recommendedGcSettings gcSettings}
${if cfg.packageQuickstart then '' ${if cfg.packageQuickstart then ''
(setq package-quickstart t (setq package-quickstart t
package-quickstart-file "hm-package-quickstart.el") package-quickstart-file "hm-package-quickstart.el")
'' else '' '' else ''
(setq package-enable-at-startup nil) (setq package-enable-at-startup nil)
''} ''}
;; Avoid expensive frame resizing. Inspired by Doom Emacs. ;; Avoid expensive frame resizing. Inspired by Doom Emacs.
(setq frame-inhibit-implied-resize t) (setq frame-inhibit-implied-resize t)
''; '';
# Collect the early initialization strings for each package. # Collect the early initialization strings for each package.
packageEarlyInits = map (p: p.earlyInit) packageEarlyInits = map (p: p.earlyInit)
(filter (p: p.earlyInit != "") (builtins.attrValues cfg.usePackage)); (filter (p: p.earlyInit != "") (builtins.attrValues cfg.usePackage));
in mkMerge ([ standardEarlyInit ] ++ packageEarlyInits); in
mkMerge ([ standardEarlyInit ] ++ packageEarlyInits);
programs.emacs.extraPackages = epkgs: programs.emacs.extraPackages = epkgs:
let let
@ -501,7 +507,8 @@ in {
packages = concatMap (v: getPkg (v.package)) packages = concatMap (v: getPkg (v.package))
(filter (getAttr "enable") (builtins.attrValues cfg.usePackage)); (filter (getAttr "enable") (builtins.attrValues cfg.usePackage));
in [ in
[
(epkgs.trivialBuild { (epkgs.trivialBuild {
pname = "hm-early-init"; pname = "hm-early-init";
src = pkgs.writeText "hm-early-init.el" earlyInitFile; src = pkgs.writeText "hm-early-init.el" earlyInitFile;

View file

@ -2,7 +2,7 @@
{ {
imports = [ ../profiles/common.nix ]; imports = [ ../profiles/common.nix ];
environment.etc."nix/user-sandbox.sb".text = '' environment.etc."nix/user-sandbox.sb".text = ''
(version 1) (version 1)
(allow default) (allow default)