fix: Format according to nixfmt-rfc-style

This commit is contained in:
Jalil David Salamé Messina 2024-04-05 11:55:35 +02:00
parent e3e96bbf40
commit ce37942672
Signed by: jalil
GPG key ID: F016B9E770737A0B
24 changed files with 606 additions and 302 deletions

View file

@ -1,25 +1,41 @@
{ overlays, nvim-config, stylix ? null }: { config, pkgs, lib, ... }:
{
overlays,
nvim-config,
stylix ? null,
}:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.jhome;
devcfg = cfg.dev;
in
{
imports = [
# Apply overlays
{ nixpkgs = { inherit overlays; }; }
nvim-config
./options.nix
./gui
./users.nix
] ++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{
stylix.image = builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
};
}
];
imports =
[
# Apply overlays
{
nixpkgs = {
inherit overlays;
};
}
nvim-config
./options.nix
./gui
./users.nix
]
++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{
stylix.image = builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
};
}
];
config = lib.mkMerge [
(lib.mkIf cfg.enable {
@ -65,7 +81,8 @@ in
# GPG Agent
services.gpg-agent.enable = true;
services.gpg-agent.maxCacheTtl = 86400;
services.gpg-agent.pinentryPackage = if config.jhome.gui.enable then pkgs.pinentry-qt else pkgs.pinentry-curses;
services.gpg-agent.pinentryPackage =
if config.jhome.gui.enable then pkgs.pinentry-qt else pkgs.pinentry-curses;
services.gpg-agent.extraConfig = "allow-preset-passphrase";
# Spotifyd
services.spotifyd.enable = true;

View file

@ -1,4 +1,10 @@
{ config, lib, pkgs, osConfig ? null, ... }:
{
config,
lib,
pkgs,
osConfig ? null,
...
}:
let
inherit (config) jhome;
flatpakEnabled = if osConfig != null then osConfig.services.flatpak.enable else false;

View file

@ -5,30 +5,60 @@ let
selectAudio = "${pkgs.audiomenu}/bin/audiomenu --menu 'fuzzel --dmenu'";
swayconf = config.wayland.windowManager.sway.config;
mod = swayconf.modifier;
workspaces = map toString [ 1 2 3 4 5 6 7 8 9 ];
workspaces = map toString [
1
2
3
4
5
6
7
8
9
];
dirs =
map
(dir: {
key = swayconf.${dir};
arrow = dir;
direction = dir;
}) [ "up" "down" "left" "right" ];
})
[
"up"
"down"
"left"
"right"
];
joinKeys = builtins.concatStringsSep "+";
# Generate a keybind from a modifier prefix and a key
keycombo = prefix: key: joinKeys (prefix ++ [ key ]);
modKeybind = keycombo [ mod ];
modCtrlKeybind = keycombo [ mod "Ctrl" ];
modShiftKeybind = keycombo [ mod "Shift" ];
modCtrlShiftKeybind = keycombo [ mod "Ctrl" "Shift" ];
modCtrlKeybind = keycombo [
mod
"Ctrl"
];
modShiftKeybind = keycombo [
mod
"Shift"
];
modCtrlShiftKeybind = keycombo [
mod
"Ctrl"
"Shift"
];
dir2resize.up = "resize grow height";
dir2resize.down = "resize shrink height";
dir2resize.right = "resize grow width";
dir2resize.left = "resize shrink width";
# Bind a key combo to an action
genKeybind = prefix: action: key: { "${prefix key}" = "${action key}"; };
genKey = prefix: action: genKeybind ({ key, ... }: prefix key) ({ direction, ... }: action direction);
genArrow = prefix: action: genKeybind ({ arrow, ... }: prefix arrow) ({ direction, ... }: action direction);
genArrowAndKey = prefix: action: key: (genKey prefix action key) // (genArrow prefix action key);
genKey =
prefix: action: genKeybind ({ key, ... }: prefix key) ({ direction, ... }: action direction);
genArrow =
prefix: action: genKeybind ({ arrow, ... }: prefix arrow) ({ direction, ... }: action direction);
genArrowAndKey =
prefix: action: key:
(genKey prefix action key) // (genArrow prefix action key);
# Move window
moveWindowKeybinds = map (genArrowAndKey modShiftKeybind (dir: "move ${dir}")) dirs;
# Focus window
@ -36,44 +66,52 @@ let
# Resize window
resizeWindowKeybinds = map (genArrowAndKey modCtrlKeybind (dir: dir2resize.${dir})) dirs;
# Move container to workspace
moveWorkspaceKeybindings = map (genKeybind modShiftKeybind (number: "move container to workspace number ${number}")) workspaces;
moveWorkspaceKeybindings = map (genKeybind modShiftKeybind (
number: "move container to workspace number ${number}"
)) workspaces;
# Focus workspace
focusWorkspaceKeybindings = map (genKeybind modKeybind (number: "workspace number ${number}")) workspaces;
focusWorkspaceKeybindings = map (genKeybind modKeybind (
number: "workspace number ${number}"
)) workspaces;
# Move container to Workspace and focus on it
moveFocusWorkspaceKeybindings = map (genKeybind modCtrlShiftKeybind (number: "move container to workspace number ${number}; workspace number ${number}")) workspaces;
moveFocusWorkspaceKeybindings = map (genKeybind modCtrlShiftKeybind (
number: "move container to workspace number ${number}; workspace number ${number}"
)) workspaces;
in
builtins.foldl' (l: r: l // r)
{
"${mod}+Return" = "exec ${swayconf.terminal}";
"${mod}+D" = "exec ${swayconf.menu}";
"${mod}+P" = "exec ${passmenu}";
"${mod}+F2" = "exec qutebrowser";
"${mod}+Shift+Q" = "kill";
"${mod}+F" = "fullscreen toggle";
# Media Controls
"${mod}+F10" = "exec ${selectAudio} select-sink";
"${mod}+Shift+F10" = "exec ${selectAudio} select-source";
"XF86AudioRaiseVolume" = "exec ${pkgs.avizo}/bin/volumectl up";
"XF86AudioLowerVolume" = "exec ${pkgs.avizo}/bin/volumectl down";
"XF86AudioMute" = "exec ${pkgs.avizo}/bin/volumectl toggle-mute";
"XF86ScreenSaver" = "exec swaylock --image ${cfg.background}";
"XF86MonBrightnessUp" = "exec ${pkgs.avizo}/bin/lightctl up";
"XF86MonBrightnessDown" = "exec ${pkgs.avizo}/bin/lightctl down";
# Floating
"${mod}+Space" = "floating toggle";
"${mod}+Shift+Space" = "focus mode_toggle";
# Scratchpad
"${mod}+Minus" = "scratchpad show";
"${mod}+Shift+Minus" = "move scratchpad";
# Layout
"${mod}+e" = "layout toggle split";
# Session control
"${mod}+r" = "reload";
"${mod}+Shift+m" = "exit";
}
(focusWindowKeybinds
{
"${mod}+Return" = "exec ${swayconf.terminal}";
"${mod}+D" = "exec ${swayconf.menu}";
"${mod}+P" = "exec ${passmenu}";
"${mod}+F2" = "exec qutebrowser";
"${mod}+Shift+Q" = "kill";
"${mod}+F" = "fullscreen toggle";
# Media Controls
"${mod}+F10" = "exec ${selectAudio} select-sink";
"${mod}+Shift+F10" = "exec ${selectAudio} select-source";
"XF86AudioRaiseVolume" = "exec ${pkgs.avizo}/bin/volumectl up";
"XF86AudioLowerVolume" = "exec ${pkgs.avizo}/bin/volumectl down";
"XF86AudioMute" = "exec ${pkgs.avizo}/bin/volumectl toggle-mute";
"XF86ScreenSaver" = "exec swaylock --image ${cfg.background}";
"XF86MonBrightnessUp" = "exec ${pkgs.avizo}/bin/lightctl up";
"XF86MonBrightnessDown" = "exec ${pkgs.avizo}/bin/lightctl down";
# Floating
"${mod}+Space" = "floating toggle";
"${mod}+Shift+Space" = "focus mode_toggle";
# Scratchpad
"${mod}+Minus" = "scratchpad show";
"${mod}+Shift+Minus" = "move scratchpad";
# Layout
"${mod}+e" = "layout toggle split";
# Session control
"${mod}+r" = "reload";
"${mod}+Shift+m" = "exit";
}
(
focusWindowKeybinds
++ moveWindowKeybinds
++ resizeWindowKeybinds
++ focusWorkspaceKeybindings
++ moveWorkspaceKeybindings
++ moveFocusWorkspaceKeybindings)
++ moveFocusWorkspaceKeybindings
)

View file

@ -22,23 +22,22 @@ let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in
pkgs.writers.writeDashBin "configure-gtk"
''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
config="${config.xdg.configHome}/gtk-3.0/settings.ini"
if [ ! -f "$config" ]; then exit 1; fi
# Read settings from gtk3
gtk_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
icon_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-icon-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
cursor_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-cursor-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')"
${pkgs.glib}/bin/gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" icon-theme "$icon_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name"
${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark
'';
pkgs.writers.writeDashBin "configure-gtk" ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
config="${config.xdg.configHome}/gtk-3.0/settings.ini"
if [ ! -f "$config" ]; then exit 1; fi
# Read settings from gtk3
gtk_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
icon_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-icon-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
cursor_theme="$(${pkgs.gnugrep}/bin/grep 'gtk-cursor-theme-name' "$config" | ${pkgs.gnused}/bin/sed 's/.*\s*=\s*//')"
font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')"
${pkgs.glib}/bin/gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" icon-theme "$icon_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
${pkgs.glib}/bin/gsettings set "$gnome_schema" font-name "$font_name"
${pkgs.glib}/bin/gsettings set "$gnome_schema" color-scheme prefer-dark
'';
cmdOnce = command: { inherit command; };
cmdAlways = command: {
inherit command;
@ -60,15 +59,23 @@ in
window.border = 2;
# Make certain windows floating
window.commands = [
{ command = "floating enable"; criteria.title = "zoom"; }
{ command = "floating enable"; criteria.class = "floating"; }
{ command = "floating enable"; criteria.app_id = "floating"; }
{
command = "floating enable";
criteria.title = "zoom";
}
{
command = "floating enable";
criteria.class = "floating";
}
{
command = "floating enable";
criteria.app_id = "floating";
}
];
# Startup scripts
startup =
[ (cmdAlways "${configure-gtk}/bin/configure-gtk") ]
++ (builtins.map cmdAlways cfg.exec.always)
++ (builtins.map cmdOnce cfg.exec.once);
startup = [
(cmdAlways "${configure-gtk}/bin/configure-gtk")
] ++ (builtins.map cmdAlways cfg.exec.always) ++ (builtins.map cmdOnce cfg.exec.once);
# Keyboard configuration
input."type:keyboard" = {
repeat_delay = "300";

View file

@ -1,5 +1,7 @@
{ config, lib }:
let cfg = config.jhome.gui; in
let
cfg = config.jhome.gui;
in
{
mainBar.layer = "top";
mainBar.position = "top";
@ -7,9 +9,13 @@ let cfg = config.jhome.gui; in
# Choose the order of the modules
mainBar.modules-left = [ "sway/workspaces" ];
mainBar.modules-center = [ "clock" ];
mainBar.modules-right = [ "pulseaudio" "backlight" "battery" "sway/language" "memory" ]
++ lib.optional (cfg.tempInfo != null) "temperature"
++ [ "tray" ];
mainBar.modules-right = [
"pulseaudio"
"backlight"
"battery"
"sway/language"
"memory"
] ++ lib.optional (cfg.tempInfo != null) "temperature" ++ [ "tray" ];
mainBar."sway/workspaces".disable-scroll = true;
mainBar."sway/workspaces".persistent-workspaces."1" = [ ];
mainBar."sway/workspaces".persistent-workspaces."2" = [ ];
@ -41,20 +47,37 @@ let cfg = config.jhome.gui; in
mainBar.pulseaudio.format-icons.phone = "󰘂";
mainBar.pulseaudio.format-icons.portable = "";
mainBar.pulseaudio.format-icons.car = "";
mainBar.pulseaudio.format-icons.default = [ "󰕿" "󰖀" "󰕾" ];
mainBar.pulseaudio.format-icons.default = [
"󰕿"
"󰖀"
"󰕾"
];
mainBar.pulseaudio.on-click = "pavucontrol";
mainBar.pulseaudio.min-length = 13;
mainBar.temperature =
lib.optionalAttrs (cfg.tempInfo != null) {
inherit (cfg.tempInfo) hwmon-path;
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [ "" "" "" "" "" ];
tooltip = false;
};
mainBar.temperature = lib.optionalAttrs (cfg.tempInfo != null) {
inherit (cfg.tempInfo) hwmon-path;
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [
""
""
""
""
""
];
tooltip = false;
};
mainBar.backlight.device = "intel_backlight";
mainBar.backlight.format = "{percent}% {icon}";
mainBar.backlight.format-icons = [ "󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠" ];
mainBar.backlight.format-icons = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
mainBar.backlight.min-length = 7;
mainBar.battery.states.warning = 30;
mainBar.battery.states.critical = 15;
@ -62,7 +85,18 @@ let cfg = config.jhome.gui; in
mainBar.battery.format-charging = "{capacity}% 󰂄";
mainBar.battery.format-plugged = "{capacity}% 󰚥";
mainBar.battery.format-alt = "{time} {icon}";
mainBar.battery.format-icons = [ "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ];
mainBar.battery.format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
mainBar.tray.icon-size = 16;
mainBar.tray.spacing = 0;
}

View file

@ -2,9 +2,12 @@
let
inherit (lib) types;
mkExtraPackagesOption = name: defaultPkgsPath:
mkExtraPackagesOption =
name: defaultPkgsPath:
let
text = lib.strings.concatMapStringsSep " " (pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath)) defaultPkgsPath;
text = lib.strings.concatMapStringsSep " " (
pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath)
) defaultPkgsPath;
defaultText = lib.literalExpression "[ ${text} ]";
default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath;
in
@ -126,7 +129,10 @@ let
description = "The terminal emulator to use.";
default = "wezterm";
example = "alacritty";
type = types.enum [ "wezterm" "alacritty" ];
type = types.enum [
"wezterm"
"alacritty"
];
};
};
in

View file

@ -20,10 +20,12 @@ in
};
})
(lib.mkIf unlockKey {
xdg.configFile.pam-gnupg.text = ''
${gpgHome}
xdg.configFile.pam-gnupg.text =
''
${gpgHome}
'' + (lib.strings.concatLines cfg.gpg.unlockKeys);
''
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
})
];
}