diff --git a/machines/default.nix b/machines/default.nix index 5185232..b5e95fd 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -1,4 +1,4 @@ -{ dedsec-grub-theme, ... } @ inputs: +{ ... } @ inputs: let hardware = inputs.hardware.nixosModules; @@ -8,7 +8,6 @@ in system = "x86_64-linux"; extraModules = [ - dedsec-grub-theme.nixosModule ../modules/garbage-collector.nix ../users/jan ]; diff --git a/users/jan/default.nix b/users/jan/default.nix index 00dd262..e06f4f3 100644 --- a/users/jan/default.nix +++ b/users/jan/default.nix @@ -31,7 +31,7 @@ ./home.nix ]; - progs.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize; + local.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize; home.stateVersion = config.system.stateVersion; }; diff --git a/users/jan/home.nix b/users/jan/home.nix index cfdca59..81bb7db 100644 --- a/users/jan/home.nix +++ b/users/jan/home.nix @@ -1,10 +1,26 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: let secrets = import ./secrets.nix; in { - imports = (import ./ui) ++ (import ./shell) ++ (import ./progs); + imports = [ + ../modules/window_manager + ../modules/terminal.nix + ../modules/shell.nix + + ../modules/notifications + ../modules/file_manager + ../modules/mail + ../modules/ledger.nix + ../modules/pass.nix + + ../modules/git.nix + ../modules/dev_tools.nix + ../modules/editor.nix + ]; + + xdg.enable = true; home.keyboard = { model = "pc105"; @@ -16,24 +32,12 @@ in home.packages = with pkgs; [ kotatogram-desktop nheko - docker-compose libreoffice image-roll asciinema # record the terminal neofetch # command-line system information - # tools - xh # friendly and fast tool for sending HTTP requests - fd # a simple, fast and user-friendly alternative to find - bat # a cat clone with syntax highlighting and git integration - ripgrep # a fuzzy finder - vnetod # a tool to change env sections - - # nix - nixpkgs-fmt - nil # lsp server - # browser # a fork of firefox, focused on privacy, security and freedom (librewolf.override { @@ -46,69 +50,18 @@ in postgresql_12 # 🤷 I need only psql ]; - # user interface - ui = { - # windows manager - xmonad.enable = true; - # bar - polybar.enable = true; - # lock - betterlockscreen.enable = true; + local.git = { + gpgKey = secrets.gpgSigningKey; + inherit (secrets) userName userEmail; + git-crypt.enable = true; }; - # shell - shell = { - zsh.enable = true; + programs.zsh.initExtra = lib.mkAfter '' + eval "$(cat $HOME/repos/tas/shell/zsh)" + eval $(kubectl completion zsh) + ''; - prompt.starship.enable = true; - }; - - # programs - progs = { - alacritty.enable = true; - - git = { - enable = true; - gpgKey = secrets.gpgSigningKey; - inherit (secrets) userName userEmail; - - git-crypt.enable = true; - }; - - # password manager - pass.enable = true; - - # email manager - aerc.enable = true; - - # finance manager - hledger.enable = true; - - # file manager - vifm.enable = true; - - # editor - nvim = { - enable = true; - default = true; - }; - - # tools - exa.enable = true; - zoxide.enable = true; - }; - - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; - - accounts = { - email = { - maildirBasePath = "${config.xdg.dataHome}/mail"; - accounts = secrets.emailAccounts; - }; - }; + accounts.email.accounts = secrets.emailAccounts; home.file = { "scripts" = { @@ -122,10 +75,4 @@ in }; }; - xdg.enable = true; - - services.wired = { - enable = true; - config = ./wired.ron; - }; } diff --git a/users/jan/progs/aerc/default.nix b/users/jan/progs/aerc/default.nix deleted file mode 100644 index d8e3e02..0000000 --- a/users/jan/progs/aerc/default.nix +++ /dev/null @@ -1,164 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.aerc; - - exec = cmd: ":${cmd}"; - fill = cmd: ":${cmd}"; -in -{ - options.progs.aerc = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add neomutt with my personal configuration"; - }; - }; - - # See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix - config = mkIf cfg.enable { - programs.aerc = { - enable = true; - # See: https://man.archlinux.org/man/aerc-config.5.en - extraConfig = { - general = { - unsafe-accounts-conf = true; - }; - - ui = { - index-format = "%-17.17D %-20.20n %Z %-20.20g %s"; - # See https://godoc.org/time#Time.Format - timestamp-format = "2006-01-02 15:04 MST"; - this-day-time-format = "15:04"; - this-week-time-format = "Monday 15:04"; - this-year-time-format = "02 January"; - pinned-tab-marker = "車"; - border-char-vertical = "│"; - border-char-horizontal = "─"; - fuzzy-complete = true; - new-message-bell = false; - }; - - statusline = { - display-mode = "icon"; - }; - - filters = { - "text/plain" = "${./colorize}"; - "text/html" = "html"; - }; - }; - extraBinds = { - messages = { - "q" = exec "quit"; - - "gt" = exec "next-tab"; - "gT" = exec "prev-tab"; - - "j" = exec "next"; - "" = exec "next"; - "" = exec "next 50%"; - - "k" = exec "prev"; - "" = exec "prev"; - "" = exec "prev 50%"; - - "gg" = exec "select 0"; - "G" = exec "select -1"; - - "J" = exec "next-folder"; - "K" = exec "prev-folder"; - "c" = fill "cf"; - - "" = exec "view"; - "C" = exec "compose"; - - "/" = fill "search"; - "\\" = fill "filter"; - "n" = exec "next-result"; - "N" = exec "prev-result"; - - "U" = exec "unsubscribe"; - "D" = exec "delete"; - "A" = exec "archive flat"; - #"D" = exec "modify-labels +deleted -inbox"; - #"A" = exec "modify-labels -inbox"; - #"ms" = exec "modify-labels +spam -inbox"; - #"mS" = exec "modify-labels -spam +inbox"; - }; - - view = { - "q" = exec "close"; - "O" = exec "open"; - "S" = fill "save"; - - "f" = exec "forward"; - - "rr" = exec "reply -a"; - "rq" = exec "reply -aq"; - "Rr" = exec "reply"; - "Rq" = exec "reply -q"; - - "" = exec "prev-part"; - "" = exec "next-part"; - "J" = exec "next"; - "K" = exec "prev"; - - "U" = exec "unsubscribe"; - "D" = exec "delete"; - "A" = exec "archive flat"; - # "ms" = exec "modify-labels +spam -inbox"; - # "mS" = exec "modify-labels -spam +inbox"; - }; - - compose = { - "$ex" = ""; - "" = exec "prev-field"; - "" = exec "next-field"; - "" = exec "next-field"; - }; - - "compose::editor" = { - "$noinherit" = "true"; - "$ex" = ""; - "" = exec "prev-field"; - "" = exec "next-field"; - }; - - "compose::review" = { - "y" = exec "send"; - "n" = exec "abort"; - "p" = exec "postpone"; - "q" = exec "choose -o d discard abort -o p postpone postpone"; - "e" = exec "edit"; - "a" = fill "attach"; - "d" = fill "detach"; - }; - }; - - stylesets.default = { - "*.selected.reverse" = true; - "title.reverse" = true; - "header.bold" = true; - "*error.bold" = true; - "error.fg" = 1; - "warning.fg" = 3; - "success.fg" = 2; - "statusline_default.bg" = 0; - "statusline_error.fg" = 1; - "statusline_error.reverse" = true; - "statusline_success.fg" = 2; - "statusline_success.reverse" = true; - "msglist_unread.bold" = true; - "msglist_deleted.fg" = 10; - "tab.bg" = 11; - "tab.selected.reverse" = false; - "tab.selected.bg" = 12; - "tab.fg" = 0; - "completion_default.bg" = 0; - }; - }; - }; -} diff --git a/users/jan/progs/alacritty/config.nix b/users/jan/progs/alacritty/config.nix deleted file mode 100644 index 27bbafe..0000000 --- a/users/jan/progs/alacritty/config.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ fontSize ? 11.0 }: - -{ - window = { - padding = { - x = 5; - y = 5; - }; - - decorations = "none"; - - dynamic_title = true; - }; - - scrolling = { - history = 10000; - - multiplier = 3; - }; - - font = - let - family = "monospace"; - - mkFont = style: { inherit family style; }; - in - { - normal = mkFont "Regular"; - bold = mkFont "Bold"; - italic = mkFont "Italic"; - bold_italic = mkFont "Bold Italic"; - - size = fontSize; - }; -} diff --git a/users/jan/progs/alacritty/default.nix b/users/jan/progs/alacritty/default.nix deleted file mode 100644 index 09ea265..0000000 --- a/users/jan/progs/alacritty/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.alacritty; - - alacrittyConfig = import ./config.nix { inherit (cfg) fontSize; }; -in -{ - options.progs.alacritty = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable alacritty, GPU-accelerated terminal emulator"; - }; - - fontSize = mkOption { - type = types.number; - default = 11.0; - description = "Alacritty font size"; - }; - }; - - config = mkIf cfg.enable { - programs.alacritty = { - enable = true; - settings = alacrittyConfig; - }; - }; -} diff --git a/users/jan/progs/default.nix b/users/jan/progs/default.nix deleted file mode 100644 index f31bf30..0000000 --- a/users/jan/progs/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -[ - ./alacritty - ./aerc - ./exa.nix - ./git.nix - ./hledger.nix - ./nvim.nix - ./pass.nix - ./vifm - ./zoxide.nix -] diff --git a/users/jan/progs/exa.nix b/users/jan/progs/exa.nix deleted file mode 100644 index 2c468ea..0000000 --- a/users/jan/progs/exa.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.exa; - zsh = config.shell.zsh; - - exaPackage = pkgs.exa.override { gitSupport = false; }; - defaultArgs = "--icons --classify"; - bin = "${exaPackage}/bin/exa ${defaultArgs}"; -in -{ - options.progs.exa = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add and configure exa, a modern replacement for ls"; - }; - }; - - config = mkIf cfg.enable { - programs.exa = { - enable = true; - package = exaPackage; - }; - - programs.zsh.shellAliases = mkIf zsh.enable rec { - ls = "${bin} --oneline"; - la = "${ls} --all"; - lt = "${bin} --tree --level=3"; - ll = "${bin} --long --header"; - lla = "${ll} --all"; - }; - }; -} diff --git a/users/jan/progs/hledger.nix b/users/jan/progs/hledger.nix deleted file mode 100644 index 9d88e19..0000000 --- a/users/jan/progs/hledger.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.hledger; - - bin = "${pkgs.hledger}/bin/hledger"; - sbin = "${bin} --strict"; - - hledgerAliases = { - hle = bin; - shle = sbin; - }; -in -{ - options.progs.hledger = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add and configure hledger tool to manage finance"; - }; - }; - - config = mkIf cfg.enable { - home.packages = with pkgs; [ - hledger - hledger-ui - hledger-interest - ]; - - home.file = { - "finance/commodities.journal".text = '' - ; Fiat currencies - commodity 1.000,00 RUB - commodity 1.000,00 USD - - ; Investment commodities - - ; Cryptocurrencies - - ; Other - - ; Default commodity - ; D 1.000,00 RUB - ''; - }; - - programs.zsh.shellAliases = mkIf config.shell.zsh.enable hledgerAliases; - }; -} - diff --git a/users/jan/progs/nvim.nix b/users/jan/progs/nvim.nix deleted file mode 100644 index e8a6cfb..0000000 --- a/users/jan/progs/nvim.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.nvim; - - myneovim = pkgs.myneovim.override { - viAlias = true; - vimAlias = true; - enableDevIcons = true; - enableTabby = true; - }; -in -{ - options.progs.nvim = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add and configure neovim"; - }; - - default = mkOption { - type = types.bool; - default = false; - description = "Set neovim as default editor"; - }; - }; - - config = mkIf cfg.enable { - home.packages = [ myneovim ]; - - home.sessionVariables = mkIf cfg.default { - EDITOR = "nvim"; - }; - }; -} diff --git a/users/jan/progs/pass.nix b/users/jan/progs/pass.nix deleted file mode 100644 index 129204b..0000000 --- a/users/jan/progs/pass.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.pass; - passDataDir = "${config.xdg.dataHome}/pass"; - - myPassPackage = pkgs.pass-minimal.withExtensions (ext: [ - ext.pass-audit - ]); -in -{ - options.progs.pass = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enables pass tool to manage your passwords"; - }; - }; - - config = mkIf cfg.enable { - programs.password-store = { - enable = true; - package = myPassPackage; - settings = { - PASSWORD_STORE_DIR = "${passDataDir}/store"; - }; - }; - services.pass-secret-service.enable = true; - - programs.gpg.enable = true; - services.gpg-agent.enable = true; - }; -} diff --git a/users/jan/progs/vifm/default.nix b/users/jan/progs/vifm/default.nix deleted file mode 100644 index 14c2ef3..0000000 --- a/users/jan/progs/vifm/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.vifm; -in -{ - options.progs.vifm = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add and configure vifm, a vi-like file manager"; - }; - }; - - config = mkIf cfg.enable { - home.packages = with pkgs; [ - vifm # a vi-like file manager - ]; - - - xdg.configFile = { - "vifm/vifmrc".source = ./vifmrc; - }; - }; -} - diff --git a/users/jan/progs/zoxide.nix b/users/jan/progs/zoxide.nix deleted file mode 100644 index 046bed9..0000000 --- a/users/jan/progs/zoxide.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.zoxide; -in -{ - options.progs.zoxide = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add zoxide, a modern replacement for cd"; - }; - }; - - config = mkIf cfg.enable { - programs.zoxide = { - enable = true; - enableZshIntegration = config.shell.zsh.enable; - }; - }; -} - diff --git a/users/jan/shell/default.nix b/users/jan/shell/default.nix deleted file mode 100644 index f75225d..0000000 --- a/users/jan/shell/default.nix +++ /dev/null @@ -1 +0,0 @@ -[ ./zsh.nix ] ++ (import ./prompt) diff --git a/users/jan/shell/prompt/default.nix b/users/jan/shell/prompt/default.nix deleted file mode 100644 index 664d604..0000000 --- a/users/jan/shell/prompt/default.nix +++ /dev/null @@ -1 +0,0 @@ -[ ./starship ] diff --git a/users/jan/shell/prompt/starship/config.nix b/users/jan/shell/prompt/starship/config.nix deleted file mode 100644 index 3c0f35d..0000000 --- a/users/jan/shell/prompt/starship/config.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ concatStrings }: - -{ - add_newline = true; - - format = concatStrings [ - "$directory" - "$git_branch" - "$git_commit" - "$git_state" - "$git_metrics" - "$git_status" - "$shlvl" - "$nix_shell" - "$cmd_duration" - "$jobs" - "$line_break" - "$character" - ]; - - character = { - success_symbol = "[➜](bold green)"; - error_symbol = "[➜](bold red)"; - }; - - git_commit.commit_hash_length = 6; - - shlvl = { - disabled = false; - format = "[$symbol$shlvl]($style) "; - symbol = "↕️ "; - threshold = 3; - }; -} diff --git a/users/jan/shell/prompt/starship/default.nix b/users/jan/shell/prompt/starship/default.nix deleted file mode 100644 index d05bd7c..0000000 --- a/users/jan/shell/prompt/starship/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.shell.prompt.starship; - - starshipConfig = import ./config.nix { - inherit concatStrings; - }; -in -{ - options.shell.prompt.starship = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable starship cross-shell prompt"; - }; - }; - - config = mkIf cfg.enable { - programs.starship = { - enable = true; - enableZshIntegration = config.shell.zsh.enable; - settings = starshipConfig; - }; - }; -} diff --git a/users/jan/shell/zsh.nix b/users/jan/shell/zsh.nix deleted file mode 100644 index 6a48b71..0000000 --- a/users/jan/shell/zsh.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.shell.zsh; -in -{ - options.shell.zsh = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add z shell"; - }; - }; - - config = mkIf cfg.enable { - # fish and zsh support for nix-shell - home.packages = with pkgs; [ any-nix-shell ]; - - programs.zsh = { - enable = true; - enableAutosuggestions = true; - enableCompletion = true; - defaultKeymap = "viins"; - dotDir = ".config/zsh"; - - history = { - path = "${config.xdg.dataHome}/zsh/zsh_history"; - expireDuplicatesFirst = true; - ignorePatterns = [ - "rm *" - "kill *" - ]; - }; - - oh-my-zsh = { - enable = true; - theme = mkIf (!config.shell.prompt.starship.enable) "robbyrussell"; - }; - - initExtra = '' - any-nix-shell zsh --info-right | source /dev/stdin - - eval "$(cat $HOME/repos/tas/shell/zsh)" - - eval $(kubectl completion zsh) - ''; - }; - }; -} diff --git a/users/jan/ui/betterlockscreen.nix b/users/jan/ui/betterlockscreen.nix deleted file mode 100644 index ccf891e..0000000 --- a/users/jan/ui/betterlockscreen.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.ui.betterlockscreen; - - package = config.services.betterlockscreen.package; -in -{ - options.ui.betterlockscreen = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable betterlockscreen"; - }; - }; - - - config = mkIf cfg.enable { - services.betterlockscreen = { - enable = true; - arguments = [ "--display 1" "--" "-e" ]; - inactiveInterval = 15; - }; - - systemd.user.timers.updateBetterlockscreenImage = { - Unit = { - Description = "Update betterlockscreen image timer"; - After = [ "graphical-session.target" "timers.target" ]; - }; - - Timer = { - OnUnitActiveSec = "60min"; - OnBootSec = "10s"; - }; - - Install = { - WantedBy = [ "graphical-session.target" "timers.target" ]; - }; - }; - - systemd.user.services.updateBetterlockscreenImage = { - Unit = { - Description = "Update betterlockscreen image"; - After = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - Environment = "PATH=/run/current-system/sw/bin"; - ExecStart = "${package}/bin/betterlockscreen --display 1 --update ${config.home.homeDirectory}/pictures/wallpapers"; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - }; - }; -} diff --git a/users/jan/ui/default.nix b/users/jan/ui/default.nix deleted file mode 100644 index 46461aa..0000000 --- a/users/jan/ui/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -[ - ./xmonad - ./polybar - ./betterlockscreen.nix -] - diff --git a/users/jan/ui/polybar/config.nix b/users/jan/ui/polybar/config.nix deleted file mode 100644 index 39340a2..0000000 --- a/users/jan/ui/polybar/config.nix +++ /dev/null @@ -1,138 +0,0 @@ -{ lib, config, pkgs, colors }: - -with lib; - -let - mkWifi = interface: { - type = "internal/network"; - interval = 3; - interface = { - text = interface; - type = "wireless"; - }; - label.connected = "%essid% %signal%"; - format.connected = { - prefix = "| "; - suffix = "%"; - }; - }; - - padding = 1; -in -{ - "bar/main" = { - monitor = "\${env:MONITOR:DisplayPort-1}"; - width = "100%"; - height = "20px"; - font = [ - "Fira Code:size=9:antialias=true" - "Fira Code:bold:size=9:antialias=true" - "FiraCode Nerd Font Mono:size=9:antialias=true" - "FiraCode Nerd Font Mono:size=14:antialias=true" - ]; - radius = 0; - modules = { - left = "xmonad"; - center = "date wifi_home wifi_laptop"; - right = "exchangerate volume battery lang time"; - }; - }; - - "module/date" = { - type = "internal/date"; - interval = 10; - date = "%a %d %b %Y"; - label = "%date%"; - format = { inherit padding; }; - }; - - "module/time" = { - type = "internal/date"; - time = "%H:%M:%S"; - label = { - text = "%time%"; - font = 2; - foreground = colors.orange; - }; - }; - - "module/lang" = { - type = "internal/xkeyboard"; - format = { - inherit padding; - text = ""; - }; - label.layout.font = 2; - }; - - "module/volume" = { - type = "custom/script"; - exec = "~/scripts/get_volume.sh"; - interval = 1; - format = { - inherit padding; - prefix = "%{T4}%{T-} "; - }; - }; - - "module/battery" = { - type = "internal/battery"; - full-at = 99; - low-at = 10; - battery = "BAT0"; - adapter = "AC0"; - - format.charging = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.green; - }; - - format.discharging = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.orange; - }; - - format.full = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.green; - }; - - format.low = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.red; - }; - - # Only applies if is used - ramp.capacity = [ "" "" "" "" "" ]; - }; - - "module/wifi_home" = mkWifi "wlp11s0f3u2"; - "module/wifi_laptop" = mkWifi "wlp2s0"; - - "module/xmonad" = mkIf config.ui.xmonad.enable { - type = "custom/script"; - exec = "${pkgs.xmonad-log}/bin/xmonad-log"; - tail = true; - }; - - "module/exchangerate" = { - type = "custom/script"; - exec = "~/scripts/exchangerate.sh"; - interval = 60; - format = { - inherit padding; - prefix = "USD: "; - }; - }; - - "global/wm" = { - margin = { - bottom = 0; - top = 0; - }; - }; -} diff --git a/users/jan/ui/polybar/default.nix b/users/jan/ui/polybar/default.nix deleted file mode 100644 index c32e3b3..0000000 --- a/users/jan/ui/polybar/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.ui.polybar; - pcfg = config.services.polybar; - - # TODO: create a theme - colors = { - orange = "#ee9a00"; - red = "#ff5555"; - green = "#50fa7b"; - }; - - polybarConfig = import ./config.nix { inherit lib config pkgs colors; }; -in -{ - options.ui.polybar = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable polybar status bar"; - }; - }; - - config = mkIf cfg.enable { - systemd.user.services.polybar = { - # Add additional /usr/bin to run custom scripts - Service.Environment = mkForce "PATH=${pcfg.package}/bin:/run/current-system/sw/bin"; - }; - - services.polybar = { - enable = true; - script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; - settings = polybarConfig; - }; - }; -} diff --git a/users/jan/ui/xmonad/default.nix b/users/jan/ui/xmonad/default.nix deleted file mode 100644 index b24c925..0000000 --- a/users/jan/ui/xmonad/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - uiCfg = config.ui; - cfg = uiCfg.xmonad; -in -{ - options.ui.xmonad = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable xsessions and xmonad window manager"; - }; - }; - - config = mkIf cfg.enable { - home.packages = with pkgs; [ - xclip # access x clipboard from a console - dmenu # menu for x window system - flameshot # powerful yet simple to use screenshot software - nitrogen # wallpaper manager - ]; - - xsession = { - enable = true; - - windowManager.xmonad = { - enable = true; - enableContribAndExtras = true; - config = ./config.hs; - extraPackages = mkIf uiCfg.polybar.enable (hp: [ - hp.dbus - hp.monad-logger - ]); - }; - - initExtra = '' - ${pkgs.nitrogen}/bin/nitrogen --restore & - ''; - }; - }; -} diff --git a/users/modules/dev_tools.nix b/users/modules/dev_tools.nix new file mode 100644 index 0000000..959acc4 --- /dev/null +++ b/users/modules/dev_tools.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, ... }: + +let + exaPackage = pkgs.exa.override { gitSupport = false; }; + defaultArgs = "--icons --classify"; + bin = "${exaPackage}/bin/exa ${defaultArgs}"; +in +{ + programs.exa = { + enable = true; + package = exaPackage; + }; + programs.zsh.shellAliases = lib.mkIf config.programs.zsh.enable rec { + ls = "${bin} --oneline"; + la = "${ls} --all"; + lt = "${bin} --tree --level=3"; + ll = "${bin} --long --header"; + lla = "${ll} --all"; + }; + + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; + + programs.zoxide = { + enable = true; + enableZshIntegration = config.programs.zsh.enable; + }; + + home.packages = with pkgs; [ + # tools + xh # friendly and fast tool for sending HTTP requests + fd # a simple, fast and user-friendly alternative to find + bat # a cat clone with syntax highlighting and git integration + ripgrep # a fuzzy finder + vnetod # a tool to change env sections + + # nix + nixpkgs-fmt + nil # lsp server + + docker-compose + ]; +} diff --git a/users/modules/editor.nix b/users/modules/editor.nix new file mode 100644 index 0000000..cc2d0d3 --- /dev/null +++ b/users/modules/editor.nix @@ -0,0 +1,15 @@ +{ config, pkgs, ... }: + +let + myneovim = pkgs.myneovim.override { + viAlias = true; + vimAlias = true; + enableDevIcons = true; + enableTabby = true; + }; +in +{ + home.packages = [ myneovim ]; + + home.sessionVariables.EDITOR = "nvim"; +} diff --git a/users/modules/file_manager/default.nix b/users/modules/file_manager/default.nix new file mode 100644 index 0000000..9c57dad --- /dev/null +++ b/users/modules/file_manager/default.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: + +{ + home.packages = with pkgs; [ vifm ]; + + xdg.configFile = { + "vifm/vifmrc".source = ./vifmrc; + }; +} diff --git a/users/jan/progs/vifm/vifmrc b/users/modules/file_manager/vifmrc similarity index 100% rename from users/jan/progs/vifm/vifmrc rename to users/modules/file_manager/vifmrc diff --git a/users/jan/progs/git.nix b/users/modules/git.nix similarity index 77% rename from users/jan/progs/git.nix rename to users/modules/git.nix index 89b9ffa..a9ec732 100644 --- a/users/jan/progs/git.nix +++ b/users/modules/git.nix @@ -1,18 +1,10 @@ { lib, config, pkgs, ... }: -with lib; - let - cfg = config.progs.git; + cfg = config.local.git; in { - options.progs.git = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add git with my personal settings"; - }; - + options.local.git = with lib; { userName = mkOption { type = types.str; description = "Set your global name"; @@ -38,14 +30,13 @@ in }; }; - config = mkIf cfg.enable { - home.packages = mkIf cfg.git-crypt.enable [ pkgs.git-crypt ]; + config = { + home.packages = lib.mkIf cfg.git-crypt.enable [ pkgs.git-crypt ]; programs.git = { enable = true; - userName = cfg.userName; - userEmail = cfg.userEmail; - signing = mkIf (cfg.gpgKey != null) { + inherit (cfg) userName userEmail; + signing = lib.mkIf (cfg.gpgKey != null) { key = cfg.gpgKey; signByDefault = true; }; @@ -75,6 +66,7 @@ in plo = "pull origin"; rb = "rebase"; rbi = "rebase -i"; + lo = "log --pretty=oneline"; }; }; }; diff --git a/users/modules/ledger.nix b/users/modules/ledger.nix new file mode 100644 index 0000000..4f2583a --- /dev/null +++ b/users/modules/ledger.nix @@ -0,0 +1,37 @@ +{ lib, config, pkgs, ... }: + +let + bin = "${pkgs.hledger}/bin/hledger"; + sbin = "${bin} --strict"; + + hledgerAliases = { + hle = bin; + shle = sbin; + }; +in +{ + home.packages = with pkgs; [ + hledger + hledger-ui + hledger-interest + ]; + + home.file = { + "finance/commodities.journal".text = '' + ; Fiat currencies + commodity 1.000,00 RUB + commodity 1.000,00 USD + + ; Investment commodities + + ; Cryptocurrencies + + ; Other + + ; Default commodity + ; D 1.000,00 RUB + ''; + }; + + programs.zsh.shellAliases = lib.mkIf config.programs.zsh.enable hledgerAliases; +} diff --git a/users/jan/progs/aerc/colorize b/users/modules/mail/colorize similarity index 100% rename from users/jan/progs/aerc/colorize rename to users/modules/mail/colorize diff --git a/users/modules/mail/default.nix b/users/modules/mail/default.nix new file mode 100644 index 0000000..95466b1 --- /dev/null +++ b/users/modules/mail/default.nix @@ -0,0 +1,152 @@ +{ config, pkgs, ... }: + +let + exec = cmd: ":${cmd}"; + fill = cmd: ":${cmd}"; +in +{ + accounts.email.maildirBasePath = "${config.xdg.dataHome}/mail"; + + # See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix + programs.aerc = { + enable = true; + # See: https://man.archlinux.org/man/aerc-config.5.en + extraConfig = { + general = { + unsafe-accounts-conf = true; + }; + + ui = { + index-format = "%-17.17D %-20.20n %Z %-20.20g %s"; + # See https://godoc.org/time#Time.Format + timestamp-format = "2006-01-02 15:04 MST"; + this-day-time-format = "15:04"; + this-week-time-format = "Monday 15:04"; + this-year-time-format = "02 January"; + pinned-tab-marker = "車"; + border-char-vertical = "│"; + border-char-horizontal = "─"; + fuzzy-complete = true; + new-message-bell = false; + }; + + statusline = { + display-mode = "icon"; + }; + + filters = { + "text/plain" = "${./colorize}"; + "text/html" = "html"; + }; + }; + extraBinds = { + messages = { + "q" = exec "quit"; + + "gt" = exec "next-tab"; + "gT" = exec "prev-tab"; + + "j" = exec "next"; + "" = exec "next"; + "" = exec "next 50%"; + + "k" = exec "prev"; + "" = exec "prev"; + "" = exec "prev 50%"; + + "gg" = exec "select 0"; + "G" = exec "select -1"; + + "J" = exec "next-folder"; + "K" = exec "prev-folder"; + "c" = fill "cf"; + + "" = exec "view"; + "C" = exec "compose"; + + "/" = fill "search"; + "\\" = fill "filter"; + "n" = exec "next-result"; + "N" = exec "prev-result"; + + "U" = exec "unsubscribe"; + "D" = exec "delete"; + "A" = exec "archive flat"; + #"D" = exec "modify-labels +deleted -inbox"; + #"A" = exec "modify-labels -inbox"; + #"ms" = exec "modify-labels +spam -inbox"; + #"mS" = exec "modify-labels -spam +inbox"; + }; + + view = { + "q" = exec "close"; + "O" = exec "open"; + "S" = fill "save"; + + "f" = exec "forward"; + + "rr" = exec "reply -a"; + "rq" = exec "reply -aq"; + "Rr" = exec "reply"; + "Rq" = exec "reply -q"; + + "" = exec "prev-part"; + "" = exec "next-part"; + "J" = exec "next"; + "K" = exec "prev"; + + "U" = exec "unsubscribe"; + "D" = exec "delete"; + "A" = exec "archive flat"; + # "ms" = exec "modify-labels +spam -inbox"; + # "mS" = exec "modify-labels -spam +inbox"; + }; + + compose = { + "$ex" = ""; + "" = exec "prev-field"; + "" = exec "next-field"; + "" = exec "next-field"; + }; + + "compose::editor" = { + "$noinherit" = "true"; + "$ex" = ""; + "" = exec "prev-field"; + "" = exec "next-field"; + }; + + "compose::review" = { + "y" = exec "send"; + "n" = exec "abort"; + "p" = exec "postpone"; + "q" = exec "choose -o d discard abort -o p postpone postpone"; + "e" = exec "edit"; + "a" = fill "attach"; + "d" = fill "detach"; + }; + }; + + stylesets.default = { + "*.selected.reverse" = true; + "title.reverse" = true; + "header.bold" = true; + "*error.bold" = true; + "error.fg" = 1; + "warning.fg" = 3; + "success.fg" = 2; + "statusline_default.bg" = 0; + "statusline_error.fg" = 1; + "statusline_error.reverse" = true; + "statusline_success.fg" = 2; + "statusline_success.reverse" = true; + "msglist_unread.bold" = true; + "msglist_deleted.fg" = 10; + "tab.bg" = 11; + "tab.selected.reverse" = false; + "tab.selected.bg" = 12; + "tab.fg" = 0; + "completion_default.bg" = 0; + }; + }; +} diff --git a/users/modules/notifications/default.nix b/users/modules/notifications/default.nix new file mode 100644 index 0000000..21c27a4 --- /dev/null +++ b/users/modules/notifications/default.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + services.wired = { + enable = true; + config = ./wired.ron; + }; +} diff --git a/users/jan/wired.ron b/users/modules/notifications/wired.ron similarity index 100% rename from users/jan/wired.ron rename to users/modules/notifications/wired.ron diff --git a/users/modules/pass.nix b/users/modules/pass.nix new file mode 100644 index 0000000..d649b66 --- /dev/null +++ b/users/modules/pass.nix @@ -0,0 +1,22 @@ +{ config, pkgs, ... }: + +let + passDataDir = "${config.xdg.dataHome}/pass"; + + myPassPackage = pkgs.pass-minimal.withExtensions (ext: [ + ext.pass-audit + ]); +in +{ + programs.password-store = { + enable = true; + package = myPassPackage; + settings = { + PASSWORD_STORE_DIR = "${passDataDir}/store"; + }; + }; + services.pass-secret-service.enable = true; + + programs.gpg.enable = true; + services.gpg-agent.enable = true; +} diff --git a/users/modules/shell.nix b/users/modules/shell.nix new file mode 100644 index 0000000..bc0a286 --- /dev/null +++ b/users/modules/shell.nix @@ -0,0 +1,66 @@ +{ lib, config, pkgs, ... }: + +{ + # fish and zsh support for nix-shell + home.packages = with pkgs; [ any-nix-shell ]; + + programs.zsh = { + enable = true; + enableAutosuggestions = true; + enableCompletion = true; + defaultKeymap = "viins"; + dotDir = ".config/zsh"; + + history = { + path = "${config.xdg.dataHome}/zsh/zsh_history"; + expireDuplicatesFirst = true; + ignorePatterns = [ + "rm *" + "kill *" + ]; + }; + + oh-my-zsh.enable = true; + + initExtra = '' + any-nix-shell zsh --info-right | source /dev/stdin + ''; + }; + + programs.starship = { + enable = true; + enableZshIntegration = config.programs.zsh.enable; + settings = { + add_newline = true; + + format = lib.concatStrings [ + "$directory" + "$git_branch" + "$git_commit" + "$git_state" + "$git_metrics" + "$git_status" + "$shlvl" + "$nix_shell" + "$cmd_duration" + "$jobs" + "$line_break" + "$character" + ]; + + character = { + success_symbol = "[➜](bold green)"; + error_symbol = "[➜](bold red)"; + }; + + git_commit.commit_hash_length = 6; + + shlvl = { + disabled = false; + format = "[$symbol$shlvl]($style) "; + symbol = "↕️ "; + threshold = 3; + }; + }; + }; +} diff --git a/users/modules/terminal.nix b/users/modules/terminal.nix new file mode 100644 index 0000000..9199650 --- /dev/null +++ b/users/modules/terminal.nix @@ -0,0 +1,46 @@ +{ lib, config, pkgs, ... }: + +let + cfg = config.local.alacritty; +in +{ + options.local.alacritty = with lib; { + fontSize = mkOption { + type = types.number; + default = 11.0; + description = "Alacritty font size"; + }; + }; + + config = { + programs.alacritty = { + enable = true; + settings = { + window = { + padding = { x = 5; y = 5; }; + decorations = "none"; + dynamic_title = true; + }; + + scrolling = { + history = 10000; + multiplier = 3; + }; + + font = + let + family = "monospace"; + mkFont = style: { inherit family style; }; + in + { + normal = mkFont "Regular"; + bold = mkFont "Bold"; + italic = mkFont "Italic"; + bold_italic = mkFont "Bold Italic"; + + size = cfg.fontSize; + }; + }; + }; + }; +} diff --git a/users/modules/window_manager/betterlockscreen.nix b/users/modules/window_manager/betterlockscreen.nix new file mode 100644 index 0000000..f4c597f --- /dev/null +++ b/users/modules/window_manager/betterlockscreen.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + + +let + inherit (config.services.betterlockscreen) package; +in +{ + services.betterlockscreen = { + enable = true; + arguments = [ "--display 1" "--" "-e" ]; + inactiveInterval = 15; + }; + + systemd.user.timers.updateBetterlockscreenImage = { + Unit = { + Description = "Update betterlockscreen image timer"; + After = [ "graphical-session.target" "timers.target" ]; + }; + + Timer = { + OnUnitActiveSec = "60min"; + OnBootSec = "10s"; + }; + + Install = { + WantedBy = [ "graphical-session.target" "timers.target" ]; + }; + }; + + systemd.user.services.updateBetterlockscreenImage = { + Unit = { + Description = "Update betterlockscreen image"; + After = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + Environment = "PATH=/run/current-system/sw/bin"; + ExecStart = "${package}/bin/betterlockscreen --display 1 --fx '' --update ${config.home.homeDirectory}/pictures/wallpapers"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; +} diff --git a/users/modules/window_manager/default.nix b/users/modules/window_manager/default.nix new file mode 100644 index 0000000..59cf02f --- /dev/null +++ b/users/modules/window_manager/default.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + imports = [ + ./xmonad.nix + ./polybar.nix + ./betterlockscreen.nix + ]; +} diff --git a/users/modules/window_manager/polybar.nix b/users/modules/window_manager/polybar.nix new file mode 100644 index 0000000..4f7713b --- /dev/null +++ b/users/modules/window_manager/polybar.nix @@ -0,0 +1,162 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + inherit (config.services.polybar) package; + + # TODO: create a theme + colors = { + orange = "#ee9a00"; + red = "#ff5555"; + green = "#50fa7b"; + }; + +in +{ + systemd.user.services.polybar = { + # Add additional /usr/bin to run custom scripts + Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin"; + }; + + services.polybar = { + enable = true; + script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; + settings = + let + mkWifi = interface: { + type = "internal/network"; + interval = 3; + interface = { + text = interface; + type = "wireless"; + }; + label.connected = "%essid% %signal%"; + format.connected = { + prefix = "| "; + suffix = "%"; + }; + }; + + padding = 1; + in + { + "bar/main" = { + monitor = "\${env:MONITOR:DisplayPort-1}"; + width = "100%"; + height = "20px"; + font = [ + "Fira Code:size=9:antialias=true" + "Fira Code:bold:size=9:antialias=true" + "FiraCode Nerd Font Mono:size=9:antialias=true" + "FiraCode Nerd Font Mono:size=14:antialias=true" + ]; + radius = 0; + modules = { + left = "xmonad"; + center = "date wifi_home wifi_laptop"; + right = "exchangerate volume battery lang time"; + }; + }; + + "module/date" = { + type = "internal/date"; + interval = 10; + date = "%a %d %b %Y"; + label = "%date%"; + format = { inherit padding; }; + }; + + "module/time" = { + type = "internal/date"; + time = "%H:%M:%S"; + label = { + text = "%time%"; + font = 2; + foreground = colors.orange; + }; + }; + + "module/lang" = { + type = "internal/xkeyboard"; + format = { + inherit padding; + text = ""; + }; + label.layout.font = 2; + }; + + "module/volume" = { + type = "custom/script"; + exec = "~/scripts/get_volume.sh"; + interval = 1; + format = { + inherit padding; + prefix = "%{T4}%{T-} "; + }; + }; + + "module/battery" = { + type = "internal/battery"; + full-at = 99; + low-at = 10; + battery = "BAT0"; + adapter = "AC0"; + + format.charging = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.green; + }; + + format.discharging = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.orange; + }; + + format.full = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.green; + }; + + format.low = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.red; + }; + + # Only applies if is used + ramp.capacity = [ "" "" "" "" "" ]; + }; + + "module/wifi_home" = mkWifi "wlp11s0f3u2"; + "module/wifi_laptop" = mkWifi "wlp2s0"; + + "module/xmonad" = mkIf config.xsession.windowManager.xmonad.enable { + type = "custom/script"; + exec = "${pkgs.xmonad-log}/bin/xmonad-log"; + tail = true; + }; + + "module/exchangerate" = { + type = "custom/script"; + exec = "~/scripts/exchangerate.sh"; + interval = 60; + format = { + inherit padding; + prefix = "USD: "; + }; + }; + + "global/wm" = { + margin = { + bottom = 0; + top = 0; + }; + }; + } + ; + }; +} diff --git a/users/modules/window_manager/xmonad.nix b/users/modules/window_manager/xmonad.nix new file mode 100644 index 0000000..e86508d --- /dev/null +++ b/users/modules/window_manager/xmonad.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +{ + home.packages = with pkgs; [ + xclip # access x clipboard from a console + dmenu # menu for x window system + flameshot # powerful yet simple to use screenshot software + nitrogen # wallpaper manager + ]; + + xsession = { + enable = true; + + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + config = ./xmonad_config.hs; + extraPackages = (hp: [ + hp.dbus + hp.monad-logger + ]); + }; + + initExtra = '' + ${pkgs.nitrogen}/bin/nitrogen --restore & + ''; + }; +} diff --git a/users/jan/ui/xmonad/config.hs b/users/modules/window_manager/xmonad_config.hs similarity index 100% rename from users/jan/ui/xmonad/config.hs rename to users/modules/window_manager/xmonad_config.hs