flake

Francesco Saccone's Nix flake.
git clone https://git.francescosaccone.com/flake
Log | Files | Refs | README | LICENSE

commit 0e98787df9279ecb58a762d16f41511a500170c6
parent 8fae0ac6047948fe7e7bdd7989ec53c8ccff7fb6
Author: Francesco Saccone <francesco@francescosaccone.com>
Date:   Sat, 17 May 2025 18:46:23 +0200

refactor: move and prefix home modules to fs.programs attrset

In the same way it happened to nixos modules.

Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>

Diffstat:
Mhosts/laptop/home/default.nix | 2+-
Dmodules/home-manager/aerc/default.nix | 127-------------------------------------------------------------------------------
Mmodules/home-manager/default.nix | 10+---------
Dmodules/home-manager/git/default.nix | 43-------------------------------------------
Dmodules/home-manager/gpg/default.nix | 50--------------------------------------------------
Dmodules/home-manager/newsraft/default.nix | 67-------------------------------------------------------------------
Dmodules/home-manager/pass/default.nix | 47-----------------------------------------------
Amodules/home-manager/programs/aerc/default.nix | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Cmodules/home-manager/default.nix -> modules/home-manager/programs/default.nix | 0
Amodules/home-manager/programs/git/default.nix | 43+++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/gpg/default.nix | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/newsraft/default.nix | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/pass/default.nix | 47+++++++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/sway/bar/default.nix | 136+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/sway/default.nix | 287+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/home-manager/programs/vis/default.nix | 27+++++++++++++++++++++++++++
Rmodules/home-manager/vis/visrc.lua -> modules/home-manager/programs/vis/visrc.lua | 0
Dmodules/home-manager/sway/bar/default.nix | 136-------------------------------------------------------------------------------
Dmodules/home-manager/sway/default.nix | 287-------------------------------------------------------------------------------
Dmodules/home-manager/vis/default.nix | 27---------------------------
20 files changed, 786 insertions(+), 794 deletions(-)

diff --git a/hosts/laptop/home/default.nix b/hosts/laptop/home/default.nix @@ -5,7 +5,7 @@ ... }: { - modules = rec { + fs.programs = rec { aerc = { enable = true; email = { diff --git a/modules/home-manager/aerc/default.nix b/modules/home-manager/aerc/default.nix @@ -1,127 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.aerc = { - enable = lib.mkOption { - description = "Whether to enable aerc."; - default = false; - type = lib.types.bool; - }; - email = { - address = lib.mkOption { - description = "The email address."; - type = lib.types.uniq lib.types.str; - }; - folders = { - drafts = lib.mkOption { - description = "The drafts folder."; - type = lib.types.uniq lib.types.str; - }; - inbox = lib.mkOption { - description = "The inbox folder."; - type = lib.types.uniq lib.types.str; - }; - sent = lib.mkOption { - description = "The sent folder."; - type = lib.types.uniq lib.types.str; - }; - trash = lib.mkOption { - description = "The spam folder."; - type = lib.types.uniq lib.types.str; - }; - }; - imapHost = lib.mkOption { - description = "The IMAP server name."; - type = lib.types.uniq lib.types.str; - }; - imapTlsPort = lib.mkOption { - description = "The IMAP port. If null then the default port is used."; - type = lib.types.nullOr lib.types.int; - }; - passwordCommand = lib.mkOption { - description = '' - The command which returns the password to login to the email - account. - ''; - type = lib.types.uniq lib.types.str; - }; - realName = lib.mkOption { - description = "The name used as recipient."; - type = lib.types.uniq lib.types.str; - }; - smtpHost = lib.mkOption { - description = "The SMTP server name."; - type = lib.types.uniq lib.types.str; - }; - smtpTlsPort = lib.mkOption { - description = "The SMTP port. If null then the default port is used."; - type = lib.types.nullOr lib.types.int; - }; - username = lib.mkOption { - description = "The username used to login to the email account."; - type = lib.types.uniq lib.types.str; - }; - }; - }; - - config = lib.mkIf config.modules.aerc.enable { - programs.aerc = { - enable = true; - package = pkgs.aerc; - - extraConfig = { - general = { - unsafe-accounts-conf = true; - }; - viewer.pager = "${pkgs.less}/bin/less --clear-screen"; - compose.editor = "${pkgs.nano}/bin/nano"; - filters = { - "text/plain" = "${pkgs.ccze}/bin/ccze --mode=ansi --raw-ansi"; - "text/html" = "${pkgs.pandoc}/bin/pandoc -f html -t plain"; - }; - }; - }; - - accounts.email = { - accounts.${config.modules.aerc.email.address} = { - aerc.enable = true; - - inherit (config.modules.aerc.email) - address - folders - passwordCommand - realName - ; - - flavor = "plain"; - gpg = lib.mkIf config.modules.gpg.enable { - key = config.modules.gpg.primaryKey.fingerprint; - signByDefault = true; - }; - imap = { - host = config.modules.aerc.email.imapHost; - port = config.modules.aerc.email.imapTlsPort; - tls = { - enable = true; - useStartTls = false; - }; - }; - primary = true; - smtp = { - host = config.modules.aerc.email.smtpHost; - port = config.modules.aerc.email.smtpTlsPort; - tls = { - enable = true; - useStartTls = false; - }; - }; - userName = config.modules.aerc.email.username; - }; - }; - }; -} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix @@ -1,12 +1,4 @@ { ... }: { - imports = [ - ./aerc - ./git - ./gpg - ./newsraft - ./pass - ./sway - ./vis - ]; + imports = [ ./programs ]; } diff --git a/modules/home-manager/git/default.nix b/modules/home-manager/git/default.nix @@ -1,43 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.git = { - enable = lib.mkOption { - description = "Whether to enable Git."; - default = false; - type = lib.types.bool; - }; - name = lib.mkOption { - description = "The name used in commits."; - type = lib.types.uniq lib.types.str; - }; - email = lib.mkOption { - description = "The email used in commits."; - type = lib.types.uniq lib.types.str; - }; - }; - - config = lib.mkIf config.modules.git.enable { - programs.git = { - enable = true; - package = pkgs.git; - - userName = config.modules.git.name; - userEmail = config.modules.git.email; - signing = lib.mkIf config.modules.gpg.enable { - key = config.modules.gpg.primaryKey.fingerprint; - signByDefault = true; - }; - - extraConfig = { - init.defaultBranch = "master"; - pull.rebase = false; - }; - }; - }; -} diff --git a/modules/home-manager/gpg/default.nix b/modules/home-manager/gpg/default.nix @@ -1,50 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.gpg = { - enable = lib.mkOption { - description = "Whether to enable GnuPG."; - default = false; - type = lib.types.bool; - }; - primaryKey = { - fingerprint = lib.mkOption { - description = "The fingerprint of the primary key."; - type = lib.types.uniq lib.types.str; - }; - file = lib.mkOption { - description = "The path to the primary key file."; - type = lib.types.uniq lib.types.path; - }; - }; - }; - - config = lib.mkIf config.modules.gpg.enable { - programs.gpg = { - enable = true; - package = pkgs.gnupg; - - mutableKeys = false; - mutableTrust = false; - - publicKeys = [ - { - source = config.modules.gpg.primaryKey.file; - trust = "ultimate"; - } - ]; - }; - - services.gpg-agent = { - enable = true; - pinentryPackage = pkgs.pinentry-tty; - }; - - home.file.".mkshrc".text = "export GPG_TTY=$(${pkgs.sbase}/bin/tty)"; - }; -} diff --git a/modules/home-manager/newsraft/default.nix b/modules/home-manager/newsraft/default.nix @@ -1,67 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.newsraft = { - enable = lib.mkOption { - description = "Whether to enable Newsraft."; - default = false; - type = lib.types.bool; - }; - feeds = lib.mkOption { - description = "For each section name, its list of feeds."; - default = { }; - type = - lib.types.submodule { - options = { - name = lib.mkOption { - description = "The name of the feed."; - type = lib.types.uniq lib.types.str; - }; - url = lib.mkOption { - description = "The URL of the feed."; - type = lib.types.uniq lib.types.str; - }; - }; - } - |> lib.types.listOf - |> lib.types.attrsOf; - }; - }; - - config = lib.mkIf config.modules.newsraft.enable { - home = { - packages = [ pkgs.newsraft ]; - file = { - ".config/newsraft/config".text = '' - # Empty configuration as of now. - ''; - ".config/newsraft/feeds".text = - config.modules.newsraft.feeds - |> builtins.mapAttrs ( - section: feeds: '' - @ ${section} - ${ - ( - feeds - |> builtins.map ( - { name, url }: - '' - ${url} "${name}" - '' - ) - |> builtins.concatStringsSep "\n" - ) - } - '' - ) - |> builtins.attrValues - |> builtins.concatStringsSep "\n"; - }; - }; - }; -} diff --git a/modules/home-manager/pass/default.nix b/modules/home-manager/pass/default.nix @@ -1,47 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.pass = { - enable = lib.mkOption { - description = "Whether to enable Password Store."; - default = false; - type = lib.types.bool; - }; - directory = lib.mkOption { - description = "The directory containing the encrypted passwords."; - default = "${config.home.homeDirectory}/.password-store"; - readOnly = true; - type = lib.types.uniq lib.types.path; - }; - passwordStoreDirectory = lib.mkOption { - description = '' - The directory the password store directory will symlink to. - ''; - type = lib.types.uniq lib.types.path; - }; - }; - - config = lib.mkIf config.modules.pass.enable { - programs.password-store = { - enable = true; - package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); - settings = { - PASSWORD_STORE_DIR = config.modules.pass.directory; - PASSWORD_STORE_CLIP_TIME = "15"; - }; - }; - - home.file = { - ".password-store" = { - source = config.modules.pass.passwordStoreDirectory; - }; - }; - - home.packages = [ pkgs.wl-clipboard-rs ]; - }; -} diff --git a/modules/home-manager/programs/aerc/default.nix b/modules/home-manager/programs/aerc/default.nix @@ -0,0 +1,127 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.aerc = { + enable = lib.mkOption { + description = "Whether to enable aerc."; + default = false; + type = lib.types.bool; + }; + email = { + address = lib.mkOption { + description = "The email address."; + type = lib.types.uniq lib.types.str; + }; + folders = { + drafts = lib.mkOption { + description = "The drafts folder."; + type = lib.types.uniq lib.types.str; + }; + inbox = lib.mkOption { + description = "The inbox folder."; + type = lib.types.uniq lib.types.str; + }; + sent = lib.mkOption { + description = "The sent folder."; + type = lib.types.uniq lib.types.str; + }; + trash = lib.mkOption { + description = "The spam folder."; + type = lib.types.uniq lib.types.str; + }; + }; + imapHost = lib.mkOption { + description = "The IMAP server name."; + type = lib.types.uniq lib.types.str; + }; + imapTlsPort = lib.mkOption { + description = "The IMAP port. If null then the default port is used."; + type = lib.types.nullOr lib.types.int; + }; + passwordCommand = lib.mkOption { + description = '' + The command which returns the password to login to the email + account. + ''; + type = lib.types.uniq lib.types.str; + }; + realName = lib.mkOption { + description = "The name used as recipient."; + type = lib.types.uniq lib.types.str; + }; + smtpHost = lib.mkOption { + description = "The SMTP server name."; + type = lib.types.uniq lib.types.str; + }; + smtpTlsPort = lib.mkOption { + description = "The SMTP port. If null then the default port is used."; + type = lib.types.nullOr lib.types.int; + }; + username = lib.mkOption { + description = "The username used to login to the email account."; + type = lib.types.uniq lib.types.str; + }; + }; + }; + + config = lib.mkIf config.fs.programs.aerc.enable { + programs.aerc = { + enable = true; + package = pkgs.aerc; + + extraConfig = { + general = { + unsafe-accounts-conf = true; + }; + viewer.pager = "${pkgs.less}/bin/less --clear-screen"; + compose.editor = "${pkgs.nano}/bin/nano"; + filters = { + "text/plain" = "${pkgs.ccze}/bin/ccze --mode=ansi --raw-ansi"; + "text/html" = "${pkgs.pandoc}/bin/pandoc -f html -t plain"; + }; + }; + }; + + accounts.email = { + accounts.${config.fs.programs.aerc.email.address} = { + aerc.enable = true; + + inherit (config.fs.programs.aerc.email) + address + folders + passwordCommand + realName + ; + + flavor = "plain"; + gpg = lib.mkIf config.fs.programs.gpg.enable { + key = config.fs.programs.gpg.primaryKey.fingerprint; + signByDefault = true; + }; + imap = { + host = config.fs.programs.aerc.email.imapHost; + port = config.fs.programs.aerc.email.imapTlsPort; + tls = { + enable = true; + useStartTls = false; + }; + }; + primary = true; + smtp = { + host = config.fs.programs.aerc.email.smtpHost; + port = config.fs.programs.aerc.email.smtpTlsPort; + tls = { + enable = true; + useStartTls = false; + }; + }; + userName = config.fs.programs.aerc.email.username; + }; + }; + }; +} diff --git a/modules/home-manager/default.nix b/modules/home-manager/programs/default.nix diff --git a/modules/home-manager/programs/git/default.nix b/modules/home-manager/programs/git/default.nix @@ -0,0 +1,43 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.git = { + enable = lib.mkOption { + description = "Whether to enable Git."; + default = false; + type = lib.types.bool; + }; + name = lib.mkOption { + description = "The name used in commits."; + type = lib.types.uniq lib.types.str; + }; + email = lib.mkOption { + description = "The email used in commits."; + type = lib.types.uniq lib.types.str; + }; + }; + + config = lib.mkIf config.fs.programs.git.enable { + programs.git = { + enable = true; + package = pkgs.git; + + userName = config.fs.programs.git.name; + userEmail = config.fs.programs.git.email; + signing = lib.mkIf config.fs.programs.gpg.enable { + key = config.fs.programs.gpg.primaryKey.fingerprint; + signByDefault = true; + }; + + extraConfig = { + init.defaultBranch = "master"; + pull.rebase = false; + }; + }; + }; +} diff --git a/modules/home-manager/programs/gpg/default.nix b/modules/home-manager/programs/gpg/default.nix @@ -0,0 +1,50 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.gpg = { + enable = lib.mkOption { + description = "Whether to enable GnuPG."; + default = false; + type = lib.types.bool; + }; + primaryKey = { + fingerprint = lib.mkOption { + description = "The fingerprint of the primary key."; + type = lib.types.uniq lib.types.str; + }; + file = lib.mkOption { + description = "The path to the primary key file."; + type = lib.types.uniq lib.types.path; + }; + }; + }; + + config = lib.mkIf config.fs.programs.gpg.enable { + programs.gpg = { + enable = true; + package = pkgs.gnupg; + + mutableKeys = false; + mutableTrust = false; + + publicKeys = [ + { + source = config.fs.programs.gpg.primaryKey.file; + trust = "ultimate"; + } + ]; + }; + + services.gpg-agent = { + enable = true; + pinentryPackage = pkgs.pinentry-tty; + }; + + home.file.".mkshrc".text = "export GPG_TTY=$(${pkgs.sbase}/bin/tty)"; + }; +} diff --git a/modules/home-manager/programs/newsraft/default.nix b/modules/home-manager/programs/newsraft/default.nix @@ -0,0 +1,67 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.newsraft = { + enable = lib.mkOption { + description = "Whether to enable Newsraft."; + default = false; + type = lib.types.bool; + }; + feeds = lib.mkOption { + description = "For each section name, its list of feeds."; + default = { }; + type = + lib.types.submodule { + options = { + name = lib.mkOption { + description = "The name of the feed."; + type = lib.types.uniq lib.types.str; + }; + url = lib.mkOption { + description = "The URL of the feed."; + type = lib.types.uniq lib.types.str; + }; + }; + } + |> lib.types.listOf + |> lib.types.attrsOf; + }; + }; + + config = lib.mkIf config.fs.programs.newsraft.enable { + home = { + packages = [ pkgs.newsraft ]; + file = { + ".config/newsraft/config".text = '' + # Empty configuration as of now. + ''; + ".config/newsraft/feeds".text = + config.fs.programs.newsraft.feeds + |> builtins.mapAttrs ( + section: feeds: '' + @ ${section} + ${ + ( + feeds + |> builtins.map ( + { name, url }: + '' + ${url} "${name}" + '' + ) + |> builtins.concatStringsSep "\n" + ) + } + '' + ) + |> builtins.attrValues + |> builtins.concatStringsSep "\n"; + }; + }; + }; +} diff --git a/modules/home-manager/programs/pass/default.nix b/modules/home-manager/programs/pass/default.nix @@ -0,0 +1,47 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.pass = { + enable = lib.mkOption { + description = "Whether to enable Password Store."; + default = false; + type = lib.types.bool; + }; + directory = lib.mkOption { + description = "The directory containing the encrypted passwords."; + default = "${config.home.homeDirectory}/.password-store"; + readOnly = true; + type = lib.types.uniq lib.types.path; + }; + passwordStoreDirectory = lib.mkOption { + description = '' + The directory the password store directory will symlink to. + ''; + type = lib.types.uniq lib.types.path; + }; + }; + + config = lib.mkIf config.fs.programs.pass.enable { + programs.password-store = { + enable = true; + package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]); + settings = { + PASSWORD_STORE_DIR = config.fs.programs.pass.directory; + PASSWORD_STORE_CLIP_TIME = "15"; + }; + }; + + home.file = { + ".password-store" = { + source = config.fs.programs.pass.passwordStoreDirectory; + }; + }; + + home.packages = [ pkgs.wl-clipboard-rs ]; + }; +} diff --git a/modules/home-manager/programs/sway/bar/default.nix b/modules/home-manager/programs/sway/bar/default.nix @@ -0,0 +1,136 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + options.fs.programs.sway.bar = { + enable = lib.mkOption { + description = "Whether to enable Swaybar."; + default = false; + type = lib.types.bool; + }; + }; + + config = + let + inherit (config.fs.programs.sway) bar colors; + in + lib.mkIf (bar.enable && config.fs.programs.sway.enable) { + wayland.windowManager.sway.config.bars = [ + { + command = "${pkgs.sway}/bin/swaybar"; + + position = "top"; + + statusCommand = "${pkgs.i3status}/bin/i3status"; + mode = "dock"; + trayOutput = "none"; + workspaceButtons = true; + extraConfig = "separator_symbol \" \""; + + fonts = { + names = [ config.fs.programs.sway.fonts.monospace ]; + style = "Regular"; + size = 12.0; + }; + + colors = { + activeWorkspace = { + inherit (colors) background; + border = colors.foreground; + text = colors.foreground; + }; + inherit (colors) background; + focusedWorkspace = { + background = colors.foreground; + border = colors.foreground; + text = colors.background; + }; + inactiveWorkspace = { + inherit (colors) background; + border = colors.background; + text = colors.foreground; + }; + separator = colors.background; + statusline = colors.foreground; + urgentWorkspace = { + inherit (colors) background; + border = colors.red; + text = colors.foreground; + }; + }; + } + ]; + + programs.i3status = { + enable = true; + package = pkgs.i3status; + + enableDefault = false; + general = { + output_format = "i3bar"; + colors = true; + color_good = colors.green; + color_degraded = colors.red; + color_bad = colors.darkRed; + }; + modules = { + "wireless _first_" = { + enable = true; + position = 0; + settings = { + format_up = "📡 %essid"; + format_down = "📡 None"; + }; + }; + "battery all" = { + enable = true; + position = 1; + settings = { + format = "🔋 %percentage %status"; + format_down = "🔋 None"; + format_percentage = "%.01f%s"; + status_chr = "⚡"; + status_bat = ""; + status_unk = ""; + status_full = "✅"; + status_idle = ""; + low_threshold = 15; + threshold_type = "percentage"; + last_full_capacity = false; + path = "/sys/class/power_supply/BAT%d/uevent"; + }; + }; + "cpu_temperature 0" = { + enable = true; + position = 2; + settings = { + format = "🌡️ %degrees°C"; + max_threshold = 75; + }; + }; + "memory" = { + enable = true; + position = 3; + settings = { + format = "🧠 %percentage_used"; + threshold_degraded = "10%"; + threshold_critical = "5%"; + unit = "auto"; + decimals = 1; + }; + }; + "time" = { + enable = true; + position = 4; + settings = { + format = "%Y-%m-%d %H:%M:%S %Z "; + }; + }; + }; + }; + }; +} diff --git a/modules/home-manager/programs/sway/default.nix b/modules/home-manager/programs/sway/default.nix @@ -0,0 +1,287 @@ +{ + lib, + options, + config, + pkgs, + ... +}: +{ + imports = [ ./bar ]; + + options.fs.programs.sway = { + enable = lib.mkOption { + description = "Whether to enable the configuration for Sway."; + default = false; + type = lib.types.bool; + }; + fonts = { + monospace = lib.mkOption { + type = lib.types.uniq lib.types.str; + description = '' + The monospace font to be used in Sway and its components. + ''; + }; + }; + backgroundImage = lib.mkOption { + description = "The image used as background."; + type = lib.types.uniq lib.types.path; + }; + colors = lib.mkOption { + description = "The hex colors, in '#rrggbb[aa]' format."; + type = lib.types.submodule { + options = { + background = lib.mkOption { + description = '' + The background color: it should be continous with the background + image. + ''; + type = lib.types.uniq lib.types.str; + }; + foreground = lib.mkOption { + description = "The foreground color."; + type = lib.types.uniq lib.types.str; + }; + darkRed = lib.mkOption { + description = "The dark red color."; + type = lib.types.uniq lib.types.str; + }; + green = lib.mkOption { + description = "The green color."; + type = lib.types.uniq lib.types.str; + }; + red = lib.mkOption { + description = "The red color."; + type = lib.types.uniq lib.types.str; + }; + transparent = lib.mkOption { + description = "The transparent color."; + readOnly = true; + default = "#00000000"; + type = lib.types.uniq lib.types.str; + }; + }; + }; + }; + }; + + config = lib.mkIf config.fs.programs.sway.enable { + home = { + packages = [ + pkgs.swaybg + pkgs.wl-clipboard-rs + ]; + pointerCursor = { + gtk.enable = true; + name = "graphite-dark-nord"; + package = pkgs.graphite-cursors; + size = 20; + }; + }; + + wayland.windowManager.sway = + let + inherit (config.fs.programs.sway) backgroundImage colors; + commands = { + terminal = + let + # Remove the leading '#' character. + parseColor = builtins.substring 1 7; + + background = parseColor colors.background; + foreground = parseColor colors.foreground; + + configFile = pkgs.writeText "foot.ini" '' + [cursor] + color=${background} ${foreground} + style=beam + blink=yes + blink-rate=500 + beam-thickness=1.5 + + [colors] + alpha=0.8 + background=${background} + foreground=${foreground} + + [main] + font=${config.fs.programs.sway.fonts.monospace}:size=11 + title=Foot + locked-title=yes + ''; + in + "${pkgs.foot}/bin/foot -c ${configFile}"; + }; + in + { + enable = true; + package = pkgs.sway; + + xwayland = true; + config = { + fonts = { + names = [ config.fs.programs.sway.fonts.monospace ]; + style = "Regular"; + size = 12.0; + }; + + defaultWorkspace = "workspace number \"1\""; + + inherit (commands) terminal; + modifier = "Mod4"; + floating.modifier = "Mod4"; + + output."*".background = "${backgroundImage} fill"; + + colors = + let + default = { + background = colors.foreground; + border = colors.transparent; + text = colors.background; + }; + in + rec { + focused = { + background = colors.foreground; + border = colors.foreground; + text = colors.background; + }; + + focusedInactive = default; + unfocused = default; + urgent = { + inherit (default) background text; + border = colors.red; + }; + } + |> builtins.mapAttrs ( + name: + { + background, + border, + text, + }: + { + inherit background border text; + childBorder = border; + indicator = border; + } + ); + + gaps = { + inner = 14; + outer = 18; + }; + + window = { + titlebar = false; + }; + + input = { + "type:keyboard" = { + xkb_layout = "it"; + }; + "*" = { + tap = "enabled"; + dwt = "disabled"; + }; + }; + + modes.resize = { + "Up" = "resize grow height 7 px or 7 ppt"; + "Right" = "resize grow width 7 px or 7 ppt"; + "Left" = "resize shrink width 7 px or 7 ppt"; + "Down" = "resize shring height 7 px or 7 ppt"; + + "Mod4+r" = "mode \"default\""; + }; + + keybindings = { + "Mod4+Return" = "exec ${commands.terminal}"; + + "XF86AudioRaiseVolume" = '' + exec ${pkgs.alsa-utils}/bin/amixer set Master 10%+ + ''; + "XF86AudioLowerVolume" = '' + exec ${pkgs.alsa-utils}/bin/amixer set Master 10%- + ''; + "XF86AudioMute" = '' + exec ${pkgs.alsa-utils}/bin/amixer set Master toggle + ''; + "XF86AudioMicMute" = '' + exec ${pkgs.alsa-utils}/bin/amixer set Capture toggle + ''; + + "XF86MonBrightnessUp" = '' + exec ${pkgs.brightnessctl}/bin/brightnessctl set 10%+ + ''; + "XF86MonBrightnessDown" = '' + exec ${pkgs.brightnessctl}/bin/brightnessctl set 10%- + ''; + + "Mod4+q" = "kill"; + + "Mod4+Left" = "focus left"; + "Mod4+Down" = "focus down"; + "Mod4+Up" = "focus up"; + "Mod4+Right" = "focus right"; + + "Mod4+Shift+Left" = "move left"; + "Mod4+Shift+Down" = "move down"; + "Mod4+Shift+Up" = "move up"; + "Mod4+Shift+Right" = "move right"; + + "Mod4+f" = "fullscreen toggle"; + "Mod4+Shift+space" = "floating toggle"; + "Mod4+space" = "focus mode_toggle"; + + "Mod4+1" = "workspace number \"1\""; + "Mod4+2" = "workspace number \"2\""; + "Mod4+3" = "workspace number \"3\""; + "Mod4+4" = "workspace number \"4\""; + "Mod4+5" = "workspace number \"5\""; + "Mod4+6" = "workspace number \"6\""; + "Mod4+7" = "workspace number \"7\""; + "Mod4+8" = "workspace number \"8\""; + "Mod4+9" = "workspace number \"9\""; + "Mod4+0" = "workspace number \"10\""; + + "Mod4+Shift+1" = "move container to workspace number \"1\""; + "Mod4+Shift+2" = "move container to workspace number \"2\""; + "Mod4+Shift+3" = "move container to workspace number \"3\""; + "Mod4+Shift+4" = "move container to workspace number \"4\""; + "Mod4+Shift+5" = "move container to workspace number \"5\""; + "Mod4+Shift+6" = "move container to workspace number \"6\""; + "Mod4+Shift+7" = "move container to workspace number \"7\""; + "Mod4+Shift+8" = "move container to workspace number \"8\""; + "Mod4+Shift+9" = "move container to workspace number \"9\""; + "Mod4+Shift+0" = "move container to workspace number \"10\""; + + "Mod4+Shift+c" = "reload"; + "Mod4+Shift+r" = "restart"; + + "Mod4+r" = "mode \"resize\""; + }; + + startup = [ + { + command = "${pkgs.autotiling}/bin/autotiling"; + always = true; + } + { + command = "${pkgs.alsa-utils}/bin/amixer set Master 100%"; + always = false; + } + { + command = "${pkgs.alsa-utils}/bin/amixer set Capture 100%"; + always = false; + } + { + command = "${pkgs.brightnessctl}/bin/brightnessctl set 100%"; + always = false; + } + ]; + }; + }; + }; +} diff --git a/modules/home-manager/programs/vis/default.nix b/modules/home-manager/programs/vis/default.nix @@ -0,0 +1,27 @@ +{ + lib, + options, + config, + pkgs, + inputs, + ... +}: +{ + options.fs.programs.vis = { + enable = lib.mkOption { + description = "Whether to enable Vis."; + default = false; + type = lib.types.bool; + }; + }; + + config = lib.mkIf config.fs.programs.vis.enable { + home = { + packages = [ pkgs.vis ]; + file = { + ".mkshrc".text = "export EDITOR=${pkgs.vis}/bin/vis"; + ".config/vis/visrc.lua".source = ./visrc.lua; + }; + }; + }; +} diff --git a/modules/home-manager/vis/visrc.lua b/modules/home-manager/programs/vis/visrc.lua diff --git a/modules/home-manager/sway/bar/default.nix b/modules/home-manager/sway/bar/default.nix @@ -1,136 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - options.modules.sway.bar = { - enable = lib.mkOption { - description = "Whether to enable Swaybar."; - default = false; - type = lib.types.bool; - }; - }; - - config = - let - inherit (config.modules.sway) bar colors; - in - lib.mkIf (bar.enable && config.modules.sway.enable) { - wayland.windowManager.sway.config.bars = [ - { - command = "${pkgs.sway}/bin/swaybar"; - - position = "top"; - - statusCommand = "${pkgs.i3status}/bin/i3status"; - mode = "dock"; - trayOutput = "none"; - workspaceButtons = true; - extraConfig = "separator_symbol \" \""; - - fonts = { - names = [ config.modules.sway.fonts.monospace ]; - style = "Regular"; - size = 12.0; - }; - - colors = { - activeWorkspace = { - inherit (colors) background; - border = colors.foreground; - text = colors.foreground; - }; - inherit (colors) background; - focusedWorkspace = { - background = colors.foreground; - border = colors.foreground; - text = colors.background; - }; - inactiveWorkspace = { - inherit (colors) background; - border = colors.background; - text = colors.foreground; - }; - separator = colors.background; - statusline = colors.foreground; - urgentWorkspace = { - inherit (colors) background; - border = colors.red; - text = colors.foreground; - }; - }; - } - ]; - - programs.i3status = { - enable = true; - package = pkgs.i3status; - - enableDefault = false; - general = { - output_format = "i3bar"; - colors = true; - color_good = colors.green; - color_degraded = colors.red; - color_bad = colors.darkRed; - }; - modules = { - "wireless _first_" = { - enable = true; - position = 0; - settings = { - format_up = "📡 %essid"; - format_down = "📡 None"; - }; - }; - "battery all" = { - enable = true; - position = 1; - settings = { - format = "🔋 %percentage %status"; - format_down = "🔋 None"; - format_percentage = "%.01f%s"; - status_chr = "⚡"; - status_bat = ""; - status_unk = ""; - status_full = "✅"; - status_idle = ""; - low_threshold = 15; - threshold_type = "percentage"; - last_full_capacity = false; - path = "/sys/class/power_supply/BAT%d/uevent"; - }; - }; - "cpu_temperature 0" = { - enable = true; - position = 2; - settings = { - format = "🌡️ %degrees°C"; - max_threshold = 75; - }; - }; - "memory" = { - enable = true; - position = 3; - settings = { - format = "🧠 %percentage_used"; - threshold_degraded = "10%"; - threshold_critical = "5%"; - unit = "auto"; - decimals = 1; - }; - }; - "time" = { - enable = true; - position = 4; - settings = { - format = "%Y-%m-%d %H:%M:%S %Z "; - }; - }; - }; - }; - }; -} diff --git a/modules/home-manager/sway/default.nix b/modules/home-manager/sway/default.nix @@ -1,287 +0,0 @@ -{ - lib, - options, - config, - pkgs, - ... -}: -{ - imports = [ ./bar ]; - - options.modules.sway = { - enable = lib.mkOption { - description = "Whether to enable the configuration for Sway."; - default = false; - type = lib.types.bool; - }; - fonts = { - monospace = lib.mkOption { - type = lib.types.uniq lib.types.str; - description = '' - The monospace font to be used in Sway and its components. - ''; - }; - }; - backgroundImage = lib.mkOption { - description = "The image used as background."; - type = lib.types.uniq lib.types.path; - }; - colors = lib.mkOption { - description = "The hex colors, in '#rrggbb[aa]' format."; - type = lib.types.submodule { - options = { - background = lib.mkOption { - description = '' - The background color: it should be continous with the background - image. - ''; - type = lib.types.uniq lib.types.str; - }; - foreground = lib.mkOption { - description = "The foreground color."; - type = lib.types.uniq lib.types.str; - }; - darkRed = lib.mkOption { - description = "The dark red color."; - type = lib.types.uniq lib.types.str; - }; - green = lib.mkOption { - description = "The green color."; - type = lib.types.uniq lib.types.str; - }; - red = lib.mkOption { - description = "The red color."; - type = lib.types.uniq lib.types.str; - }; - transparent = lib.mkOption { - description = "The transparent color."; - readOnly = true; - default = "#00000000"; - type = lib.types.uniq lib.types.str; - }; - }; - }; - }; - }; - - config = lib.mkIf config.modules.sway.enable { - home = { - packages = [ - pkgs.swaybg - pkgs.wl-clipboard-rs - ]; - pointerCursor = { - gtk.enable = true; - name = "graphite-dark-nord"; - package = pkgs.graphite-cursors; - size = 20; - }; - }; - - wayland.windowManager.sway = - let - inherit (config.modules.sway) backgroundImage colors; - commands = { - terminal = - let - # Remove the leading '#' character. - parseColor = builtins.substring 1 7; - - background = parseColor colors.background; - foreground = parseColor colors.foreground; - - configFile = pkgs.writeText "foot.ini" '' - [cursor] - color=${background} ${foreground} - style=beam - blink=yes - blink-rate=500 - beam-thickness=1.5 - - [colors] - alpha=0.8 - background=${background} - foreground=${foreground} - - [main] - font=${config.modules.sway.fonts.monospace}:size=11 - title=Foot - locked-title=yes - ''; - in - "${pkgs.foot}/bin/foot -c ${configFile}"; - }; - in - { - enable = true; - package = pkgs.sway; - - xwayland = true; - config = { - fonts = { - names = [ config.modules.sway.fonts.monospace ]; - style = "Regular"; - size = 12.0; - }; - - defaultWorkspace = "workspace number \"1\""; - - inherit (commands) terminal; - modifier = "Mod4"; - floating.modifier = "Mod4"; - - output."*".background = "${backgroundImage} fill"; - - colors = - let - default = { - background = colors.foreground; - border = colors.transparent; - text = colors.background; - }; - in - rec { - focused = { - background = colors.foreground; - border = colors.foreground; - text = colors.background; - }; - - focusedInactive = default; - unfocused = default; - urgent = { - inherit (default) background text; - border = colors.red; - }; - } - |> builtins.mapAttrs ( - name: - { - background, - border, - text, - }: - { - inherit background border text; - childBorder = border; - indicator = border; - } - ); - - gaps = { - inner = 14; - outer = 18; - }; - - window = { - titlebar = false; - }; - - input = { - "type:keyboard" = { - xkb_layout = "it"; - }; - "*" = { - tap = "enabled"; - dwt = "disabled"; - }; - }; - - modes.resize = { - "Up" = "resize grow height 7 px or 7 ppt"; - "Right" = "resize grow width 7 px or 7 ppt"; - "Left" = "resize shrink width 7 px or 7 ppt"; - "Down" = "resize shring height 7 px or 7 ppt"; - - "Mod4+r" = "mode \"default\""; - }; - - keybindings = { - "Mod4+Return" = "exec ${commands.terminal}"; - - "XF86AudioRaiseVolume" = '' - exec ${pkgs.alsa-utils}/bin/amixer set Master 10%+ - ''; - "XF86AudioLowerVolume" = '' - exec ${pkgs.alsa-utils}/bin/amixer set Master 10%- - ''; - "XF86AudioMute" = '' - exec ${pkgs.alsa-utils}/bin/amixer set Master toggle - ''; - "XF86AudioMicMute" = '' - exec ${pkgs.alsa-utils}/bin/amixer set Capture toggle - ''; - - "XF86MonBrightnessUp" = '' - exec ${pkgs.brightnessctl}/bin/brightnessctl set 10%+ - ''; - "XF86MonBrightnessDown" = '' - exec ${pkgs.brightnessctl}/bin/brightnessctl set 10%- - ''; - - "Mod4+q" = "kill"; - - "Mod4+Left" = "focus left"; - "Mod4+Down" = "focus down"; - "Mod4+Up" = "focus up"; - "Mod4+Right" = "focus right"; - - "Mod4+Shift+Left" = "move left"; - "Mod4+Shift+Down" = "move down"; - "Mod4+Shift+Up" = "move up"; - "Mod4+Shift+Right" = "move right"; - - "Mod4+f" = "fullscreen toggle"; - "Mod4+Shift+space" = "floating toggle"; - "Mod4+space" = "focus mode_toggle"; - - "Mod4+1" = "workspace number \"1\""; - "Mod4+2" = "workspace number \"2\""; - "Mod4+3" = "workspace number \"3\""; - "Mod4+4" = "workspace number \"4\""; - "Mod4+5" = "workspace number \"5\""; - "Mod4+6" = "workspace number \"6\""; - "Mod4+7" = "workspace number \"7\""; - "Mod4+8" = "workspace number \"8\""; - "Mod4+9" = "workspace number \"9\""; - "Mod4+0" = "workspace number \"10\""; - - "Mod4+Shift+1" = "move container to workspace number \"1\""; - "Mod4+Shift+2" = "move container to workspace number \"2\""; - "Mod4+Shift+3" = "move container to workspace number \"3\""; - "Mod4+Shift+4" = "move container to workspace number \"4\""; - "Mod4+Shift+5" = "move container to workspace number \"5\""; - "Mod4+Shift+6" = "move container to workspace number \"6\""; - "Mod4+Shift+7" = "move container to workspace number \"7\""; - "Mod4+Shift+8" = "move container to workspace number \"8\""; - "Mod4+Shift+9" = "move container to workspace number \"9\""; - "Mod4+Shift+0" = "move container to workspace number \"10\""; - - "Mod4+Shift+c" = "reload"; - "Mod4+Shift+r" = "restart"; - - "Mod4+r" = "mode \"resize\""; - }; - - startup = [ - { - command = "${pkgs.autotiling}/bin/autotiling"; - always = true; - } - { - command = "${pkgs.alsa-utils}/bin/amixer set Master 100%"; - always = false; - } - { - command = "${pkgs.alsa-utils}/bin/amixer set Capture 100%"; - always = false; - } - { - command = "${pkgs.brightnessctl}/bin/brightnessctl set 100%"; - always = false; - } - ]; - }; - }; - }; -} diff --git a/modules/home-manager/vis/default.nix b/modules/home-manager/vis/default.nix @@ -1,27 +0,0 @@ -{ - lib, - options, - config, - pkgs, - inputs, - ... -}: -{ - options.modules.vis = { - enable = lib.mkOption { - description = "Whether to enable Vis."; - default = false; - type = lib.types.bool; - }; - }; - - config = lib.mkIf config.modules.vis.enable { - home = { - packages = [ pkgs.vis ]; - file = { - ".mkshrc".text = "export EDITOR=${pkgs.vis}/bin/vis"; - ".config/vis/visrc.lua".source = ./visrc.lua; - }; - }; - }; -}