[fix] fmt: change formatter to nixfmt-rfc-style

Alejandra has ads and splits files into too many new lines.
This commit is contained in:
Jalil David Salamé Messina 2024-07-03 23:58:26 +02:00
parent 711c1aa81d
commit 91284a73ca
Signed by: jalil
GPG key ID: F016B9E770737A0B
28 changed files with 800 additions and 742 deletions

View file

@ -1,15 +1,18 @@
{
nvim-config,
stylix ? null,
}: {
}:
{
config,
pkgs,
lib,
...
}: let
}:
let
cfg = config.jhome;
devcfg = cfg.dev;
in {
in
{
imports =
[
nvim-config
@ -19,11 +22,11 @@ in {
]
++ lib.optionals (stylix != null) [
stylix.homeManagerModules.stylix
{stylix.image = cfg.sway.background;}
{ stylix.image = cfg.sway.background; }
];
config = lib.mkMerge [
(lib.mkIf (cfg.enable && cfg.styling.enable) {stylix.enable = true;})
(lib.mkIf (cfg.enable && cfg.styling.enable) { stylix.enable = true; })
(lib.mkIf cfg.enable {
programs = {
# Better cat (bat)
@ -81,10 +84,7 @@ in {
gpg-agent = {
enable = true;
maxCacheTtl = 86400;
pinentryPackage =
if config.jhome.gui.enable
then pkgs.pinentry-qt
else pkgs.pinentry-curses;
pinentryPackage = if config.jhome.gui.enable then pkgs.pinentry-qt else pkgs.pinentry-curses;
extraConfig = "allow-preset-passphrase";
};
# Spotifyd
@ -189,7 +189,7 @@ in {
};
})
(lib.mkIf (cfg.enable && devcfg.enable && devcfg.rust.enable) {
home.packages = [pkgs.rustup] ++ devcfg.rust.extraPackages;
home.packages = [ pkgs.rustup ] ++ devcfg.rust.extraPackages;
# Background code checker (for Rust)
programs.bacon = {
enable = true;

View file

@ -4,17 +4,12 @@
pkgs,
osConfig ? null,
...
}: let
}:
let
inherit (config) jhome;
flatpakEnabled =
if osConfig != null
then osConfig.services.flatpak.enable
else false;
flatpakEnabled = if osConfig != null then osConfig.services.flatpak.enable else false;
osSway = osConfig == null && !osConfig.programs.sway.enable;
swayPkg =
if osSway
then pkgs.sway
else null;
swayPkg = if osSway then pkgs.sway else null;
cfg = jhome.gui;
cursor = {
package = pkgs.nordzy-cursor-theme;
@ -24,9 +19,11 @@
name = "Papirus-Dark";
package = pkgs.papirus-icon-theme;
};
in {
in
{
config = lib.mkIf (jhome.enable && cfg.enable) {
home.packages = with pkgs;
home.packages =
with pkgs;
[
webcord
ferdium
@ -36,16 +33,25 @@ in {
wl-clipboard
# Extra fonts
noto-fonts-cjk # Chinese, Japanese and Korean characters
(pkgs.nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];})
(pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
]
++ lib.optional flatpakEnabled flatpak;
fonts.fontconfig = {
enable = true;
defaultFonts = lib.mkIf config.jhome.styling.enable {
emoji = ["Noto Color Emoji"];
monospace = ["JetBrains Mono" "Symbols Nerd Font"];
serif = ["Noto Serif" "Symbols Nerd Font"];
sansSerif = ["Noto Sans" "Symbols Nerd Font"];
emoji = [ "Noto Color Emoji" ];
monospace = [
"JetBrains Mono"
"Symbols Nerd Font"
];
serif = [
"Noto Serif"
"Symbols Nerd Font"
];
sansSerif = [
"Noto Sans"
"Symbols Nerd Font"
];
};
};
# Browser
@ -63,13 +69,15 @@ in {
# Video player
mpv = {
enable = true;
scripts = builtins.attrValues {inherit (pkgs.mpvScripts) uosc thumbfast;};
scripts = builtins.attrValues { inherit (pkgs.mpvScripts) uosc thumbfast; };
};
# Status bar
waybar = {
enable = true;
systemd.enable = true;
settings = lib.mkIf config.jhome.styling.enable (import ./waybar-settings.nix {inherit config lib;});
settings = lib.mkIf config.jhome.styling.enable (
import ./waybar-settings.nix { inherit config lib; }
);
style = lib.optionalString config.jhome.styling.enable ''
.modules-left #workspaces button {
border-bottom: 3px solid @base01;
@ -130,15 +138,17 @@ in {
wayland.windowManager.sway = {
inherit (cfg.sway) enable;
package = swayPkg; # no sway package if it comes from the OS
config = import ./sway-config.nix {inherit config pkgs;};
config = import ./sway-config.nix { inherit config pkgs; };
};
# Set cursor style
stylix = lib.mkIf config.jhome.styling.enable {inherit cursor;};
home.pointerCursor = lib.mkIf config.jhome.styling.enable (lib.mkDefault {
gtk.enable = true;
inherit (cursor) name package;
});
stylix = lib.mkIf config.jhome.styling.enable { inherit cursor; };
home.pointerCursor = lib.mkIf config.jhome.styling.enable (
lib.mkDefault {
gtk.enable = true;
inherit (cursor) name package;
}
);
# Set Gtk theme
gtk = lib.mkIf config.jhome.styling.enable {
enable = true;

View file

@ -1,7 +1,5 @@
{
pkgs,
config,
}: let
{ pkgs, config }:
let
cfg = config.jhome.gui.sway;
passmenu = "${pkgs.jpassmenu}/bin/jpassmenu";
selectAudio = "${pkgs.audiomenu}/bin/audiomenu --menu 'fuzzel --dmenu'";
@ -20,21 +18,21 @@
];
dirs =
map
(dir: {
key = swayconf.${dir};
arrow = dir;
direction = dir;
})
[
"up"
"down"
"left"
"right"
];
(dir: {
key = swayconf.${dir};
arrow = dir;
direction = dir;
})
[
"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];
keycombo = prefix: key: joinKeys (prefix ++ [ key ]);
modKeybind = keycombo [ mod ];
modCtrlKeybind = keycombo [
mod
"Ctrl"
@ -53,10 +51,13 @@
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:
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);
# Move window
moveWindowKeybinds = map (genArrowAndKey modShiftKeybind (dir: "move ${dir}")) dirs;
@ -65,25 +66,19 @@
# 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)
builtins.foldl' (l: r: l // r)
{
"${mod}+Return" = "exec ${swayconf.terminal}";
"${mod}+D" = "exec ${swayconf.menu}";

View file

@ -1,16 +1,15 @@
{
config,
pkgs,
}: let
{ config, pkgs }:
let
cfg = config.jhome.gui.sway;
modifier = "Mod4";
inherit (config.jhome.gui) terminal;
termCmd =
if terminal == "wezterm"
then "wezterm start"
else if terminal == "alacritty"
then "alacritty -e"
else builtins.abort "no command configured for ${terminal}";
if terminal == "wezterm" then
"wezterm start"
else if terminal == "alacritty" then
"alacritty -e"
else
builtins.abort "no command configured for ${terminal}";
menu = "${pkgs.fuzzel}/bin/fuzzel --terminal '${termCmd}'";
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
@ -18,10 +17,11 @@
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in
configure-gtk =
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
@ -38,16 +38,17 @@
${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;};
cmdOnce = command: { inherit command; };
cmdAlways = command: {
inherit command;
always = true;
};
in {
in
{
inherit modifier terminal menu;
keybindings = import ./keybindings.nix {inherit config pkgs;};
keybindings = import ./keybindings.nix { inherit config pkgs; };
# Appearance
bars = []; # Waybar is started as a systemd service
bars = [ ]; # Waybar is started as a systemd service
gaps = {
smartGaps = true;
smartBorders = "on";
@ -72,12 +73,9 @@ in {
}
];
# 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,38 +1,34 @@
{
config,
lib,
}: let
{ config, lib }:
let
cfg = config.jhome.gui;
in {
in
{
mainBar = {
layer = "top";
position = "top";
margin = "2 2 2 2";
# Choose the order of the modules
modules-left = ["sway/workspaces"];
modules-center = ["clock"];
modules-right =
[
"pulseaudio"
"backlight"
"battery"
"sway/language"
"memory"
]
++ lib.optional (cfg.tempInfo != null) "temperature"
++ ["tray"];
modules-left = [ "sway/workspaces" ];
modules-center = [ "clock" ];
modules-right = [
"pulseaudio"
"backlight"
"battery"
"sway/language"
"memory"
] ++ lib.optional (cfg.tempInfo != null) "temperature" ++ [ "tray" ];
"sway/workspaces" = {
disable-scroll = true;
persistent-workspaces = {
"1" = [];
"2" = [];
"3" = [];
"4" = [];
"5" = [];
"6" = [];
"7" = [];
"8" = [];
"9" = [];
"1" = [ ];
"2" = [ ];
"3" = [ ];
"4" = [ ];
"5" = [ ];
"6" = [ ];
"7" = [ ];
"8" = [ ];
"9" = [ ];
};
};
"sway/language" = {
@ -64,7 +60,11 @@ in {
phone = "󰘂";
portable = "";
car = "";
default = ["󰕿" "󰖀" "󰕾"];
default = [
"󰕿"
"󰖀"
"󰕾"
];
};
on-click = "pavucontrol";
min-length = 13;
@ -73,13 +73,27 @@ in {
inherit (cfg.tempInfo) hwmon-path;
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = ["" "" "" "" ""];
format-icons = [
""
""
""
""
""
];
tooltip = false;
};
backlight = {
device = "intel_backlight";
format = "{percent}% {icon}";
format-icons = ["󰃚" "󰃛" "󰃜" "󰃝" "󰃞" "󰃟" "󰃠"];
format-icons = [
"󰃚"
"󰃛"
"󰃜"
"󰃝"
"󰃞"
"󰃟"
"󰃠"
];
min-length = 7;
};
battery = {
@ -89,7 +103,18 @@ in {
format-charging = "{capacity}% 󰂄";
format-plugged = "{capacity}% 󰚥";
format-alt = "{time} {icon}";
format-icons = ["󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"];
format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
};
tray = {
icon-size = 16;

View file

@ -1,36 +1,30 @@
{
lib,
pkgs,
...
} @ attrs: let
{ lib, pkgs, ... }@attrs:
let
osConfig = attrs.osConfig or null;
inherit (lib) types;
fromOs = let
get = path: set:
if path == []
then set
else get (builtins.tail path) (builtins.getAttr (builtins.head path) set);
in
path: default:
if osConfig == null
then default
else get path osConfig;
fromConfig = path: default: fromOs (["jconfig"] ++ path) default;
fromOs =
let
get =
path: set:
if path == [ ] then set else get (builtins.tail path) (builtins.getAttr (builtins.head path) set);
in
path: default: if osConfig == null then default else get path osConfig;
fromConfig = path: default: fromOs ([ "jconfig" ] ++ path) default;
mkExtraPackagesOption = name: defaultPkgsPath: let
text =
lib.strings.concatMapStringsSep " " (
mkExtraPackagesOption =
name: defaultPkgsPath:
let
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
) defaultPkgsPath;
defaultText = lib.literalExpression "[ ${text} ]";
default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath;
in
lib.mkOption {
description = "Extra ${name} Packages.";
type = types.listOf types.package;
inherit default defaultText;
example = [];
example = [ ];
};
identity.options = {
@ -62,12 +56,12 @@
enable = lib.mkEnableOption "Jalil's default user configuration";
gpg = lib.mkOption {
description = "GnuPG Configuration.";
default = {};
default = { };
type = types.submodule {
options.unlockKeys = lib.mkOption {
description = "Keygrips of keys to unlock through `pam-gnupg` when logging in.";
default = [];
example = ["6F4ABB77A88E922406BCE6627AFEEE2363914B76"];
default = [ ];
example = [ "6F4ABB77A88E922406BCE6627AFEEE2363914B76" ];
type = types.listOf types.str;
};
};
@ -85,14 +79,27 @@
};
sway.options = {
enable = lib.mkEnableOption "sway" // {default = fromConfig ["gui" "sway"] true;};
enable = lib.mkEnableOption "sway" // {
default = fromConfig [
"gui"
"sway"
] true;
};
background = lib.mkOption {
description = "The wallpaper to use.";
type = types.path;
default = fromConfig ["styling" "wallpaper"] (builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
});
default =
fromConfig
[
"styling"
"wallpaper"
]
(
builtins.fetchurl {
url = "https://raw.githubusercontent.com/lunik1/nixos-logo-gruvbox-wallpaper/d4937c424fad79c1136a904599ba689fcf8d0fad/png/gruvbox-dark-rainbow.png";
sha256 = "036gqhbf6s5ddgvfbgn6iqbzgizssyf7820m5815b2gd748jw8zc";
}
);
};
autostart = lib.mkOption {
description = ''
@ -109,20 +116,20 @@
};
exec = lib.mkOption {
description = "Run commands when starting sway.";
default = {};
default = { };
type = types.submodule {
options = {
once = lib.mkOption {
description = "Programs to start only once (`exec`).";
type = types.listOf types.str;
default = [];
example = ["signal-desktop --start-in-tray"];
default = [ ];
example = [ "signal-desktop --start-in-tray" ];
};
always = lib.mkOption {
description = "Programs to start whenever the config is sourced (`exec_always`).";
type = types.listOf types.str;
default = [];
example = ["signal-desktop --start-in-tray"];
default = [ ];
example = [ "signal-desktop --start-in-tray" ];
};
};
};
@ -130,7 +137,12 @@
};
gui.options = {
enable = lib.mkEnableOption "GUI applications" // {default = fromConfig ["gui" "enable"] false;};
enable = lib.mkEnableOption "GUI applications" // {
default = fromConfig [
"gui"
"enable"
] false;
};
tempInfo = lib.mkOption {
description = "Temperature info to display in the statusbar.";
default = null;
@ -138,7 +150,7 @@
};
sway = lib.mkOption {
description = "Sway window manager configuration.";
default = {};
default = { };
type = types.submodule sway;
};
terminal = lib.mkOption {
@ -151,48 +163,57 @@
];
};
};
in {
in
{
options.jhome = lib.mkOption {
description = "Jalil's default home-manager configuration.";
default = {};
default = { };
type = types.submodule {
options = {
enable = lib.mkEnableOption "jalil's home defaults";
hostName = lib.mkOption {
description = "The hostname of this system.";
type = types.str;
default = fromOs ["networking" "hostName"] "nixos";
default = fromOs [
"networking"
"hostName"
] "nixos";
example = "my pc";
};
dev = lib.mkOption {
description = "Setup development environment for programming languages.";
default = {};
default = { };
type = types.submodule {
options = {
enable = lib.mkEnableOption "development settings" // {default = fromConfig ["dev" "enable"] false;};
enable = lib.mkEnableOption "development settings" // {
default = fromConfig [
"dev"
"enable"
] false;
};
neovimAsManPager = lib.mkEnableOption "neovim as the man pager";
extraPackages = mkExtraPackagesOption "dev" [
["jq"] # json parser
["just"] # just a command runner
["typos"] # low false positive rate typo checker
["gcc"] # GNU Compiler Collection
["git-absorb"] # fixup! but automatic
["man-pages"] # gimme the man pages
["man-pages-posix"] # I said gimme the man pages!!!
[ "jq" ] # json parser
[ "just" ] # just a command runner
[ "typos" ] # low false positive rate typo checker
[ "gcc" ] # GNU Compiler Collection
[ "git-absorb" ] # fixup! but automatic
[ "man-pages" ] # gimme the man pages
[ "man-pages-posix" ] # I said gimme the man pages!!!
];
rust = lib.mkOption {
description = "Jalil's default rust configuration.";
default = {};
default = { };
type = types.submodule {
options.enable = lib.mkEnableOption "rust development settings";
options.extraPackages = mkExtraPackagesOption "Rust" [
["cargo-insta"] # snapshot testing
["cargo-llvm-cov"] # code coverage
["cargo-msrv"] # minimum supported version
["cargo-nextest"] # better testing harness
["cargo-sort"] # sort deps and imports
["cargo-udeps"] # check for unused dependencies (requires nightly)
["cargo-watch"] # watch for file changes and run commands
[ "cargo-insta" ] # snapshot testing
[ "cargo-llvm-cov" ] # code coverage
[ "cargo-msrv" ] # minimum supported version
[ "cargo-nextest" ] # better testing harness
[ "cargo-sort" ] # sort deps and imports
[ "cargo-udeps" ] # check for unused dependencies (requires nightly)
[ "cargo-watch" ] # watch for file changes and run commands
];
};
};
@ -206,15 +227,20 @@ in {
};
gui = lib.mkOption {
description = "Jalil's default GUI configuration.";
default = {};
default = { };
type = types.submodule gui;
};
styling = lib.mkOption {
description = "My custom styling (uses stylix)";
default = {};
default = { };
type = types.submodule {
options = {
enable = lib.mkEnableOption "styling" // {default = fromConfig ["styling" "enable"] true;};
enable = lib.mkEnableOption "styling" // {
default = fromConfig [
"styling"
"enable"
] true;
};
};
};
};

View file

@ -1,8 +1,5 @@
{
config,
lib,
...
}: let
{ config, lib, ... }:
let
inherit (config) jhome;
inherit (cfg.defaultIdentity) signingKey;
@ -10,8 +7,9 @@
hasConfig = jhome.enable && cfg != null;
hasKey = signingKey != null;
gpgHome = config.programs.gpg.homedir;
unlockKey = hasConfig && cfg.gpg.unlockKeys != [];
in {
unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
in
{
config = lib.mkMerge [
(lib.mkIf hasConfig {
programs.git = {
@ -23,7 +21,7 @@ in {
};
};
programs.jujutsu.settings = {
user = lib.mkIf (cfg.defaultIdentity != null) {inherit (cfg.defaultIdentity) name email;};
user = lib.mkIf (cfg.defaultIdentity != null) { inherit (cfg.defaultIdentity) name email; };
signing = lib.mkIf hasKey {
sign-all = true;
backend = "gpg";