1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

treewide: reformat nixfmt-rfc-style

Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
Austin Horstman 2025-04-07 16:11:29 -05:00
parent 5df48c4255
commit cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
homeDir = config.home.homeDirectory;
@ -9,7 +14,8 @@ let
};
fonts = "${fontsEnv}/share/fonts";
installDir = "${homeDir}/Library/Fonts/HomeManager";
in {
in
{
# macOS won't recognize symlinked fonts
config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.file."Library/Fonts/.home-manager-fonts-version" = {
@ -17,7 +23,10 @@ in {
onChange = ''
run mkdir -p ${lib.escapeShellArg installDir}
run ${pkgs.rsync}/bin/rsync $VERBOSE_ARG -acL --chmod=u+w --delete \
${lib.escapeShellArgs [ "${fonts}/" installDir ]}
${lib.escapeShellArgs [
"${fonts}/"
installDir
]}
'';
};
};

View file

@ -1,11 +1,16 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.targets.darwin;
homeDir = config.home.homeDirectory;
confFile = pkgs.writeText "DefaultKeybinding.dict"
(lib.generators.toPlist { } cfg.keybindings);
in {
confFile = pkgs.writeText "DefaultKeybinding.dict" (lib.generators.toPlist { } cfg.keybindings);
in
{
options.targets.darwin.keybindings = lib.mkOption {
type = with lib.types; attrsOf anything;
default = { };
@ -28,16 +33,14 @@ in {
config = lib.mkIf (cfg.keybindings != { }) {
assertions = [
(lib.hm.assertions.assertPlatform "targets.darwin.keybindings" pkgs
lib.platforms.darwin)
(lib.hm.assertions.assertPlatform "targets.darwin.keybindings" pkgs lib.platforms.darwin)
];
# NOTE: just copy the files because symlinks won't be recognized by macOS
home.activation.setCocoaKeybindings =
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
verboseEcho "Configuring keybindings for the Cocoa Text System"
run install -Dm644 $VERBOSE_ARG \
"${confFile}" "${homeDir}/Library/KeyBindings/DefaultKeyBinding.dict"
'';
home.activation.setCocoaKeybindings = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
verboseEcho "Configuring keybindings for the Cocoa Text System"
run install -Dm644 $VERBOSE_ARG \
"${confFile}" "${homeDir}/Library/KeyBindings/DefaultKeyBinding.dict"
'';
};
}

View file

@ -1,13 +1,18 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let cfg = config.targets.darwin;
in {
let
cfg = config.targets.darwin;
in
{
options.targets.darwin.linkApps = {
enable =
lib.mkEnableOption "linking macOS applications to the user environment"
// {
default = true;
};
enable = lib.mkEnableOption "linking macOS applications to the user environment" // {
default = true;
};
directory = lib.mkOption {
type = lib.types.str;
@ -18,12 +23,14 @@ in {
config = lib.mkIf (pkgs.stdenv.hostPlatform.isDarwin && cfg.linkApps.enable) {
# Install MacOS applications to the user environment.
home.file.${cfg.linkApps.directory}.source = let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in "${apps}/Applications";
home.file.${cfg.linkApps.directory}.source =
let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in
"${apps}/Applications";
};
}

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.targets.darwin;
@ -10,7 +15,8 @@ let
Yahoo = "com.yahoo.www";
};
searchId = lib.getAttr cfg.search searchEngines;
in {
in
{
options.targets.darwin.search = lib.mkOption {
type = with lib.types; nullOr (enum (lib.attrNames searchEngines));
default = null;
@ -19,8 +25,7 @@ in {
config = lib.mkIf (cfg.search != null) {
assertions = [
(lib.hm.assertions.assertPlatform "targets.darwin.search" pkgs
lib.platforms.darwin)
(lib.hm.assertions.assertPlatform "targets.darwin.search" pkgs lib.platforms.darwin)
];
targets.darwin.defaults = {

View file

@ -1,33 +1,36 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.targets.darwin;
mkActivationCmds = isLocal: settings:
mkActivationCmds =
isLocal: settings:
let
toDefaultsFile = domain: attrs:
pkgs.writeText "${domain}.plist" (lib.generators.toPlist { } attrs);
toDefaultsFile = domain: attrs: pkgs.writeText "${domain}.plist" (lib.generators.toPlist { } attrs);
cliFlags = lib.optionalString isLocal "-currentHost";
toActivationCmd = domain: attrs:
"run /usr/bin/defaults ${cliFlags} import ${
lib.escapeShellArg domain
} ${toDefaultsFile domain attrs}";
toActivationCmd =
domain: attrs:
"run /usr/bin/defaults ${cliFlags} import ${lib.escapeShellArg domain} ${toDefaultsFile domain attrs}";
nonNullDefaults =
lib.mapAttrs (domain: attrs: (lib.filterAttrs (n: v: v != null) attrs))
settings;
nonNullDefaults = lib.mapAttrs (domain: attrs: (lib.filterAttrs (n: v: v != null) attrs)) settings;
writableDefaults =
lib.filterAttrs (domain: attrs: attrs != { }) nonNullDefaults;
in lib.mapAttrsToList toActivationCmd writableDefaults;
writableDefaults = lib.filterAttrs (domain: attrs: attrs != { }) nonNullDefaults;
in
lib.mapAttrsToList toActivationCmd writableDefaults;
defaultsCmds = mkActivationCmds false cfg.defaults;
currentHostDefaultsCmds = mkActivationCmds true cfg.currentHostDefaults;
activationCmds = defaultsCmds ++ currentHostDefaultsCmds;
in {
in
{
meta.maintainers = [ lib.maintainers.midchildan ];
options.targets.darwin.defaults = lib.mkOption {
@ -58,7 +61,9 @@ in {
type = lib.types.submodule ./opts-currenthost.nix;
default = { };
example = {
"com.apple.controlcenter" = { BatteryShowPercentage = true; };
"com.apple.controlcenter" = {
BatteryShowPercentage = true;
};
};
description = ''
Set macOS user defaults. Unlike {option}`targets.darwin.defaults`,
@ -75,32 +80,33 @@ in {
config = lib.mkIf (activationCmds != [ ]) {
assertions = [
(lib.hm.assertions.assertPlatform "targets.darwin.defaults" pkgs
lib.platforms.darwin)
(lib.hm.assertions.assertPlatform "targets.darwin.defaults" pkgs lib.platforms.darwin)
];
warnings = let
batteryOptionName = ''
targets.darwin.currentHostDefaults."com.apple.controlcenter".BatteryShowPercentage'';
batteryPercentage =
lib.attrByPath [ "com.apple.menuextra.battery" "ShowPercent" ] null
cfg.defaults;
webkitDevExtras = lib.attrByPath [
"com.apple.Safari"
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled"
] null cfg.defaults;
in lib.optional (batteryPercentage != null) ''
The option 'com.apple.menuextra.battery.ShowPercent' no longer works on
macOS 11 and later. Instead, use '${batteryOptionName}'.
'' ++ lib.optional (webkitDevExtras != null) ''
The option 'com.apple.Safari.com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled'
is no longer present in recent versions of Safari.
'';
home.activation.setDarwinDefaults =
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
verboseEcho "Configuring macOS user defaults"
${lib.concatStringsSep "\n" activationCmds}
warnings =
let
batteryOptionName = ''targets.darwin.currentHostDefaults."com.apple.controlcenter".BatteryShowPercentage'';
batteryPercentage = lib.attrByPath [
"com.apple.menuextra.battery"
"ShowPercent"
] null cfg.defaults;
webkitDevExtras = lib.attrByPath [
"com.apple.Safari"
"com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled"
] null cfg.defaults;
in
lib.optional (batteryPercentage != null) ''
The option 'com.apple.menuextra.battery.ShowPercent' no longer works on
macOS 11 and later. Instead, use '${batteryOptionName}'.
''
++ lib.optional (webkitDevExtras != null) ''
The option 'com.apple.Safari.com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled'
is no longer present in recent versions of Safari.
'';
home.activation.setDarwinDefaults = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
verboseEcho "Configuring macOS user defaults"
${lib.concatStringsSep "\n" activationCmds}
'';
};
}

View file

@ -3,13 +3,18 @@
let
inherit (lib) types;
mkNullableOption = args:
lib.mkOption (args // {
type = types.nullOr args.type;
default = null;
});
mkNullableOption =
args:
lib.mkOption (
args
// {
type = types.nullOr args.type;
default = null;
}
);
mkNullableEnableOption = name:
mkNullableEnableOption =
name:
lib.mkOption {
type = with types; nullOr bool;
default = null;
@ -18,7 +23,8 @@ let
};
safari = config."com.apple.Safari";
in {
in
{
freeformType = with types; attrsOf (attrsOf anything);
options = {
@ -36,7 +42,10 @@ in {
};
AppleMeasurementUnits = mkNullableOption {
type = types.enum [ "Centimeters" "Inches" ];
type = types.enum [
"Centimeters"
"Inches"
];
example = "Centimeters";
description = "Sets the measurement unit.";
};
@ -44,8 +53,7 @@ in {
ApplePressAndHoldEnabled = mkNullableOption {
type = types.bool;
example = true;
description =
"Repeat a key when it is held down (false) or display the accented character selector (true)";
description = "Repeat a key when it is held down (false) or display the accented character selector (true)";
};
AppleShowAllExtensions = mkNullableOption {
@ -55,7 +63,10 @@ in {
};
AppleTemperatureUnit = mkNullableOption {
type = types.enum [ "Celsius" "Fahrenheit" ];
type = types.enum [
"Celsius"
"Fahrenheit"
];
example = "Celsius";
description = "Sets the temperature unit.";
};
@ -72,20 +83,15 @@ in {
'';
};
NSAutomaticCapitalizationEnabled =
mkNullableEnableOption "automatic capitalization";
NSAutomaticCapitalizationEnabled = mkNullableEnableOption "automatic capitalization";
NSAutomaticDashSubstitutionEnabled =
mkNullableEnableOption "smart dashes";
NSAutomaticDashSubstitutionEnabled = mkNullableEnableOption "smart dashes";
NSAutomaticPeriodSubstitutionEnabled =
mkNullableEnableOption "period with double space";
NSAutomaticPeriodSubstitutionEnabled = mkNullableEnableOption "period with double space";
NSAutomaticQuoteSubstitutionEnabled =
mkNullableEnableOption "smart quotes";
NSAutomaticQuoteSubstitutionEnabled = mkNullableEnableOption "smart quotes";
NSAutomaticSpellingCorrectionEnabled =
mkNullableEnableOption "spelling correction";
NSAutomaticSpellingCorrectionEnabled = mkNullableEnableOption "spelling correction";
};
"com.apple.desktopservices" = {
@ -113,10 +119,13 @@ in {
example = true;
description = "Hide the Dock automatically";
};
expose-group-apps = mkNullableEnableOption
"grouping of windows by application in Mission Control";
expose-group-apps = mkNullableEnableOption "grouping of windows by application in Mission Control";
orientation = mkNullableOption {
type = types.enum [ "left" "bottom" "right" ];
type = types.enum [
"left"
"bottom"
"right"
];
example = "left";
description = "Position of the Dock on the screen";
};
@ -155,7 +164,10 @@ in {
};
"com.apple.menuextra.battery".ShowPercent = mkNullableOption {
type = types.enum [ "YES" "NO" ];
type = types.enum [
"YES"
"NO"
];
example = "NO";
description = ''
This option no longer works on macOS 11 and later. Instead, use
@ -166,11 +178,9 @@ in {
};
"com.apple.menuextra.clock" = {
IsAnalog = mkNullableEnableOption
"showing an analog clock instead of a digital one";
IsAnalog = mkNullableEnableOption "showing an analog clock instead of a digital one";
Show24Hour = mkNullableEnableOption
"showing a 24-hour clock, instead of a 12-hour clock";
Show24Hour = mkNullableEnableOption "showing a 24-hour clock, instead of a 12-hour clock";
ShowAMPM = mkNullableOption {
type = types.bool;
@ -180,7 +190,11 @@ in {
};
ShowDate = mkNullableOption {
type = types.enum [ 0 1 2 ];
type = types.enum [
0
1
2
];
description = ''
Show the full date. Default is null.
@ -196,19 +210,14 @@ in {
ShowDayOfWeek = mkNullableEnableOption "showing the day of the week";
ShowSeconds = mkNullableEnableOption
"showing the clock with second precision, instead of minutes";
ShowSeconds = mkNullableEnableOption "showing the clock with second precision, instead of minutes";
};
"com.apple.Safari" = {
AutoOpenSafeDownloads =
mkNullableEnableOption "opening of downloaded files";
AutoFillPasswords =
mkNullableEnableOption "autofill of usernames and passwords";
AutoFillCreditCardData =
mkNullableEnableOption "autofill of credit card numbers";
IncludeDevelopMenu =
mkNullableEnableOption ''"Develop" menu in the menu bar'';
AutoOpenSafeDownloads = mkNullableEnableOption "opening of downloaded files";
AutoFillPasswords = mkNullableEnableOption "autofill of usernames and passwords";
AutoFillCreditCardData = mkNullableEnableOption "autofill of credit card numbers";
IncludeDevelopMenu = mkNullableEnableOption ''"Develop" menu in the menu bar'';
ShowOverlayStatusBar = mkNullableEnableOption "status bar";
WebKitDeveloperExtrasEnabledPreferenceKey = mkNullableOption {
@ -250,14 +259,11 @@ in {
};
"com.googlecode.iterm2" = {
AddNewTabAtEndOfTabs = mkNullableEnableOption
"placement of new tabs at the end of the tab bar";
AddNewTabAtEndOfTabs = mkNullableEnableOption "placement of new tabs at the end of the tab bar";
AlternateMouseScroll = mkNullableEnableOption
"arrow keys when scrolling in alternate screen mode";
AlternateMouseScroll = mkNullableEnableOption "arrow keys when scrolling in alternate screen mode";
CopySelection =
mkNullableEnableOption "copy to clipboard upon selecting text";
CopySelection = mkNullableEnableOption "copy to clipboard upon selecting text";
OpenTmuxWindowsIn = mkNullableOption {
type = types.int;
@ -278,8 +284,7 @@ in {
'';
};
ExperimentalKeyHandling = mkNullableEnableOption
"experimental key handling for AquaSKK compatibility";
ExperimentalKeyHandling = mkNullableEnableOption "experimental key handling for AquaSKK compatibility";
};
};
@ -288,9 +293,8 @@ in {
WebKitDeveloperExtrasEnabledPreferenceKey = safari.IncludeDevelopMenu;
"WebKitPreferences.developerExtrasEnabled" = safari.IncludeDevelopMenu;
};
"com.apple.Safari.SandboxBroker" =
lib.mkIf (safari.IncludeDevelopMenu != null) {
ShowDevelopMenu = safari.IncludeDevelopMenu;
};
"com.apple.Safari.SandboxBroker" = lib.mkIf (safari.IncludeDevelopMenu != null) {
ShowDevelopMenu = safari.IncludeDevelopMenu;
};
};
}

View file

@ -1,20 +1,26 @@
{ lib, ... }:
let
mkNullableOption = args:
lib.mkOption (args // {
type = lib.types.nullOr args.type;
default = null;
});
mkNullableOption =
args:
lib.mkOption (
args
// {
type = lib.types.nullOr args.type;
default = null;
}
);
mkNullableEnableOption = name:
mkNullableEnableOption =
name:
lib.mkOption {
type = with lib.types; nullOr bool;
default = null;
example = true;
description = "Whether to enable ${name}.";
};
in {
in
{
freeformType = with lib.types; attrsOf (attrsOf anything);
options = {

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
@ -8,13 +13,17 @@ let
nixPkg = if config.nix.package == null then pkgs.nix else config.nix.package;
in {
in
{
imports = [
(lib.mkRenamedOptionModule [ "targets" "genericLinux" "extraXdgDataDirs" ] [
"xdg"
"systemDirs"
"data"
])
(lib.mkRenamedOptionModule
[ "targets" "genericLinux" "extraXdgDataDirs" ]
[
"xdg"
"systemDirs"
"data"
]
)
];
options.targets.genericLinux = {
@ -28,8 +37,7 @@ in {
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "targets.genericLinux" pkgs
lib.platforms.linux)
(lib.hm.assertions.assertPlatform "targets.genericLinux" pkgs lib.platforms.linux)
];
xdg.systemDirs.data = [
@ -87,24 +95,25 @@ in {
}
'';
systemd.user.sessionVariables = let
# https://github.com/archlinux/svntogit-packages/blob/packages/ncurses/trunk/PKGBUILD
# https://salsa.debian.org/debian/ncurses/-/blob/master/debian/rules
# https://src.fedoraproject.org/rpms/ncurses/blob/main/f/ncurses.spec
# https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/ncurses/ncurses-6.2-r1.ebuild
distroTerminfoDirs = lib.concatStringsSep ":" [
"/etc/terminfo" # debian, fedora, gentoo
"/lib/terminfo" # debian
"/usr/share/terminfo" # package default, all distros
];
in {
NIX_PATH = if config.nix.enable
&& (config.nix.settings.use-xdg-base-directories or false) then
"${config.xdg.stateHome}/nix/defexpr/channels\${NIX_PATH:+:}$NIX_PATH"
else
"$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
TERMINFO_DIRS =
"${profileDirectory}/share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:}${distroTerminfoDirs}";
};
systemd.user.sessionVariables =
let
# https://github.com/archlinux/svntogit-packages/blob/packages/ncurses/trunk/PKGBUILD
# https://salsa.debian.org/debian/ncurses/-/blob/master/debian/rules
# https://src.fedoraproject.org/rpms/ncurses/blob/main/f/ncurses.spec
# https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/ncurses/ncurses-6.2-r1.ebuild
distroTerminfoDirs = lib.concatStringsSep ":" [
"/etc/terminfo" # debian, fedora, gentoo
"/lib/terminfo" # debian
"/usr/share/terminfo" # package default, all distros
];
in
{
NIX_PATH =
if config.nix.enable && (config.nix.settings.use-xdg-base-directories or false) then
"${config.xdg.stateHome}/nix/defexpr/channels\${NIX_PATH:+:}$NIX_PATH"
else
"$HOME/.nix-defexpr/channels\${NIX_PATH:+:}$NIX_PATH";
TERMINFO_DIRS = "${profileDirectory}/share/terminfo:$TERMINFO_DIRS\${TERMINFO_DIRS:+:}${distroTerminfoDirs}";
};
};
}