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

treewide: format with latest stable formatter

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-07-23 10:00:12 -05:00
parent 56ee5d0670
commit b4752b0eda
56 changed files with 816 additions and 832 deletions

View file

@ -32,7 +32,8 @@ let
class = "homeManager"; class = "homeManager";
specialArgs = { specialArgs = {
modulesPath = builtins.toString ./.; modulesPath = builtins.toString ./.;
} // extraSpecialArgs; }
// extraSpecialArgs;
}; };
moduleChecks = moduleChecks =

View file

@ -615,21 +615,20 @@ in
home.sessionVariablesPackage = pkgs.writeTextFile { home.sessionVariablesPackage = pkgs.writeTextFile {
name = "hm-session-vars.sh"; name = "hm-session-vars.sh";
destination = "/etc/profile.d/hm-session-vars.sh"; destination = "/etc/profile.d/hm-session-vars.sh";
text = text = ''
'' # Only source this once.
# Only source this once. if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi export __HM_SESS_VARS_SOURCED=1
export __HM_SESS_VARS_SOURCED=1
${config.lib.shell.exportAll cfg.sessionVariables} ${config.lib.shell.exportAll cfg.sessionVariables}
'' ''
+ lib.concatStringsSep "\n" ( + lib.concatStringsSep "\n" (
lib.mapAttrsToList ( lib.mapAttrsToList (
env: values: config.lib.shell.export env (config.lib.shell.prependToVar ":" env values) env: values: config.lib.shell.export env (config.lib.shell.prependToVar ":" env values)
) cfg.sessionSearchVariables ) cfg.sessionSearchVariables
) )
+ "\n" + "\n"
+ cfg.sessionVariablesExtra; + cfg.sessionVariablesExtra;
}; };
home.sessionSearchVariables.PATH = lib.mkIf (cfg.sessionPath != [ ]) cfg.sessionPath; home.sessionSearchVariables.PATH = lib.mkIf (cfg.sessionPath != [ ]) cfg.sessionPath;

View file

@ -199,19 +199,18 @@ in
}; };
home = { home = {
sessionVariables = sessionVariables = {
{ GLFW_IM_MODULE = "ibus"; # IME support in kitty
GLFW_IM_MODULE = "ibus"; # IME support in kitty SDL_IM_MODULE = "fcitx";
SDL_IM_MODULE = "fcitx"; XMODIFIERS = "@im=fcitx";
XMODIFIERS = "@im=fcitx"; }
} // lib.optionalAttrs (!cfg.waylandFrontend) {
// lib.optionalAttrs (!cfg.waylandFrontend) { GTK_IM_MODULE = "fcitx";
GTK_IM_MODULE = "fcitx"; QT_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx"; }
} // lib.optionalAttrs cfg.ignoreUserConfig {
// lib.optionalAttrs cfg.ignoreUserConfig { SKIP_FCITX_USER_PATH = "1";
SKIP_FCITX_USER_PATH = "1"; };
};
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ]; sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
}; };

View file

@ -18,17 +18,16 @@ rec {
# All characters that are considered safe. Note "-" is not # All characters that are considered safe. Note "-" is not
# included to avoid "-" followed by digit being interpreted as a # included to avoid "-" followed by digit being interpreted as a
# version. # version.
safeChars = safeChars = [
[ "+"
"+" "."
"." "_"
"_" "?"
"?" "="
"=" ]
] ++ lowerChars
++ lowerChars ++ upperChars
++ upperChars ++ stringToCharacters "0123456789";
++ stringToCharacters "0123456789";
empties = l: genList (x: "") (length l); empties = l: genList (x: "") (length l);

View file

@ -20,38 +20,36 @@ in
nameExample ? "Adwaita", nameExample ? "Adwaita",
}: }:
types.submodule { types.submodule {
options = options = {
{ package = mkOption {
package = mkOption { type = types.nullOr types.package;
type = types.nullOr types.package; default = null;
default = null; example = literalExpression packageExample;
example = literalExpression packageExample; description = ''
description = Package providing the ${typeName}. This package will be installed
'' to your profile. If `null` then the ${typeName}
Package providing the ${typeName}. This package will be installed is assumed to already be available in your profile.
to your profile. If `null` then the ${typeName} ''
is assumed to already be available in your profile. + optionalString (typeName == "theme") ''
''
+ optionalString (typeName == "theme") ''
For the theme to apply to GTK 4, this option is mandatory. For the theme to apply to GTK 4, this option is mandatory.
''; '';
};
name = mkOption {
type = types.str;
example = nameExample;
description = "The name of the ${typeName} within the package.";
};
}
// optionalAttrs hasSize {
size = mkOption {
type = types.nullOr types.int;
default = null;
example = 16;
description = "The size of the cursor.";
};
}; };
name = mkOption {
type = types.str;
example = nameExample;
description = "The name of the ${typeName} within the package.";
};
}
// optionalAttrs hasSize {
size = mkOption {
type = types.nullOr types.int;
default = null;
example = 16;
description = "The size of the cursor.";
};
};
}; };
# Helper function to generate the settings attribute set for a given version # Helper function to generate the settings attribute set for a given version

View file

@ -190,24 +190,23 @@ in
"DRI_PRIME" = "${cfg.prime.card}"; "DRI_PRIME" = "${cfg.prime.card}";
}; };
nvOffloadEnv = nvOffloadEnv = {
{ "DRI_PRIME" = "${cfg.prime.card}";
"DRI_PRIME" = "${cfg.prime.card}"; "__NV_PRIME_RENDER_OFFLOAD" = "1";
"__NV_PRIME_RENDER_OFFLOAD" = "1"; "__GLX_VENDOR_LIBRARY_NAME" = "nvidia";
"__GLX_VENDOR_LIBRARY_NAME" = "nvidia"; "__VK_LAYER_NV_optimus" = "NVIDIA_only";
"__VK_LAYER_NV_optimus" = "NVIDIA_only"; }
} // (
// ( let
let provider = cfg.prime.nvidiaProvider;
provider = cfg.prime.nvidiaProvider; in
in if !isNull provider then
if !isNull provider then {
{ "__NV_PRIME_RENDER_OFFLOAD_PROVIDER" = "${provider}";
"__NV_PRIME_RENDER_OFFLOAD_PROVIDER" = "${provider}"; }
} else
else { }
{ } );
);
makePackageWrapper = makePackageWrapper =
vendor: environment: pkg: vendor: environment: pkg:

View file

@ -386,12 +386,11 @@ in
) )
++ (lib.optionals (cfg.style.package != null) (lib.toList cfg.style.package)); ++ (lib.optionals (cfg.style.package != null) (lib.toList cfg.style.package));
xsession.importedVariables = xsession.importedVariables = [
[ "QT_PLUGIN_PATH"
"QT_PLUGIN_PATH" "QML2_IMPORT_PATH"
"QML2_IMPORT_PATH" ]
] ++ lib.optionals (platformTheme.name != null) [ "QT_QPA_PLATFORMTHEME" ]
++ lib.optionals (platformTheme.name != null) [ "QT_QPA_PLATFORMTHEME" ] ++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ];
++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ];
}; };
} }

View file

@ -229,7 +229,8 @@ in
config = lib.mkIf (config.xdg.desktopEntries != { }) { config = lib.mkIf (config.xdg.desktopEntries != { }) {
assertions = [ assertions = [
(lib.hm.assertions.assertPlatform "xdg.desktopEntries" pkgs lib.platforms.linux) (lib.hm.assertions.assertPlatform "xdg.desktopEntries" pkgs lib.platforms.linux)
] ++ lib.flatten (lib.catAttrs "assertions" (lib.attrValues config.xdg.desktopEntries)); ]
++ lib.flatten (lib.catAttrs "assertions" (lib.attrValues config.xdg.desktopEntries));
home.packages = ( home.packages = (
map lib.hiPrio # we need hiPrio to override existing entries map lib.hiPrio # we need hiPrio to override existing entries

View file

@ -13,102 +13,100 @@
let let
modules = modules = [
[ # keep-sorted start case=no numeric=yes
# keep-sorted start case=no numeric=yes ./accounts/calendar.nix
./accounts/calendar.nix ./accounts/contacts.nix
./accounts/contacts.nix ./accounts/email.nix
./accounts/email.nix ./config/home-cursor.nix
./config/home-cursor.nix ./config/i18n.nix
./config/i18n.nix ./dbus.nix
./dbus.nix ./files.nix
./files.nix ./home-environment.nix
./home-environment.nix ./i18n/input-method/default.nix
./i18n/input-method/default.nix ./launchd/default.nix
./launchd/default.nix ./manual.nix
./manual.nix ./misc/dconf.nix
./misc/dconf.nix ./misc/debug.nix
./misc/debug.nix ./misc/editorconfig.nix
./misc/editorconfig.nix ./misc/fontconfig.nix
./misc/fontconfig.nix ./misc/gtk.nix
./misc/gtk.nix ./misc/lib.nix
./misc/lib.nix ./misc/mozilla-messaging-hosts.nix
./misc/mozilla-messaging-hosts.nix ./misc/news.nix
./misc/news.nix ./misc/nix.nix
./misc/nix.nix ./misc/nixgl.nix
./misc/nixgl.nix ./misc/numlock.nix
./misc/numlock.nix ./misc/pam.nix
./misc/pam.nix ./misc/qt.nix
./misc/qt.nix ./misc/qt/kconfig.nix
./misc/qt/kconfig.nix ./misc/shell.nix
./misc/shell.nix ./misc/specialisation.nix
./misc/specialisation.nix ./misc/submodule-support.nix
./misc/submodule-support.nix ./misc/tmpfiles.nix
./misc/tmpfiles.nix ./misc/uninstall.nix
./misc/uninstall.nix ./misc/version.nix
./misc/version.nix ./misc/vte.nix
./misc/vte.nix ./misc/xdg-autostart.nix
./misc/xdg-autostart.nix ./misc/xdg-desktop-entries.nix
./misc/xdg-desktop-entries.nix ./misc/xdg-mime-apps.nix
./misc/xdg-mime-apps.nix ./misc/xdg-mime.nix
./misc/xdg-mime.nix ./misc/xdg-portal.nix
./misc/xdg-portal.nix ./misc/xdg-system-dirs.nix
./misc/xdg-system-dirs.nix ./misc/xdg-user-dirs.nix
./misc/xdg-user-dirs.nix ./misc/xdg.nix
./misc/xdg.nix ./misc/xfconf.nix
./misc/xfconf.nix ./systemd.nix
./systemd.nix ./targets/darwin
./targets/darwin ./targets/generic-linux.nix
./targets/generic-linux.nix ./wayland.nix
./wayland.nix ./xresources.nix
./xresources.nix ./xsession.nix
./xsession.nix # keep-sorted end
# keep-sorted end (pkgs.path + "/nixos/modules/misc/assertions.nix")
(pkgs.path + "/nixos/modules/misc/assertions.nix") (pkgs.path + "/nixos/modules/misc/meta.nix")
(pkgs.path + "/nixos/modules/misc/meta.nix")
(lib.mkRemovedOptionModule [ "services" "password-store-sync" ] '' (lib.mkRemovedOptionModule [ "services" "password-store-sync" ] ''
Use services.git-sync instead. Use services.git-sync instead.
'') '')
(lib.mkRemovedOptionModule [ "services" "keepassx" ] '' (lib.mkRemovedOptionModule [ "services" "keepassx" ] ''
KeePassX is no longer maintained. KeePassX is no longer maintained.
'') '')
] ]
++ (lib.concatMap ++ (lib.concatMap
( (
dir: dir:
lib.pipe (builtins.readDir dir) [ lib.pipe (builtins.readDir dir) [
(lib.filterAttrs (path: _kind: !lib.hasPrefix "_" path)) (lib.filterAttrs (path: _kind: !lib.hasPrefix "_" path))
(lib.filterAttrs ( (lib.filterAttrs (
_path: kind: kind == "directory" || (kind == "regular" && lib.hasSuffix ".nix" _path) _path: kind: kind == "directory" || (kind == "regular" && lib.hasSuffix ".nix" _path)
)) ))
(lib.mapAttrsToList (path: _kind: lib.path.append dir path)) (lib.mapAttrsToList (path: _kind: lib.path.append dir path))
]
)
[
./services
./programs
] ]
) )
++ lib.optional useNixpkgsModule ./misc/nixpkgs.nix [
++ lib.optional (!useNixpkgsModule) ./misc/nixpkgs-disabled.nix; ./services
./programs
]
)
++ lib.optional useNixpkgsModule ./misc/nixpkgs.nix
++ lib.optional (!useNixpkgsModule) ./misc/nixpkgs-disabled.nix;
pkgsModule = pkgsModule =
{ config, ... }: { config, ... }:
{ {
config = config = {
{ _module.args.baseModules = modules;
_module.args.baseModules = modules; _module.args.pkgsPath = lib.mkDefault (
_module.args.pkgsPath = lib.mkDefault ( if lib.versionAtLeast config.home.stateVersion "20.09" then pkgs.path else <nixpkgs>
if lib.versionAtLeast config.home.stateVersion "20.09" then pkgs.path else <nixpkgs> );
); _module.args.pkgs = lib.mkDefault pkgs;
_module.args.pkgs = lib.mkDefault pkgs; _module.check = check;
_module.check = check; lib = lib.hm;
lib = lib.hm; }
} // lib.optionalAttrs useNixpkgsModule {
// lib.optionalAttrs useNixpkgsModule { nixpkgs.system = lib.mkDefault pkgs.stdenv.hostPlatform.system;
nixpkgs.system = lib.mkDefault pkgs.stdenv.hostPlatform.system; };
};
}; };
in in

View file

@ -254,34 +254,33 @@ in
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file = home.file = {
{ "${configDir}/accounts.conf" = mkIf genAccountsConf {
"${configDir}/accounts.conf" = mkIf genAccountsConf { text = joinCfg [
text = joinCfg [ header
header (mkINI cfg.extraAccounts)
(mkINI cfg.extraAccounts) (mkINI primaryAccountAccounts)
(mkINI primaryAccountAccounts) (mkINI accountsExtraAccounts)
(mkINI accountsExtraAccounts) ];
]; };
};
"${configDir}/aerc.conf" = mkIf genAercConf { "${configDir}/aerc.conf" = mkIf genAercConf {
text = joinCfg [ text = joinCfg [
header header
(mkINI cfg.extraConfig) (mkINI cfg.extraConfig)
(joinContextual accountsExtraConfig) (joinContextual accountsExtraConfig)
]; ];
}; };
"${configDir}/binds.conf" = mkIf genBindsConf { "${configDir}/binds.conf" = mkIf genBindsConf {
text = joinCfg [ text = joinCfg [
header header
(mkINI cfg.extraBinds) (mkINI cfg.extraBinds)
(joinContextual accountsExtraBinds) (joinContextual accountsExtraBinds)
]; ];
}; };
} }
// (mkStyleset cfg.stylesets) // (mkStyleset cfg.stylesets)
// (mkTemplates cfg.templates); // (mkTemplates cfg.templates);
}; };
} }

View file

@ -281,11 +281,10 @@ in
xdg.configFile."alot/config".text = configFile; xdg.configFile."alot/config".text = configFile;
xdg.configFile."alot/hooks.py" = lib.mkIf (cfg.hooks != "") { xdg.configFile."alot/hooks.py" = lib.mkIf (cfg.hooks != "") {
text = text = ''
'' # Generated by Home Manager.
# Generated by Home Manager. ''
'' + cfg.hooks;
+ cfg.hooks;
}; };
}; };
} }

View file

@ -53,8 +53,7 @@ in
(pkgs.eclipses.eclipseWithPlugins { (pkgs.eclipses.eclipseWithPlugins {
eclipse = cfg.package; eclipse = cfg.package;
jvmArgs = jvmArgs =
cfg.jvmArgs cfg.jvmArgs ++ lib.optional cfg.enableLombok "-javaagent:${pkgs.lombok}/share/java/lombok.jar";
++ lib.optional cfg.enableLombok "-javaagent:${pkgs.lombok}/share/java/lombok.jar";
plugins = cfg.plugins; plugins = cfg.plugins;
}) })
]; ];

View file

@ -63,13 +63,12 @@ let
} }
) )
// { // {
General = General = {
{ StartWithLastProfile = 1;
StartWithLastProfile = 1; }
} // lib.optionalAttrs (cfg.profileVersion != null) {
// lib.optionalAttrs (cfg.profileVersion != null) { Version = cfg.profileVersion;
Version = cfg.profileVersion; };
};
}; };
profilesIni = lib.generators.toINI { } profiles; profilesIni = lib.generators.toINI { } profiles;
@ -168,11 +167,10 @@ let
in in
{ {
assertion = duplicates == { }; assertion = duplicates == { };
message = message = ''
'' Must not have a ${appName} ${entityKind} with an existing ID but
Must not have a ${appName} ${entityKind} with an existing ID but ''
'' + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates);
+ concatStringsSep "\n" (mapAttrsToList mkMsg duplicates);
} }
); );
@ -784,54 +782,53 @@ in
}; };
config = { config = {
assertions = assertions = [
(mkNoDuplicateAssertion config.containers "container")
{
assertion = !(extensionSettingsNeedForce config.extensions.settings) || config.extensions.force;
message = ''
Using '${lib.showOption profilePath}.extensions.settings' will override all
previous extensions settings. Enable
'${lib.showOption profilePath}.extensions.force' to acknowledge this.
'';
}
]
++ (builtins.concatMap (
{ name, value }:
let
packages = builtins.filter (pkg: pkg.addonId == name) config.extensions.packages;
package = builtins.head packages;
unauthorized = lib.subtractLists value.permissions package.meta.mozPermissions;
in
[ [
(mkNoDuplicateAssertion config.containers "container")
{ {
assertion = !(extensionSettingsNeedForce config.extensions.settings) || config.extensions.force; assertion = value.permissions == null || length packages == 1;
message = '' message = ''
Using '${lib.showOption profilePath}.extensions.settings' will override all Must have exactly one extension with addonId '${name}'
previous extensions settings. Enable in '${lib.showOption profilePath}.extensions.packages' but found ${toString (length packages)}.
'${lib.showOption profilePath}.extensions.force' to acknowledge this. '';
}
{
assertion = value.permissions == null || length packages != 1 || unauthorized == [ ];
message = ''
Extension ${name} requests permissions that weren't
authorized: ${builtins.toJSON unauthorized}.
Consider adding the missing permissions to
'${
lib.showAttrPath (
profilePath
++ [
"extensions"
name
]
)
}.permissions'.
''; '';
} }
] ]
++ (builtins.concatMap ( ) (lib.attrsToList config.extensions.settings))
{ name, value }: ++ config.bookmarks.assertions;
let
packages = builtins.filter (pkg: pkg.addonId == name) config.extensions.packages;
package = builtins.head packages;
unauthorized = lib.subtractLists value.permissions package.meta.mozPermissions;
in
[
{
assertion = value.permissions == null || length packages == 1;
message = ''
Must have exactly one extension with addonId '${name}'
in '${lib.showOption profilePath}.extensions.packages' but found ${toString (length packages)}.
'';
}
{
assertion = value.permissions == null || length packages != 1 || unauthorized == [ ];
message = ''
Extension ${name} requests permissions that weren't
authorized: ${builtins.toJSON unauthorized}.
Consider adding the missing permissions to
'${
lib.showAttrPath (
profilePath
++ [
"extensions"
name
]
)
}.permissions'.
'';
}
]
) (lib.attrsToList config.extensions.settings))
++ config.bookmarks.assertions;
}; };
} }
) )
@ -902,7 +899,8 @@ in
} }
(mkNoDuplicateAssertion cfg.profiles "profile") (mkNoDuplicateAssertion cfg.profiles "profile")
] ++ (lib.concatMap (profile: profile.assertions) (attrValues cfg.profiles)); ]
++ (lib.concatMap (profile: profile.assertions) (attrValues cfg.profiles));
warnings = warnings =
optional (cfg.enableGnomeExtensions or false) '' optional (cfg.enableGnomeExtensions or false) ''

View file

@ -566,11 +566,12 @@ in
package: package:
pkgs.runCommand "${getName package}-fish-completions" pkgs.runCommand "${getName package}-fish-completions"
{ {
srcs = srcs = [
[ package ] package
++ lib.filter (p: p != null) ( ]
builtins.map (outName: package.${outName} or null) config.home.extraOutputsToInstall ++ lib.filter (p: p != null) (
); builtins.map (outName: package.${outName} or null) config.home.extraOutputsToInstall
);
nativeBuildInputs = [ pkgs.python3 ]; nativeBuildInputs = [ pkgs.python3 ];
buildInputs = [ cfg.package ]; buildInputs = [ cfg.package ];
preferLocalBuild = true; preferLocalBuild = true;

View file

@ -203,8 +203,7 @@ in
FZF_CTRL_T_OPTS = cfg.fileWidgetOptions; FZF_CTRL_T_OPTS = cfg.fileWidgetOptions;
FZF_DEFAULT_COMMAND = cfg.defaultCommand; FZF_DEFAULT_COMMAND = cfg.defaultCommand;
FZF_DEFAULT_OPTS = FZF_DEFAULT_OPTS =
cfg.defaultOptions cfg.defaultOptions ++ lib.optionals (cfg.colors != { }) [ "--color ${renderedColors cfg.colors}" ];
++ lib.optionals (cfg.colors != { }) [ "--color ${renderedColors cfg.colors}" ];
FZF_TMUX = if cfg.tmux.enableShellIntegration then "1" else null; FZF_TMUX = if cfg.tmux.enableShellIntegration then "1" else null;
FZF_TMUX_OPTS = cfg.tmux.shellIntegrationOptions; FZF_TMUX_OPTS = cfg.tmux.shellIntegrationOptions;
} }

View file

@ -120,7 +120,8 @@ in
"bezier" "bezier"
"monitor" "monitor"
"size" "size"
] ++ lib.optionals cfg.sourceFirst [ "source" ]; ]
++ lib.optionals cfg.sourceFirst [ "source" ];
example = [ example = [
"$" "$"
"bezier" "bezier"

View file

@ -28,11 +28,10 @@ in
# Errors out if the symlink already exists # Errors out if the symlink already exists
"${ide}/bin/${ide.meta.mainProgram}-remote-dev-server registerBackendLocationForGateway || true"; "${ide}/bin/${ide.meta.mainProgram}-remote-dev-server registerBackendLocationForGateway || true";
lines = map mkLine cfg.ides; lines = map mkLine cfg.ides;
linesStr = linesStr = ''
'' rm $HOME/.cache/JetBrains/RemoteDev/userProvidedDist/_nix_store* || true
rm $HOME/.cache/JetBrains/RemoteDev/userProvidedDist/_nix_store* || true ''
'' + lib.concatStringsSep "\n" lines;
+ lib.concatStringsSep "\n" lines;
in in
lib.hm.dag.entryAfter [ "writeBoundary" ] linesStr; lib.hm.dag.entryAfter [ "writeBoundary" ] linesStr;
}; };

View file

@ -301,24 +301,23 @@ in
(mkOrder 570 (toKittyEnv cfg.environment)) (mkOrder 570 (toKittyEnv cfg.environment))
]; ];
xdg.configFile."kitty/kitty.conf" = xdg.configFile."kitty/kitty.conf" = {
{ text = ''
text = '' # Generated by Home Manager.
# Generated by Home Manager. # See https://sw.kovidgoyal.net/kitty/conf.html
# See https://sw.kovidgoyal.net/kitty/conf.html ${cfg.extraConfig}
${cfg.extraConfig} '';
''; }
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { onChange = ''
onChange = '' ${pkgs.procps}/bin/pkill -USR1 -u $USER kitty || true
${pkgs.procps}/bin/pkill -USR1 -u $USER kitty || true '';
''; }
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin { onChange = ''
onChange = '' /usr/bin/pkill -USR1 -u $USER kitty || true
/usr/bin/pkill -USR1 -u $USER kitty || true '';
''; };
};
home.activation.checkKittyTheme = mkIf (cfg.themeFile != null) ( home.activation.checkKittyTheme = mkIf (cfg.themeFile != null) (
let let

View file

@ -106,13 +106,12 @@ in
MANGOHUD_DLSYM = 1; MANGOHUD_DLSYM = 1;
}; };
xdg.configFile = xdg.configFile = {
{ "MangoHud/MangoHud.conf" = mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; };
"MangoHud/MangoHud.conf" = mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; }; }
} // lib.mapAttrs' (
// lib.mapAttrs' ( n: v: lib.nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; }
n: v: lib.nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; } ) cfg.settingsPerApplication;
) cfg.settingsPerApplication;
}; };
meta.maintainers = with lib.maintainers; [ zeratax ]; meta.maintainers = with lib.maintainers; [ zeratax ];

View file

@ -22,33 +22,30 @@ let
# See: https://github.com/nix-community/home-manager/issues/6663 # See: https://github.com/nix-community/home-manager/issues/6663
# and https://github.com/bnprks/mcfly-fzf/issues/10 # and https://github.com/bnprks/mcfly-fzf/issues/10
bashIntegration = bashIntegration = ''
'' eval "$(${getExe cfg.package} init bash)"
eval "$(${getExe cfg.package} init bash)" ''
'' + optionalString cfg.fzf.enable ''
+ optionalString cfg.fzf.enable '' if [[ $- =~ i ]]; then
if [[ $- =~ i ]]; then eval "$(${getExe cfg.mcflyFzfPackage} init bash)"
eval "$(${getExe cfg.mcflyFzfPackage} init bash)" fi
fi '';
'';
fishIntegration = fishIntegration = ''
'' ${getExe cfg.package} init fish | source
${getExe cfg.package} init fish | source ''
'' + optionalString cfg.fzf.enable ''
+ optionalString cfg.fzf.enable '' ${getExe cfg.mcflyFzfPackage} init fish | source
${getExe cfg.mcflyFzfPackage} init fish | source '';
'';
zshIntegration = zshIntegration = ''
'' eval "$(${getExe cfg.package} init zsh)"
eval "$(${getExe cfg.package} init zsh)" ''
'' + optionalString cfg.fzf.enable ''
+ optionalString cfg.fzf.enable '' if [[ -o interactive ]]; then
if [[ -o interactive ]]; then eval "$(${getExe cfg.mcflyFzfPackage} init zsh)"
eval "$(${getExe cfg.mcflyFzfPackage} init zsh)" fi
fi '';
'';
in in
{ {

View file

@ -84,17 +84,16 @@ in
(mkIf (cfg.ignores != [ ] || cfg.ignoresRegexp != [ ]) { (mkIf (cfg.ignores != [ ] || cfg.ignoresRegexp != [ ]) {
programs.mercurial.iniContent.ui.ignore = "${config.xdg.configHome}/hg/hgignore_global"; programs.mercurial.iniContent.ui.ignore = "${config.xdg.configHome}/hg/hgignore_global";
xdg.configFile."hg/hgignore_global".text = xdg.configFile."hg/hgignore_global".text = ''
'' syntax: glob
syntax: glob ''
'' + lib.concatStringsSep "\n" cfg.ignores
+ lib.concatStringsSep "\n" cfg.ignores + "\n"
+ "\n" + ''
+ '' syntax: regexp
syntax: regexp ''
'' + lib.concatStringsSep "\n" cfg.ignoresRegexp
+ lib.concatStringsSep "\n" cfg.ignoresRegexp + "\n";
+ "\n";
}) })
(mkIf (cfg.aliases != { }) { (mkIf (cfg.aliases != { }) {

View file

@ -99,6 +99,7 @@ in
".ne/.keys" = mkIf (cfg.keybindings != "") { text = cfg.keybindings; }; ".ne/.keys" = mkIf (cfg.keybindings != "") { text = cfg.keybindings; };
".ne/.extensions" = mkIf (cfg.virtualExtensions != "") { text = cfg.virtualExtensions; }; ".ne/.extensions" = mkIf (cfg.virtualExtensions != "") { text = cfg.virtualExtensions; };
".ne/.menus" = mkIf (cfg.menus != "") { text = cfg.menus; }; ".ne/.menus" = mkIf (cfg.menus != "") { text = cfg.menus; };
} // autoPrefFiles; }
// autoPrefFiles;
}; };
} }

View file

@ -109,7 +109,8 @@ in
"${lib.getExe cfg.package}" "${lib.getExe cfg.package}"
"clean" "clean"
"user" "user"
] ++ lib.optional (cfg.clean.extraArgs != "") cfg.clean.extraArgs; ]
++ lib.optional (cfg.clean.extraArgs != "") cfg.clean.extraArgs;
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.clean.dates; StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.clean.dates;

View file

@ -532,13 +532,12 @@ in
vaults = builtins.listToAttrs ( vaults = builtins.listToAttrs (
builtins.map (vault: { builtins.map (vault: {
name = builtins.hashString "md5" vault.target; name = builtins.hashString "md5" vault.target;
value = value = {
{ path = "${config.home.homeDirectory}/${vault.target}";
path = "${config.home.homeDirectory}/${vault.target}"; }
} // (lib.attrsets.optionalAttrs ((builtins.length vaults) == 1) {
// (lib.attrsets.optionalAttrs ((builtins.length vaults) == 1) { open = true;
open = true; });
});
}) vaults }) vaults
); );
updateDisabled = true; updateDisabled = true;

View file

@ -65,29 +65,28 @@ let
}; };
in in
toIni { toIni {
"Account ${name}" = "Account ${name}" = {
{ localrepository = "${name}-local";
localrepository = "${name}-local"; remoterepository = "${name}-remote";
remoterepository = "${name}-remote"; }
} // postSyncHook
// postSyncHook // offlineimap.extraConfig.account;
// offlineimap.extraConfig.account;
"Repository ${name}-local" = { "Repository ${name}-local" = {
type = localType; type = localType;
localfolders = account.maildir.absPath; localfolders = account.maildir.absPath;
} // offlineimap.extraConfig.local; }
// offlineimap.extraConfig.local;
"Repository ${name}-remote" = "Repository ${name}-remote" = {
{ type = remoteType;
type = remoteType; remoteuser = account.userName;
remoteuser = account.userName; }
} // remoteHost
// remoteHost // remotePort
// remotePort // remotePassEval
// remotePassEval // ssl
// ssl // offlineimap.extraConfig.remote;
// offlineimap.extraConfig.remote;
}; };
extraConfigType = with lib.types; attrsOf (either (either str int) bool); extraConfigType = with lib.types; attrsOf (either (either str int) bool);
@ -189,30 +188,31 @@ in
'' ''
}/bin/get_settings.pyc"; }/bin/get_settings.pyc";
xdg.configFile."offlineimap/config".text = xdg.configFile."offlineimap/config".text = ''
'' # Generated by Home Manager.
# Generated by Home Manager. # See https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf
# See https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf # for an exhaustive list of options.
# for an exhaustive list of options. ''
'' + toIni (
+ toIni ( {
{ general = {
general = { accounts = lib.concatMapStringsSep "," (a: a.name) accounts;
accounts = lib.concatMapStringsSep "," (a: a.name) accounts; pythonfile = "${config.xdg.configHome}/offlineimap/get_settings.py";
pythonfile = "${config.xdg.configHome}/offlineimap/get_settings.py"; metadata = "${config.xdg.dataHome}/offlineimap";
metadata = "${config.xdg.dataHome}/offlineimap";
} // cfg.extraConfig.general;
} }
// lib.optionalAttrs (cfg.extraConfig.mbnames != { }) { // cfg.extraConfig.general;
mbnames = { }
enabled = true; // lib.optionalAttrs (cfg.extraConfig.mbnames != { }) {
} // cfg.extraConfig.mbnames; mbnames = {
enabled = true;
} }
// lib.optionalAttrs (cfg.extraConfig.default != { }) { // cfg.extraConfig.mbnames;
DEFAULT = cfg.extraConfig.default; }
} // lib.optionalAttrs (cfg.extraConfig.default != { }) {
) DEFAULT = cfg.extraConfig.default;
+ "\n" }
+ lib.concatStringsSep "\n" (map accountStr accounts); )
+ "\n"
+ lib.concatStringsSep "\n" (map accountStr accounts);
}; };
} }

View file

@ -176,10 +176,11 @@ in
let let
resolvedExtraLuaPackages = cfg.extraLuaPackages pkgs.lua54Packages; resolvedExtraLuaPackages = cfg.extraLuaPackages pkgs.lua54Packages;
pathPackages = pathPackages = [
[ cfg.package ] cfg.package
++ cfg.extraPackages ]
++ lib.optional (cfg.configType == "lua" && cfg.luaPackage != null) cfg.luaPackage; ++ cfg.extraPackages
++ lib.optional (cfg.configType == "lua" && cfg.luaPackage != null) cfg.luaPackage;
luaPaths = lib.filter (x: x != "") [ luaPaths = lib.filter (x: x != "") [
(lib.optionalString (cfg.configType == "lua" && resolvedExtraLuaPackages != [ ]) ( (lib.optionalString (cfg.configType == "lua" && resolvedExtraLuaPackages != [ ]) (

View file

@ -135,20 +135,19 @@ in
{ home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; } { home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; }
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux { (lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
xdg.configFile = xdg.configFile = {
{ "streamlink/config" = lib.mkIf (cfg.settings != { }) {
"streamlink/config" = lib.mkIf (cfg.settings != { }) { text = renderSettings cfg.settings;
text = renderSettings cfg.settings; };
}; }
} // (lib.mapAttrs' (
// (lib.mapAttrs' ( name: value:
name: value: lib.nameValuePair "streamlink/config.${name}" (
lib.nameValuePair "streamlink/config.${name}" ( lib.mkIf (value.settings != { }) {
lib.mkIf (value.settings != { }) { text = renderSettings value.settings;
text = renderSettings value.settings; }
} )
) ) cfg.plugins);
) cfg.plugins);
xdg.dataFile = lib.mapAttrs' ( xdg.dataFile = lib.mapAttrs' (
name: value: name: value:
@ -168,35 +167,34 @@ in
}) })
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.file = home.file = {
{ "Library/Application Support/streamlink/config" = lib.mkIf (cfg.settings != { }) {
"Library/Application Support/streamlink/config" = lib.mkIf (cfg.settings != { }) { text = renderSettings cfg.settings;
text = renderSettings cfg.settings; };
}; }
} // (lib.mapAttrs' (
// (lib.mapAttrs' ( name: value:
name: value: lib.nameValuePair "Library/Application Support/streamlink/config.${name}" (
lib.nameValuePair "Library/Application Support/streamlink/config.${name}" ( lib.mkIf (value.settings != { }) {
lib.mkIf (value.settings != { }) { text = renderSettings value.settings;
text = renderSettings value.settings; }
} )
) cfg.plugins)
// (lib.mapAttrs' (
name: value:
lib.nameValuePair "Library/Application Support/streamlink/plugins/${name}.py" (
lib.mkIf (value.src != null) (
if (builtins.isPath value.src) then
{
source = value.src;
}
else
{
text = value.src;
}
) )
) cfg.plugins) )
// (lib.mapAttrs' ( ) cfg.plugins);
name: value:
lib.nameValuePair "Library/Application Support/streamlink/plugins/${name}.py" (
lib.mkIf (value.src != null) (
if (builtins.isPath value.src) then
{
source = value.src;
}
else
{
text = value.src;
}
)
)
) cfg.plugins);
}) })
] ]
); );

View file

@ -54,13 +54,12 @@ let
profilesIni = profilesIni =
lib.foldl lib.recursiveUpdate lib.foldl lib.recursiveUpdate
{ {
General = General = {
{ StartWithLastProfile = 1;
StartWithLastProfile = 1; }
} // lib.optionalAttrs (cfg.profileVersion != null) {
// lib.optionalAttrs (cfg.profileVersion != null) { Version = cfg.profileVersion;
Version = cfg.profileVersion; };
};
} }
( (
lib.flip map profilesWithId (profile: { lib.flip map profilesWithId (profile: {
@ -882,11 +881,13 @@ in
home.packages = [ home.packages = [
cfg.package cfg.package
] ++ lib.optional (lib.any (p: p.withExternalGnupg) (attrValues cfg.profiles)) pkgs.gpgme; ]
++ lib.optional (lib.any (p: p.withExternalGnupg) (attrValues cfg.profiles)) pkgs.gpgme;
mozilla.thunderbirdNativeMessagingHosts = [ mozilla.thunderbirdNativeMessagingHosts = [
cfg.package # package configured native messaging hosts (entire mail app actually) cfg.package # package configured native messaging hosts (entire mail app actually)
] ++ cfg.nativeMessagingHosts; # user configured native messaging hosts ]
++ cfg.nativeMessagingHosts; # user configured native messaging hosts
home.file = lib.mkMerge ( home.file = lib.mkMerge (
[ [

View file

@ -357,10 +357,11 @@ in
config = lib.mkIf cfg.enable ( config = lib.mkIf cfg.enable (
lib.mkMerge [ lib.mkMerge [
{ {
home.packages = home.packages = [
[ cfg.package ] cfg.package
++ lib.optional cfg.tmuxinator.enable pkgs.tmuxinator ]
++ lib.optional cfg.tmuxp.enable pkgs.tmuxp; ++ lib.optional cfg.tmuxinator.enable pkgs.tmuxinator
++ lib.optional cfg.tmuxp.enable pkgs.tmuxp;
} }
{ xdg.configFile."tmux/tmux.conf".text = lib.mkBefore tmuxConf; } { xdg.configFile."tmux/tmux.conf".text = lib.mkBefore tmuxConf; }

View file

@ -142,27 +142,26 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xresources.properties = xresources.properties = {
{ "URxvt.scrollBar" = cfg.scroll.bar.enable;
"URxvt.scrollBar" = cfg.scroll.bar.enable; "URxvt.scrollstyle" = cfg.scroll.bar.style;
"URxvt.scrollstyle" = cfg.scroll.bar.style; "URxvt.scrollBar_align" = cfg.scroll.bar.align;
"URxvt.scrollBar_align" = cfg.scroll.bar.align; "URxvt.scrollBar_right" = cfg.scroll.bar.position == "right";
"URxvt.scrollBar_right" = cfg.scroll.bar.position == "right"; "URxvt.scrollBar_floating" = cfg.scroll.bar.floating;
"URxvt.scrollBar_floating" = cfg.scroll.bar.floating; "URxvt.saveLines" = cfg.scroll.lines;
"URxvt.saveLines" = cfg.scroll.lines; "URxvt.scrollWithBuffer" = cfg.scroll.keepPosition;
"URxvt.scrollWithBuffer" = cfg.scroll.keepPosition; "URxvt.scrollTtyKeypress" = cfg.scroll.scrollOnKeystroke;
"URxvt.scrollTtyKeypress" = cfg.scroll.scrollOnKeystroke; "URxvt.scrollTtyOutput" = cfg.scroll.scrollOnOutput;
"URxvt.scrollTtyOutput" = cfg.scroll.scrollOnOutput; "URxvt.transparent" = cfg.transparent;
"URxvt.transparent" = cfg.transparent; "URxvt.shading" = cfg.shading;
"URxvt.shading" = cfg.shading; "URxvt.iso14755" = cfg.iso14755;
"URxvt.iso14755" = cfg.iso14755; }
} // lib.flip lib.mapAttrs' cfg.keybindings (
// lib.flip lib.mapAttrs' cfg.keybindings ( kb: action: lib.nameValuePair "URxvt.keysym.${kb}" action
kb: action: lib.nameValuePair "URxvt.keysym.${kb}" action )
) // lib.optionalAttrs (cfg.fonts != [ ]) {
// lib.optionalAttrs (cfg.fonts != [ ]) { "URxvt.font" = lib.concatStringsSep "," cfg.fonts;
"URxvt.font" = lib.concatStringsSep "," cfg.fonts; }
} // lib.flip lib.mapAttrs' cfg.extraConfig (k: v: lib.nameValuePair "URxvt.${k}" v);
// lib.flip lib.mapAttrs' cfg.extraConfig (k: v: lib.nameValuePair "URxvt.${k}" v);
}; };
} }

View file

@ -259,20 +259,20 @@ let
allProfilesExceptDefault = removeAttrs cfg.profiles [ "default" ]; allProfilesExceptDefault = removeAttrs cfg.profiles [ "default" ];
in in
{ {
imports = imports = [
[ ./haskell.nix
./haskell.nix (lib.mkChangedOptionModule
(lib.mkChangedOptionModule [
[ "programs"
"programs" "vscode"
"vscode" "immutableExtensionsDir"
"immutableExtensionsDir" ]
] [ "programs" "vscode" "mutableExtensionsDir" ]
[ "programs" "vscode" "mutableExtensionsDir" ] (config: !config.programs.vscode.immutableExtensionsDir)
(config: !config.programs.vscode.immutableExtensionsDir) )
) ]
] ++
++ map map
( (
v: v:
lib.mkRenamedOptionModule lib.mkRenamedOptionModule

View file

@ -62,6 +62,7 @@ in
programs.vscode.profiles.default.extensions = [ programs.vscode.profiles.default.extensions = [
pkgs.vscode-extensions.justusadam.language-haskell pkgs.vscode-extensions.justusadam.language-haskell
] ++ lib.optional cfg.hie.enable pkgs.vscode-extensions.alanz.vscode-hie-server; ]
++ lib.optional cfg.hie.enable pkgs.vscode-extensions.alanz.vscode-hie-server;
}; };
} }

View file

@ -227,34 +227,33 @@ in
nushell.extraConfig = mkIf cfg.enableNushellIntegration nushellIntegration; nushell.extraConfig = mkIf cfg.enableNushellIntegration nushellIntegration;
}; };
xdg.configFile = xdg.configFile = {
{ "yazi/keymap.toml" = mkIf (cfg.keymap != { }) {
"yazi/keymap.toml" = mkIf (cfg.keymap != { }) { source = tomlFormat.generate "yazi-keymap" cfg.keymap;
source = tomlFormat.generate "yazi-keymap" cfg.keymap; };
}; "yazi/yazi.toml" = mkIf (cfg.settings != { }) {
"yazi/yazi.toml" = mkIf (cfg.settings != { }) { source = tomlFormat.generate "yazi-settings" cfg.settings;
source = tomlFormat.generate "yazi-settings" cfg.settings; };
}; "yazi/theme.toml" = mkIf (cfg.theme != { }) {
"yazi/theme.toml" = mkIf (cfg.theme != { }) { source = tomlFormat.generate "yazi-theme" cfg.theme;
source = tomlFormat.generate "yazi-theme" cfg.theme; };
}; "yazi/init.lua" = mkIf (cfg.initLua != null) (
"yazi/init.lua" = mkIf (cfg.initLua != null) ( if builtins.isPath cfg.initLua then
if builtins.isPath cfg.initLua then {
{ source = cfg.initLua;
source = cfg.initLua; }
} else
else {
{ text = cfg.initLua;
text = cfg.initLua; }
} );
); }
} // (lib.mapAttrs' (
// (lib.mapAttrs' ( name: value: lib.nameValuePair "yazi/flavors/${name}.yazi" { source = value; }
name: value: lib.nameValuePair "yazi/flavors/${name}.yazi" { source = value; } ) cfg.flavors)
) cfg.flavors) // (lib.mapAttrs' (
// (lib.mapAttrs' ( name: value: lib.nameValuePair "yazi/plugins/${name}.yazi" { source = value; }
name: value: lib.nameValuePair "yazi/plugins/${name}.yazi" { source = value; } ) cfg.plugins);
) cfg.plugins);
warnings = lib.filter (s: s != "") ( warnings = lib.filter (s: s != "") (
lib.concatLists [ lib.concatLists [

View file

@ -154,11 +154,13 @@ in
"/run/current-system/sw" "/run/current-system/sw"
config.home.profileDirectory config.home.profileDirectory
cfg.iconTheme.package cfg.iconTheme.package
] ++ optional useCustomTheme hicolorTheme.package; ]
++ optional useCustomTheme hicolorTheme.package;
themes = [ themes = [
cfg.iconTheme cfg.iconTheme
] ++ optional useCustomTheme (hicolorTheme // { size = cfg.iconTheme.size; }); ]
++ optional useCustomTheme (hicolorTheme // { size = cfg.iconTheme.size; });
categories = [ categories = [
"actions" "actions"

View file

@ -22,7 +22,8 @@ let
finalConfig = { finalConfig = {
inherit (cfg) order; inherit (cfg) order;
} // cfg.extraConfig; }
// cfg.extraConfig;
configFile = jsonFormat.generate "dwm-status.json" finalConfig; configFile = jsonFormat.generate "dwm-status.json" finalConfig;

View file

@ -129,64 +129,61 @@ in
} }
(mkIf pkgs.stdenv.isLinux { (mkIf pkgs.stdenv.isLinux {
systemd.user.services.emacs = systemd.user.services.emacs = {
{ Unit = {
Unit = Description = "Emacs text editor";
{ Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
Description = "Emacs text editor";
Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/";
After = optional (cfg.startWithUserSession == "graphical") "graphical-session.target"; After = optional (cfg.startWithUserSession == "graphical") "graphical-session.target";
PartOf = optional (cfg.startWithUserSession == "graphical") "graphical-session.target"; PartOf = optional (cfg.startWithUserSession == "graphical") "graphical-session.target";
# Avoid killing the Emacs session, which may be full of # Avoid killing the Emacs session, which may be full of
# unsaved buffers. # unsaved buffers.
X-RestartIfChanged = false; X-RestartIfChanged = false;
}
// optionalAttrs needsSocketWorkaround {
# Emacs deletes its socket when shutting down, which systemd doesn't
# handle, resulting in a server without a socket.
# See https://github.com/nix-community/home-manager/issues/2018
RefuseManualStart = true;
};
Service =
{
Type = "notify";
# We wrap ExecStart in a login shell so Emacs starts with the user's
# environment, most importantly $PATH and $NIX_PROFILES. It may be
# worth investigating a more targeted approach for user services to
# import the user environment.
ExecStart = ''${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
# In case the user sets 'server-directory' or 'server-name' in
# their Emacs config, we want to specify the socket path explicitly
# so launching 'emacs.service' manually doesn't break emacsclient
# when using socket activation.
lib.optionalString cfg.socketActivation.enable "=${lib.escapeShellArg socketPath}"
} ${lib.escapeShellArgs cfg.extraOptions}"'';
# Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services.
SuccessExitStatus = 15;
Restart = "on-failure";
}
// optionalAttrs needsSocketWorkaround {
# Use read-only directory permissions to prevent emacs from
# deleting systemd's socket file before exiting.
ExecStartPost = "${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
ExecStopPost = "${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
};
} }
// optionalAttrs (cfg.startWithUserSession != false) { // optionalAttrs needsSocketWorkaround {
Install = { # Emacs deletes its socket when shutting down, which systemd doesn't
WantedBy = [ # handle, resulting in a server without a socket.
(if cfg.startWithUserSession == true then "default.target" else "graphical-session.target") # See https://github.com/nix-community/home-manager/issues/2018
]; RefuseManualStart = true;
};
}; };
Service = {
Type = "notify";
# We wrap ExecStart in a login shell so Emacs starts with the user's
# environment, most importantly $PATH and $NIX_PROFILES. It may be
# worth investigating a more targeted approach for user services to
# import the user environment.
ExecStart = ''${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
# In case the user sets 'server-directory' or 'server-name' in
# their Emacs config, we want to specify the socket path explicitly
# so launching 'emacs.service' manually doesn't break emacsclient
# when using socket activation.
lib.optionalString cfg.socketActivation.enable "=${lib.escapeShellArg socketPath}"
} ${lib.escapeShellArgs cfg.extraOptions}"'';
# Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services.
SuccessExitStatus = 15;
Restart = "on-failure";
}
// optionalAttrs needsSocketWorkaround {
# Use read-only directory permissions to prevent emacs from
# deleting systemd's socket file before exiting.
ExecStartPost = "${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
ExecStopPost = "${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
};
}
// optionalAttrs (cfg.startWithUserSession != false) {
Install = {
WantedBy = [
(if cfg.startWithUserSession == true then "default.target" else "graphical-session.target")
];
};
};
home.packages = optional cfg.client.enable (lib.hiPrio clientDesktopItem); home.packages = optional cfg.client.enable (lib.hiPrio clientDesktopItem);
}) })
@ -227,7 +224,8 @@ in
ProgramArguments = [ ProgramArguments = [
"${cfg.package}/bin/emacs" "${cfg.package}/bin/emacs"
"--fg-daemon" "--fg-daemon"
] ++ cfg.extraOptions; ]
++ cfg.extraOptions;
RunAtLoad = true; RunAtLoad = true;
KeepAlive = { KeepAlive = {
Crashed = true; Crashed = true;

View file

@ -23,34 +23,30 @@ let
${gpgPkg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null ${gpgPkg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null
''; '';
gpgInitStr = gpgInitStr = ''
'' GPG_TTY="$(tty)"
GPG_TTY="$(tty)" export GPG_TTY
export GPG_TTY ''
'' + optionalString cfg.enableSshSupport gpgSshSupportStr;
+ optionalString cfg.enableSshSupport gpgSshSupportStr;
gpgZshInitStr = gpgZshInitStr = ''
'' export GPG_TTY=$TTY
export GPG_TTY=$TTY ''
'' + optionalString cfg.enableSshSupport gpgSshSupportStr;
+ optionalString cfg.enableSshSupport gpgSshSupportStr;
gpgFishInitStr = gpgFishInitStr = ''
'' set -gx GPG_TTY (tty)
set -gx GPG_TTY (tty) ''
'' + optionalString cfg.enableSshSupport gpgSshSupportStr;
+ optionalString cfg.enableSshSupport gpgSshSupportStr;
gpgNushellInitStr = gpgNushellInitStr = ''
'' $env.GPG_TTY = (tty)
$env.GPG_TTY = (tty) ''
'' + optionalString cfg.enableSshSupport ''
+ optionalString cfg.enableSshSupport '' ${gpgPkg}/bin/gpg-connect-agent --quiet updatestartuptty /bye | ignore
${gpgPkg}/bin/gpg-connect-agent --quiet updatestartuptty /bye | ignore
$env.SSH_AUTH_SOCK = ($env.SSH_AUTH_SOCK? | default (${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)) $env.SSH_AUTH_SOCK = ($env.SSH_AUTH_SOCK? | default (${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket))
''; '';
# mimic `gpgconf` output for use in the service definitions. # mimic `gpgconf` output for use in the service definitions.
# we cannot use `gpgconf` directly because it heavily depends on system # we cannot use `gpgconf` directly because it heavily depends on system
@ -439,7 +435,8 @@ in
ProgramArguments = [ ProgramArguments = [
"${gpgPkg}/bin/gpg-agent" "${gpgPkg}/bin/gpg-agent"
"--supervised" "--supervised"
] ++ optional cfg.verbose "--verbose"; ]
++ optional cfg.verbose "--verbose";
EnvironmentVariables = { EnvironmentVariables = {
GNUPGHOME = homedir; GNUPGHOME = homedir;
}; };

View file

@ -131,7 +131,8 @@ in
RestartSec = "10"; RestartSec = "10";
}; };
}; };
} // transitionServices; }
// transitionServices;
timers = lib.mapAttrs' ( timers = lib.mapAttrs' (
name: transitionCfg: name: transitionCfg:

View file

@ -44,9 +44,10 @@ let
Restart = "always"; Restart = "always";
RestartSec = 30; RestartSec = 30;
Type = "simple"; Type = "simple";
Environment = Environment = [
[ "PATH=${cfg.path}" ] "PATH=${cfg.path}"
++ lib.optional account.notmuch.enable "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config"; ]
++ lib.optional account.notmuch.enable "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config";
}; };
Install = { Install = {
@ -64,23 +65,22 @@ let
name = "imapnotify-${name}"; name = "imapnotify-${name}";
value = { value = {
enable = true; enable = true;
config = config = {
{ # Use the nix store path for config to ensure service restarts when it changes
# Use the nix store path for config to ensure service restarts when it changes ProgramArguments = [
ProgramArguments = [ "${lib.getExe cfg.package}"
"${lib.getExe cfg.package}" "-conf"
"-conf" "${genAccountConfig account}"
"${genAccountConfig account}" ];
]; KeepAlive = true;
KeepAlive = true; ThrottleInterval = 30;
ThrottleInterval = 30; ExitTimeOut = 0;
ExitTimeOut = 0; ProcessType = "Background";
ProcessType = "Background"; RunAtLoad = true;
RunAtLoad = true; }
} // optionalAttrs account.notmuch.enable {
// optionalAttrs account.notmuch.enable { EnvironmentVariables.NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/default/config";
EnvironmentVariables.NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/default/config"; };
};
}; };
}; };

View file

@ -90,14 +90,13 @@ in
systemd.user = { systemd.user = {
services.ludusavi = { services.ludusavi = {
Unit.Description = "Run a game save backup with Ludusavi"; Unit.Description = "Run a game save backup with Ludusavi";
Service = Service = {
{ Type = "oneshot";
Type = "oneshot"; ExecStart = "${lib.getExe cfg.package} backup --force";
ExecStart = "${lib.getExe cfg.package} backup --force"; }
} // lib.optionalAttrs cfg.backupNotification {
// lib.optionalAttrs cfg.backupNotification { ExecStartPost = "${lib.getExe pkgs.libnotify} 'Ludusavi' 'Backup completed' -i com.mtkennerly.ludusavi -a 'Ludusavi'";
ExecStartPost = "${lib.getExe pkgs.libnotify} 'Ludusavi' 'Backup completed' -i com.mtkennerly.ludusavi -a 'Ludusavi'"; };
};
}; };
timers.ludusavi = { timers.ludusavi = {
Unit.Description = "Run a game save backup with Ludusavi"; Unit.Description = "Run a game save backup with Ludusavi";

View file

@ -9,10 +9,11 @@ let
cfg = config.services.mbsync; cfg = config.services.mbsync;
mbsyncOptions = mbsyncOptions = [
[ "--all" ] "--all"
++ lib.optional (cfg.verbose) "--verbose" ]
++ lib.optional (cfg.configFile != null) "--config ${cfg.configFile}"; ++ lib.optional (cfg.verbose) "--verbose"
++ lib.optional (cfg.configFile != null) "--config ${cfg.configFile}";
in in
{ {
@ -82,17 +83,16 @@ in
Description = "mbsync mailbox synchronization"; Description = "mbsync mailbox synchronization";
}; };
Service = Service = {
{ Type = "oneshot";
Type = "oneshot"; ExecStart = "${cfg.package}/bin/mbsync ${lib.concatStringsSep " " mbsyncOptions}";
ExecStart = "${cfg.package}/bin/mbsync ${lib.concatStringsSep " " mbsyncOptions}"; }
} // (lib.optionalAttrs (cfg.postExec != null) {
// (lib.optionalAttrs (cfg.postExec != null) { ExecStartPost = cfg.postExec;
ExecStartPost = cfg.postExec; })
}) // (lib.optionalAttrs (cfg.preExec != null) {
// (lib.optionalAttrs (cfg.preExec != null) { ExecStartPre = cfg.preExec;
ExecStartPre = cfg.preExec; });
});
}; };
systemd.user.timers.mbsync = { systemd.user.timers.mbsync = {

View file

@ -228,7 +228,8 @@ in
(lib.getExe cfg.package) (lib.getExe cfg.package)
"--no-daemon" "--no-daemon"
"${mpdConf}" "${mpdConf}"
] ++ cfg.extraArgs; ]
++ cfg.extraArgs;
KeepAlive = true; KeepAlive = true;
ProcessType = "Interactive"; ProcessType = "Interactive";
}; };

View file

@ -19,15 +19,14 @@ let
}; };
mpdris2Conf = { mpdris2Conf = {
Connection = Connection = {
{ host = cfg.mpd.host;
host = cfg.mpd.host; port = cfg.mpd.port;
port = cfg.mpd.port; music_dir = cfg.mpd.musicDirectory;
music_dir = cfg.mpd.musicDirectory; }
} // lib.optionalAttrs (cfg.mpd.password != null) {
// lib.optionalAttrs (cfg.mpd.password != null) { password = cfg.mpd.password;
password = cfg.mpd.password; };
};
Bling = { Bling = {
notify = cfg.notifications; notify = cfg.notifications;

View file

@ -118,7 +118,8 @@ in
config = { config = {
ProgramArguments = [ ProgramArguments = [
"${nixPackage}/bin/nix-collect-garbage" "${nixPackage}/bin/nix-collect-garbage"
] ++ lib.optional (cfg.options != null) cfg.options; ]
++ lib.optional (cfg.options != null) cfg.options;
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.frequency; StartCalendarInterval = lib.hm.darwin.mkCalendarInterval cfg.frequency;
}; };
}; };

View file

@ -218,8 +218,11 @@ in
{ {
Description = "${programName} colour temperature adjuster"; Description = "${programName} colour temperature adjuster";
Documentation = serviceDocumentation; Documentation = serviceDocumentation;
After = After = [
[ "graphical-session.target" ] ++ (lib.optional cfg.tray "tray.target") ++ geoclueAgentService; "graphical-session.target"
]
++ (lib.optional cfg.tray "tray.target")
++ geoclueAgentService;
Wants = geoclueAgentService; Wants = geoclueAgentService;
Requires = lib.mkIf cfg.tray "tray.target"; Requires = lib.mkIf cfg.tray "tray.target";
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];

View file

@ -395,87 +395,85 @@ in
After = [ "network-online.target" ]; After = [ "network-online.target" ];
}; };
Service = Service = {
{ Type = "oneshot";
Type = "oneshot";
X-RestartIfChanged = true; X-RestartIfChanged = true;
RuntimeDirectory = serviceName; RuntimeDirectory = serviceName;
CacheDirectory = serviceName; CacheDirectory = serviceName;
CacheDirectoryMode = "0700"; CacheDirectoryMode = "0700";
PrivateTmp = true; PrivateTmp = true;
Environment = Environment = [
[ "RESTIC_CACHE_DIR=%C"
"RESTIC_CACHE_DIR=%C" "PATH=${backup.ssh-package}/bin"
"PATH=${backup.ssh-package}/bin" ]
] ++ attrsToEnvs (
++ attrsToEnvs ( {
{ RESTIC_PROGRESS_FPS = backup.progressFps;
RESTIC_PROGRESS_FPS = backup.progressFps; RESTIC_PASSWORD_FILE = backup.passwordFile;
RESTIC_PASSWORD_FILE = backup.passwordFile; RESTIC_REPOSITORY = backup.repository;
RESTIC_REPOSITORY = backup.repository; RESTIC_REPOSITORY_FILE = backup.repositoryFile;
RESTIC_REPOSITORY_FILE = backup.repositoryFile; }
} // backup.rcloneOptions
// backup.rcloneOptions );
);
ExecStart = ExecStart =
lib.optional doBackup backupCmd lib.optional doBackup backupCmd
++ lib.optionals doPrune [ ++ lib.optionals doPrune [
unlockCmd unlockCmd
forgetCmd forgetCmd
] ]
++ lib.optional doCheck checkCmd; ++ lib.optional doCheck checkCmd;
ExecStartPre = lib.getExe ( ExecStartPre = lib.getExe (
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "${serviceName}-exec-start-pre"; name = "${serviceName}-exec-start-pre";
inherit runtimeInputs; inherit runtimeInputs;
text = '' text = ''
set -x set -x
${lib.optionalString (backup.backupPrepareCommand != null) '' ${lib.optionalString (backup.backupPrepareCommand != null) ''
${pkgs.writeScript "backupPrepareCommand" backup.backupPrepareCommand} ${pkgs.writeScript "backupPrepareCommand" backup.backupPrepareCommand}
''} ''}
${lib.optionalString (backup.initialize) '' ${lib.optionalString (backup.initialize) ''
${ ${
mkResticCmd [ mkResticCmd [
"cat" "cat"
"config" "config"
] ]
} 2>/dev/null || ${mkResticCmd "init"} } 2>/dev/null || ${mkResticCmd "init"}
''} ''}
${lib.optionalString (backup.paths != null && backup.paths != [ ]) '' ${lib.optionalString (backup.paths != null && backup.paths != [ ]) ''
cat ${pkgs.writeText "staticPaths" (lib.concatLines backup.paths)} >> ${filesFromTmpFile} cat ${pkgs.writeText "staticPaths" (lib.concatLines backup.paths)} >> ${filesFromTmpFile}
''} ''}
${lib.optionalString (backup.dynamicFilesFrom != null) '' ${lib.optionalString (backup.dynamicFilesFrom != null) ''
${pkgs.writeScript "dynamicFilesFromScript" backup.dynamicFilesFrom} >> ${filesFromTmpFile} ${pkgs.writeScript "dynamicFilesFromScript" backup.dynamicFilesFrom} >> ${filesFromTmpFile}
''} ''}
''; '';
} }
); );
ExecStopPost = lib.getExe ( ExecStopPost = lib.getExe (
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "${serviceName}-exec-stop-post"; name = "${serviceName}-exec-stop-post";
inherit runtimeInputs; inherit runtimeInputs;
text = '' text = ''
set -x set -x
${lib.optionalString (backup.backupCleanupCommand != null) '' ${lib.optionalString (backup.backupCleanupCommand != null) ''
${pkgs.writeScript "backupCleanupCommand" backup.backupCleanupCommand} ${pkgs.writeScript "backupCleanupCommand" backup.backupCleanupCommand}
''} ''}
''; '';
} }
); );
} }
// lib.optionalAttrs (backup.environmentFile != null) { // lib.optionalAttrs (backup.environmentFile != null) {
EnvironmentFile = backup.environmentFile; EnvironmentFile = backup.environmentFile;
}; };
} }
) cfg.backups; ) cfg.backups;

View file

@ -250,7 +250,8 @@ in
"$" "$"
"bezier" "bezier"
"name" "name"
] ++ lib.optionals cfg.sourceFirst [ "source" ]; ]
++ lib.optionals cfg.sourceFirst [ "source" ];
example = [ example = [
"$" "$"
"bezier" "bezier"
@ -334,7 +335,8 @@ in
BindsTo = [ "graphical-session.target" ]; BindsTo = [ "graphical-session.target" ];
Wants = [ Wants = [
"graphical-session-pre.target" "graphical-session-pre.target"
] ++ lib.optional cfg.systemd.enableXdgAutostart "xdg-desktop-autostart.target"; ]
++ lib.optional cfg.systemd.enableXdgAutostart "xdg-desktop-autostart.target";
After = [ "graphical-session-pre.target" ]; After = [ "graphical-session-pre.target" ];
Before = lib.mkIf cfg.systemd.enableXdgAutostart [ "xdg-desktop-autostart.target" ]; Before = lib.mkIf cfg.systemd.enableXdgAutostart [ "xdg-desktop-autostart.target" ];
}; };

View file

@ -48,40 +48,39 @@ let
}; };
startupModule = types.submodule { startupModule = types.submodule {
options = options = {
{ command = mkOption {
command = mkOption { type = types.str;
type = types.str; description = "Command that will be executed on startup.";
description = "Command that will be executed on startup.";
};
always = mkOption {
type = types.bool;
default = false;
description = "Whether to run command on each ${moduleName} restart.";
};
}
// lib.optionalAttrs isI3 {
notification = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable startup-notification support for the command.
See {option}`--no-startup-id` option description in the i3 user guide.
'';
};
workspace = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Launch application on a particular workspace. DEPRECATED:
Use [](#opt-xsession.windowManager.i3.config.assigns)
instead. See <https://github.com/nix-community/home-manager/issues/265>.
'';
};
}; };
always = mkOption {
type = types.bool;
default = false;
description = "Whether to run command on each ${moduleName} restart.";
};
}
// lib.optionalAttrs isI3 {
notification = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable startup-notification support for the command.
See {option}`--no-startup-id` option description in the i3 user guide.
'';
};
workspace = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Launch application on a particular workspace. DEPRECATED:
Use [](#opt-xsession.windowManager.i3.config.assigns)
instead. See <https://github.com/nix-community/home-manager/issues/265>.
'';
};
};
}; };
barModule = types.submodule { barModule = types.submodule {

View file

@ -718,7 +718,8 @@ in
BindsTo = [ "graphical-session.target" ]; BindsTo = [ "graphical-session.target" ];
Wants = [ Wants = [
"graphical-session-pre.target" "graphical-session-pre.target"
] ++ optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target"; ]
++ optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target";
After = [ "graphical-session-pre.target" ]; After = [ "graphical-session-pre.target" ];
Before = optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target"; Before = optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target";
}; };

View file

@ -201,8 +201,7 @@ in
]; ];
home.packages = home.packages =
lib.optional (cfg.package != null) cfg.package lib.optional (cfg.package != null) cfg.package ++ lib.optional cfg.xwayland.enable pkgs.xwayland;
++ lib.optional cfg.xwayland.enable pkgs.xwayland;
# Configuration file ~/.config/river/init # Configuration file ~/.config/river/init
xdg.configFile."river/init".source = pkgs.writeShellScript "init" ( xdg.configFile."river/init".source = pkgs.writeShellScript "init" (

View file

@ -167,7 +167,8 @@ in
Service = { Service = {
Type = if cfg.once then "oneshot" else "simple"; Type = if cfg.once then "oneshot" else "simple";
ExecStart = "${script}"; ExecStart = "${script}";
} // lib.optionalAttrs (!cfg.once) { Restart = "always"; }; }
// lib.optionalAttrs (!cfg.once) { Restart = "always"; };
Install.WantedBy = [ "graphical-session.target" ]; Install.WantedBy = [ "graphical-session.target" ];
}; };
}; };

View file

@ -31,7 +31,8 @@ let
osConfig = config; osConfig = config;
osClass = _class; osClass = _class;
modulesPath = builtins.toString ../modules; modulesPath = builtins.toString ../modules;
} // cfg.extraSpecialArgs; }
// cfg.extraSpecialArgs;
modules = [ modules = [
( (
{ name, ... }: { name, ... }:
@ -62,7 +63,8 @@ let
}; };
} }
) )
] ++ cfg.sharedModules; ]
++ cfg.sharedModules;
}; };
in in

View file

@ -13,13 +13,11 @@ let
dynDir = testDir.overrideAttrs ( dynDir = testDir.overrideAttrs (
final: prev: { final: prev: {
buildCommand = buildCommand = prev.buildCommand + ''
prev.buildCommand echo more secret data > $out/top-secret
+ '' echo shhhh > $out/top-secret-v2
echo more secret data > $out/top-secret echo this isnt secret > $out/metadata
echo shhhh > $out/top-secret-v2 '';
echo this isnt secret > $out/metadata
'';
} }
); );
in in

View file

@ -3,47 +3,46 @@
{ {
config = { config = {
programs.htop.enable = true; programs.htop.enable = true;
programs.htop.settings = programs.htop.settings = {
{ color_scheme = 6;
color_scheme = 6; cpu_count_from_one = 0;
cpu_count_from_one = 0; delay = 15;
delay = 15; fields = with config.lib.htop.fields; [
fields = with config.lib.htop.fields; [ PID
PID USER
USER PRIORITY
PRIORITY NICE
NICE M_SIZE
M_SIZE M_RESIDENT
M_RESIDENT M_SHARE
M_SHARE STATE
STATE PERCENT_CPU
PERCENT_CPU PERCENT_MEM
PERCENT_MEM TIME
TIME COMM
COMM ];
]; highlight_base_name = 1;
highlight_base_name = 1; highlight_megabytes = 1;
highlight_megabytes = 1; highlight_threads = 1;
highlight_threads = 1; }
} // (
// ( with config.lib.htop;
with config.lib.htop; leftMeters [
leftMeters [ (bar "AllCPUs2")
(bar "AllCPUs2") (bar "Memory")
(bar "Memory") (bar "Swap")
(bar "Swap") (text "Zram")
(text "Zram") ]
] )
) // (
// ( with config.lib.htop;
with config.lib.htop; rightMeters [
rightMeters [ (text "Tasks")
(text "Tasks") (text "LoadAverage")
(text "LoadAverage") (text "Uptime")
(text "Uptime") (text "Systemd")
(text "Systemd") ]
] );
);
nmt.script = '' nmt.script = ''
htoprc=home-files/.config/htop/htoprc htoprc=home-files/.config/htop/htoprc

View file

@ -35,17 +35,16 @@
}; };
}; };
nmt.script = nmt.script = ''
'' assertFileExists home-files/.config/kitty/kitty.conf
assertFileExists home-files/.config/kitty/kitty.conf assertFileContent \
assertFileContent \ home-files/.config/kitty/kitty.conf \
home-files/.config/kitty/kitty.conf \ ${./example-settings-expected.conf}
${./example-settings-expected.conf} ''
'' + lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
+ lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' assertFileContent \
assertFileContent \ home-files/.config/kitty/macos-launch-services-cmdline \
home-files/.config/kitty/macos-launch-services-cmdline \ ${./example-macos-launch-services-cmdline}
${./example-macos-launch-services-cmdline} '';
'';
}; };
} }

View file

@ -42,7 +42,8 @@ espansoExtraArgs: {
]; ];
}; };
}; };
} // espansoExtraArgs; }
// espansoExtraArgs;
nmt.script = '' nmt.script = ''
serviceFile=home-files/.config/systemd/user/espanso.service serviceFile=home-files/.config/systemd/user/espanso.service