From 61f3db56410f41d5249c88e44db60d9713dae26d Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Tue, 3 Dec 2024 21:19:39 -0600 Subject: home: big refactor --- flake.nix | 22 ++---- home/baseline/default.nix | 63 ++++++++++++++++ home/baseline/git.nix | 13 ++++ home/baseline/graphics.nix | 52 +++++++++++++ home/baseline/nvim.nix | 26 +++++++ home/baseline/zsh.nix | 14 ++++ home/baseline/zshrc.nix | 64 ++++++++++++++++ home/default.nix | 67 ++--------------- home/desktop.nix | 177 --------------------------------------------- home/desktop/default.nix | 14 ++++ home/desktop/firefox.nix | 30 ++++++++ home/desktop/sway.nix | 117 ++++++++++++++++++++++++++++++ home/environ.nix | 73 ------------------- home/environ/default.nix | 17 +++++ home/environ/gpg.nix | 30 ++++++++ home/environ/pass.nix | 26 +++++++ home/environ/path.nix | 45 ++++++++++++ home/environ/source.nix | 23 ++++++ home/environ/ssh-match.nix | 1 + home/environ/ssh.nix | 23 ++++++ home/environ/tmux.nix | 41 +++++++++++ home/environ/units.nix | 33 +++++++++ home/environ/vtmp.nix | 20 +++++ home/git.nix | 14 ---- home/gpg.nix | 27 ------- home/graphics.nix | 30 -------- home/isolation.nix | 19 ----- home/isolation/default.nix | 34 +++++++++ home/mail/default.nix | 9 ++- home/pass.nix | 21 ------ home/path.nix | 51 ------------- home/ssh/default.nix | 20 ----- home/ssh/match.nix | 82 --------------------- home/zshrc.nix | 64 ---------------- 34 files changed, 706 insertions(+), 656 deletions(-) create mode 100644 home/baseline/default.nix create mode 100644 home/baseline/git.nix create mode 100644 home/baseline/graphics.nix create mode 100644 home/baseline/nvim.nix create mode 100644 home/baseline/zsh.nix create mode 100644 home/baseline/zshrc.nix delete mode 100644 home/desktop.nix create mode 100644 home/desktop/default.nix create mode 100644 home/desktop/firefox.nix create mode 100644 home/desktop/sway.nix delete mode 100644 home/environ.nix create mode 100644 home/environ/default.nix create mode 100644 home/environ/gpg.nix create mode 100644 home/environ/pass.nix create mode 100644 home/environ/path.nix create mode 100644 home/environ/source.nix create mode 100644 home/environ/ssh-match.nix create mode 100644 home/environ/ssh.nix create mode 100644 home/environ/tmux.nix create mode 100644 home/environ/units.nix create mode 100644 home/environ/vtmp.nix delete mode 100644 home/git.nix delete mode 100644 home/gpg.nix delete mode 100644 home/graphics.nix delete mode 100644 home/isolation.nix create mode 100644 home/isolation/default.nix delete mode 100644 home/pass.nix delete mode 100644 home/path.nix delete mode 100644 home/ssh/default.nix delete mode 100644 home/ssh/match.nix delete mode 100644 home/zshrc.nix diff --git a/flake.nix b/flake.nix index 258901f..ed8ea1f 100644 --- a/flake.nix +++ b/flake.nix @@ -104,32 +104,24 @@ let registry = { ... }: { config.nix.registry = mapAttrs - (_: value: { - flake = value; - }) + (_: value: { flake = value; }) flakes; }; - home = platform: home-manager.lib.homeManagerConfiguration { + home = name: platform: home-manager.lib.homeManagerConfiguration { inherit pkgs; + extraSpecialArgs = { + inherit flakes; + }; + modules = [ ./home platform registry - hm-isolation.homeManagerModule ]; }; - - platformHome = platform: - let - value = home platform; - in - { - inherit value; - name = "${value.config.home.username}@${value.config.local.hostname}"; - }; in - mapAttrs' (_: platformHome) (importAll { root = ./home/platform; }); + mapAttrs home (importAll { root = ./home/platform; }); }; } diff --git a/home/baseline/default.nix b/home/baseline/default.nix new file mode 100644 index 0000000..a859fb7 --- /dev/null +++ b/home/baseline/default.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.baseline; +in +{ + imports = [ + ./git.nix + ./graphics.nix + ./nvim.nix + ./zsh.nix + ]; + + options.local = { + hostname = mkOption { + type = types.str; + }; + + uid = mkOption { + type = types.int; + }; + + gecos = mkOption { + type = types.str; + }; + + email = mkOption { + type = types.str; + }; + }; + + config = { + home = { + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + stateVersion = "21.11"; + + homeDirectory = "/home/${config.home.username}"; + + packages = [ + pkgs.file + pkgs.killall + pkgs.man-pages + pkgs.man-pages-posix + pkgs.tree + pkgs.unzip + pkgs.wget + pkgs.zip + ]; + + sessionVariables = { + LESSHISTFILE = "/dev/null"; + }; + }; + + xdg.enable = true; + }; +} diff --git a/home/baseline/git.nix b/home/baseline/git.nix new file mode 100644 index 0000000..faad082 --- /dev/null +++ b/home/baseline/git.nix @@ -0,0 +1,13 @@ +{ config, lib, ... }: +with lib; let + cfg = config.local; +in +{ + config = { + programs.git = { + enable = true; + userName = cfg.gecos; + userEmail = cfg.email; + }; + }; +} diff --git a/home/baseline/graphics.nix b/home/baseline/graphics.nix new file mode 100644 index 0000000..072acb7 --- /dev/null +++ b/home/baseline/graphics.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: +with lib; { + config = { + fonts.fontconfig.enable = true; + + gtk = { + enable = true; + + gtk2.extraConfig = '' + gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ + gtk-menu-images=1 + gtk-button-images=1 + ''; + + font = { + package = pkgs.noto-fonts; + name = "Noto Sans Regular"; + #size = 14; <- caga layout de páginas + }; + + theme = { + package = pkgs.materia-theme; + name = "Materia-dark"; + }; + }; + + home = { + pointerCursor = { + name = "Adwaita"; + package = pkgs.adwaita-icon-theme; + + gtk.enable = true; + x11.enable = true; + }; + + sessionVariables = { + # Usar gtk en aplicaciones de jvm + _JAVA_OPTIONS = concatStringsSep " " [ + "-Dawt.useSystemAAFontSettings=on" + "-Dswing.aatext=true" + "-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel" + "-Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel" + ]; + }; + }; + + qt = { + enable = true; + platformTheme.name = "gtk"; + }; + }; +} diff --git a/home/baseline/nvim.nix b/home/baseline/nvim.nix new file mode 100644 index 0000000..882788d --- /dev/null +++ b/home/baseline/nvim.nix @@ -0,0 +1,26 @@ +{ config, lib, ... }: +with lib; let + cfg = config.local.baseline; +in +{ + config = { + home.sessionVariables.EDITOR = "nvim"; + + programs.neovim = { + enable = true; + + viAlias = true; + vimAlias = true; + withRuby = false; + withPython3 = false; + + extraConfig = '' + set number " Enable line numbering + set relativenumber " Enable relative line numbering + set tabstop=4 " Set tap stop to 4 + set shiftwidth=4 " Set shift width to 4 (same as tabstop) + set viminfo= " No tracking + ''; + }; + }; +} diff --git a/home/baseline/zsh.nix b/home/baseline/zsh.nix new file mode 100644 index 0000000..8dd169c --- /dev/null +++ b/home/baseline/zsh.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.baseline; +in +{ + config = { + programs.zsh = { + enable = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + initExtra = import ./zshrc.nix pkgs; + }; + }; +} diff --git a/home/baseline/zshrc.nix b/home/baseline/zshrc.nix new file mode 100644 index 0000000..a82ab7a --- /dev/null +++ b/home/baseline/zshrc.nix @@ -0,0 +1,64 @@ +{ grml-zsh-config, local, ... }: '' + source ${grml-zsh-config}/etc/zsh/zshrc + + export PATH="$PATH:$HOME/.cargo/bin" + + alias reset='tput reset' + alias reload='exec zsh' + alias this-date='date +%b%d | sed "s/^\w/\U&/g"' + + function spawn() { + if [ ! -x "$(command -v $1)" ]; then + echo "spawn: no such command: $1" >&2 + return 1 + fi + + $@ >/dev/null 0>&1 2>&1 & + disown + } + + function xseli() { + T=$(mktemp) + $EDITOR -n $T + xsel -b <$T + rm $T + } + + autoload -Uz up-line-or-beginning-search + zle -N up-line-or-beginning-search + autoload -Uz down-line-or-beginning-search + zle -N down-line-or-beginning-search + bindkey '\eOA' up-line-or-beginning-search + bindkey '\e[A' up-line-or-beginning-search + bindkey '\eOB' down-line-or-beginning-search + bindkey '\e[B' down-line-or-beginning-search + + INSTALLABLES=() + while read -d: PATH_ITEM; do + if [[ "$PATH_ITEM" =~ "^(/nix/store/[a-z0-9]+-([a-zA-Z][a-zA-Z0-9_]*(-[a-zA-Z][a-zA-Z0-9_]*)*)(-[^/]+)?)/" ]]; then + INSTALLABLES+=("''${match[2]}") + fi + done <<<"$PATH" + + if [ "''${#INSTALLABLES[@]}" -gt 0 ]; then + _GRML_NIX_SHELL="{''${INSTALLABLES[@]}} " + fi + + unset INSTALLABLES PATH_ITEM + + function grml_nix_shell() { + REPLY="$_GRML_NIX_SHELL" + } + + grml_theme_add_token nix-shell -f grml_nix_shell '%F{red}' '%f' + + zstyle ':prompt:grml:left:setup' items $([ ''${NO_USERATHOST:-0} -gt 0 ] || echo user at host) path nix-shell percent + zstyle ':prompt:grml:right:setup' items sad-smiley vcs $([ ''${NO_BATTERY:-0} -gt 0 ] || echo battery) time + zstyle ':prompt:grml:right:items:time' pre ' %F{yellow}' + + unsetopt sharehistory + setopt appendhistory + setopt extendedhistory + + source ${local.git-aliases} +'' diff --git a/home/default.nix b/home/default.nix index 96d6b3f..254cde2 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,66 +1,11 @@ -{ lib, config, pkgs, ... }: -with lib; { +{ flakes, ... }: { imports = [ + flakes.hm-isolation.homeManagerModule ../pki - ./desktop.nix - ./environ.nix - ./git.nix - ./gpg.nix - ./graphics.nix - ./isolation.nix + ./baseline + ./desktop + ./environ + ./isolation ./mail - ./path.nix - ./pass.nix - ./ssh ]; - - options.local = with lib.types; { - hostname = mkOption { - type = str; - }; - - uid = mkOption { - type = int; - }; - - workstation = mkOption { - type = bool; - }; - }; - - config = { - nix.registry."system".to = { - type = "path"; - path = "${config.home.homeDirectory}/nix"; - }; - - home = { - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - stateVersion = "21.11"; - - homeDirectory = "/home/${config.home.username}"; - - sessionVariables = { - EDITOR = "nvim"; - LESSHISTFILE = "/dev/null"; - - # Usar gtk en aplicaciones de jvm - _JAVA_OPTIONS = concatStringsSep " " [ - "-Dawt.useSystemAAFontSettings=on" - "-Dswing.aatext=true" - "-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel" - "-Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel" - ]; - }; - }; - - programs.home-manager.enable = true; - }; } diff --git a/home/desktop.nix b/home/desktop.nix deleted file mode 100644 index fea1f35..0000000 --- a/home/desktop.nix +++ /dev/null @@ -1,177 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config = mkIf (!config.home.isolation.active) { - home.pointerCursor = { - package = pkgs.adwaita-icon-theme; - - gtk.enable = true; - name = "Adwaita"; - x11.enable = true; - }; - - programs = { - firefox = { - enable = true; - - package = pkgs.firefox.override { - nativeMessagingHosts = [ pkgs.passff-host ]; - }; - - profiles."main.profile" = { - id = 0; - name = "default"; - - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - decentraleyes - darkreader - old-reddit-redirect - passff - privacy-badger - ublock-origin - umatrix - ]; - }; - }; - - swaylock = { - enable = true; - - settings = { - color = "222222"; - font-size = 24; - show-failed-attempts = true; - }; - }; - - tmux = { - enable = true; - aggressiveResize = true; - clock24 = true; - escapeTime = 10; - terminal = "xterm-256color"; - keyMode = "vi"; - - plugins = [ - { - plugin = pkgs.local.tmux-pass; - extraConfig = '' - set -g @pass-key BSpace - set -g @pass-copy-to-clipboard on - set -g @pass-window-size 15 - set -g @pass-hide-pw-from-preview 'on' - set -g @pass-hide-preview on - ''; - } - ]; - - extraConfig = '' - set -g mouse on - set -ga update-environment " LIFT_PID" - set -g set-titles on - set -g renumber-windows on - set -sa terminal-overrides ',xterm-termite:RGB' - set -g status-right "#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,} %H:%M %d-%b-%y" - bind-key X set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}" - ''; - }; - - waybar.enable = true; - - wofi.enable = true; - }; - - services = { - swayidle = { - enable = true; - - timeouts = [ - { timeout = 600; command = "${getExe config.programs.swaylock.package} -fF"; } - ]; - }; - }; - - systemd.user.services.wl-gammarelay-rs = { - Unit.After = [ "sway-session.target" ]; - Install.WantedBy = [ "sway-session.target" ]; - - Service.ExecStart = getExe pkgs.wl-gammarelay-rs; - }; - - wayland.windowManager.sway = { - enable = true; - - config = { - modifier = "Mod4"; - focus.followMouse = false; - - fonts = { - size = 11.0; - names = [ "DejaVu Sans Mono" ]; - style = "Bold Semi-Condensed"; - }; - - bars = singleton { - command = "waybar"; - position = "top"; - }; - - keybindings = - let - mod = config.wayland.windowManager.sway.config.modifier; - wofi = config.programs.wofi.package; - - inherit (pkgs.local) st tmux-lift; - - grimshot = getExe pkgs.sway-contrib.grimshot; - in - mkOptionDefault { - "${mod}+a" = "focus parent"; - "${mod}+c" = "focus child"; - "${mod}+d" = "exec --no-startup-id ${getExe wofi} -S run"; - "${mod}+i" = "exec busctl --user call rs.wl-gammarelay / rs.wl.gammarelay ToggleInverted"; - "${mod}+o" = "exec ${getExe config.programs.swaylock.package} -fF"; - "${mod}+Return" = "exec ${getExe st} -e ${getExe tmux-lift}"; - "${mod}+Shift+e" = "input * xkb_layout latam"; - "${mod}+Shift+u" = "input * xkb_layout us"; - "${mod}+p" = "exec ${grimshot} copy active"; - "${mod}+Shift+p" = "exec ${grimshot} copy area"; - "${mod}+Ctrl+p" = "exec ${grimshot} copy window"; - }; - - startup = [ - { - command = "${getExe pkgs.xautolock} -time 10 -locker '${pkgs.i3lock-color}/bin/i3lock-color -fe -c222222'"; - } - ]; - - window.commands = [ - # (No) Title Bars - { - command = "border pixel 5"; - criteria.class = "^.*"; - } - - { - command = "floating enabled"; - criteria.class = "floating"; - } - ]; - }; - - extraSessionCommands = '' - export SDL_VIDEODRIVER=wayland - # needs qt5.qtwayland in systemPackages - export QT_QPA_PLATFORM=wayland - export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" - # Fix for some Java AWT applications (e.g. Android Studio), - # use this if they aren't displayed properly: - export _JAVA_AWT_WM_NONREPARENTING=1 - ''; - - swaynag.enable = true; - systemd.enable = true; - - xwayland = true; - }; - }; -} diff --git a/home/desktop/default.nix b/home/desktop/default.nix new file mode 100644 index 0000000..1608693 --- /dev/null +++ b/home/desktop/default.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.desktop; +in +{ + imports = [ + ./firefox.nix + ./sway.nix + ]; + + options.local.desktop = { + enable = mkEnableOption "desktop"; + }; +} diff --git a/home/desktop/firefox.nix b/home/desktop/firefox.nix new file mode 100644 index 0000000..4a7bbac --- /dev/null +++ b/home/desktop/firefox.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.desktop; +in +{ + config = mkIf cfg.enable { + programs.firefox = { + enable = true; + + package = pkgs.firefox.override { + nativeMessagingHosts = [ pkgs.passff-host ]; + }; + + profiles."main.profile" = { + id = 0; + name = "default"; + + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + decentraleyes + darkreader + old-reddit-redirect + passff + privacy-badger + ublock-origin + umatrix + ]; + }; + }; + }; +} diff --git a/home/desktop/sway.nix b/home/desktop/sway.nix new file mode 100644 index 0000000..1162e87 --- /dev/null +++ b/home/desktop/sway.nix @@ -0,0 +1,117 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.desktop; +in +{ + config = mkIf cfg.enable { + programs = { + swaylock = { + enable = true; + + settings = { + color = "222222"; + font-size = 24; + show-failed-attempts = true; + }; + }; + + waybar.enable = true; + + wofi.enable = true; + }; + + services = { + swayidle = { + enable = true; + + timeouts = [ + { timeout = 600; command = "${getExe config.programs.swaylock.package} -fF"; } + ]; + }; + }; + + systemd.user.services.wl-gammarelay-rs = { + Unit.After = [ "sway-session.target" ]; + Install.WantedBy = [ "sway-session.target" ]; + + Service.ExecStart = getExe pkgs.wl-gammarelay-rs; + }; + + wayland.windowManager.sway = { + enable = true; + + config = { + modifier = "Mod4"; + focus.followMouse = false; + + fonts = { + size = 11.0; + names = [ "DejaVu Sans Mono" ]; + style = "Bold Semi-Condensed"; + }; + + bars = singleton { + command = "waybar"; + position = "top"; + }; + + keybindings = + let + mod = config.wayland.windowManager.sway.config.modifier; + wofi = config.programs.wofi.package; + + inherit (pkgs.local) st tmux-lift; + + grimshot = getExe pkgs.sway-contrib.grimshot; + in + mkOptionDefault { + "${mod}+a" = "focus parent"; + "${mod}+c" = "focus child"; + "${mod}+d" = "exec --no-startup-id ${getExe wofi} -S run"; + "${mod}+i" = "exec busctl --user call rs.wl-gammarelay / rs.wl.gammarelay ToggleInverted"; + "${mod}+o" = "exec ${getExe config.programs.swaylock.package} -fF"; + "${mod}+Return" = "exec ${getExe st} -e ${getExe tmux-lift}"; + "${mod}+Shift+e" = "input * xkb_layout latam"; + "${mod}+Shift+u" = "input * xkb_layout us"; + "${mod}+p" = "exec ${grimshot} copy active"; + "${mod}+Shift+p" = "exec ${grimshot} copy area"; + "${mod}+Ctrl+p" = "exec ${grimshot} copy window"; + }; + + startup = [ + { + command = "${getExe pkgs.xautolock} -time 10 -locker '${pkgs.i3lock-color}/bin/i3lock-color -fe -c222222'"; + } + ]; + + window.commands = [ + # (No) Title Bars + { + command = "border pixel 5"; + criteria.class = "^.*"; + } + + { + command = "floating enabled"; + criteria.class = "floating"; + } + ]; + }; + + extraSessionCommands = '' + export SDL_VIDEODRIVER=wayland + # needs qt5.qtwayland in systemPackages + export QT_QPA_PLATFORM=wayland + export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" + # Fix for some Java AWT applications (e.g. Android Studio), + # use this if they aren't displayed properly: + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + + swaynag.enable = true; + systemd.enable = true; + + xwayland = true; + }; + }; +} diff --git a/home/environ.nix b/home/environ.nix deleted file mode 100644 index 60d618a..0000000 --- a/home/environ.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; let - symlink = config.lib.file.mkOutOfStoreSymlink; - - #TODO: No sirve, creo que por readline - devNull = symlink "/dev/null"; -in -{ - config = { - xdg.enable = true; - - systemd.user = { - tmpfiles.rules = [ - "d %t/vtmp 0700" - ]; - - timers = { - units-cur = { - Install.WantedBy = [ "timers.target" ]; - Timer.OnCalendar = "daily"; - Unit.Description = "Update currency information for 'units'"; - }; - }; - - services = { - units-cur = { - Unit.Description = "Update currency information for 'units'"; - - Service = { - Type = "exec"; - ExecStart = "${pkgs.units}/bin/units_cur .units"; - }; - }; - }; - }; - - home.file = { - #TODO: .calc_history - "vtmp".source = symlink "/run/user/${toString config.local.uid}/vtmp"; - ".units_history".source = devNull; - }; - - programs = { - zsh = { - enable = true; - autosuggestion.enable = true; - syntaxHighlighting.enable = true; - initExtra = import ./zshrc.nix pkgs; - }; - - neovim = { - enable = true; - - viAlias = true; - vimAlias = true; - withRuby = false; - withPython3 = false; - - extraConfig = '' - set number " Enable line numbering - set relativenumber " Enable relative line numbering - set tabstop=4 " Set tap stop to 4 - set shiftwidth=4 " Set shift width to 4 (same as tabstop) - set viminfo= " No tracking - ''; - }; - }; - - xdg.configFile."home-manager" = mkIf (!config.home.isolation.active) { - source = symlink "${config.home.homeDirectory}/nix"; - }; - }; -} diff --git a/home/environ/default.nix b/home/environ/default.nix new file mode 100644 index 0000000..53841f1 --- /dev/null +++ b/home/environ/default.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +with lib; { + imports = [ + ./gpg.nix + ./pass.nix + ./path.nix + ./source.nix + ./ssh.nix + ./tmux.nix + ./units.nix + ./vtmp.nix + ]; + + options.local.environ = { + enable = mkEnableOption "local environment"; + }; +} diff --git a/home/environ/gpg.nix b/home/environ/gpg.nix new file mode 100644 index 0000000..dd58181 --- /dev/null +++ b/home/environ/gpg.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; +in +{ + config = mkIf cfg.enable { + programs.gpg = { + enable = true; + scdaemonSettings.disable-ccid = true; + }; + + services.gpg-agent = { + enable = true; + + enableBashIntegration = true; + enableZshIntegration = true; + + enableExtraSocket = true; + enableSshSupport = true; + + defaultCacheTtl = 3600 * 3; + defaultCacheTtlSsh = 3600 * 3; + + maxCacheTtl = 3600 * 6; + maxCacheTtlSsh = 3600 * 6; + + pinentryPackage = pkgs.pinentry-gtk2; + }; + }; +} diff --git a/home/environ/pass.nix b/home/environ/pass.nix new file mode 100644 index 0000000..69947a7 --- /dev/null +++ b/home/environ/pass.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; +in +{ + config = mkIf cfg.enable { + programs.password-store = { + enable = true; + package = pkgs.pass.withExtensions (exts: (with exts; [ + pass-audit + pass-genphrase + pass-otp + pass-tomb + pass-update + ]) ++ [ + pkgs.local.pass-bcr + ]); + + settings = { + PASSWORD_STORE_DIR = "${config.home.homeDirectory}/pass"; + PASSWORD_STORE_TOMB_KEY = "${config.home.homeDirectory}/tomb/pass.key.gpg"; + PASSWORD_STORE_TOMB_FILE = "${config.home.homeDirectory}/tomb/pass.tomb"; + }; + }; + }; +} diff --git a/home/environ/path.nix b/home/environ/path.nix new file mode 100644 index 0000000..3d7d455 --- /dev/null +++ b/home/environ/path.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; + + py = pkgs.python3Packages; +in +{ + config = mkIf cfg.enable { + home.packages = [ + pkgs.calc + pkgs.cloc + pkgs.gcc + pkgs.gnome-screenshot + pkgs.loupe # 'gpicview' has been removed due to lack of maintenance upstream + pkgs.gruvbox-dark-icons-gtk + pkgs.hack-font + pkgs.i3-gaps + pkgs.imagemagick + py.ipython + pkgs.jq + pkgs.libreoffice-fresh + pkgs.lsof + pkgs.mosh + pkgs.mpv + pkgs.libsForQt5.okular + pkgs.pavucontrol + pkgs.pciutils + py.python + pkgs.rustup + pkgs.local.scripts + pkgs.local.st + pkgs.tdesktop + pkgs.local.tmux-lift + pkgs.teams-for-linux + pkgs.tomb + pkgs.units + pkgs.usbutils + pkgs.wl-clipboard + pkgs.xsel + pkgs.xournalpp + pkgs.yubikey-manager + pkgs.zoom-us + ]; + }; +} diff --git a/home/environ/source.nix b/home/environ/source.nix new file mode 100644 index 0000000..ed9f53c --- /dev/null +++ b/home/environ/source.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; + + py = pkgs.python3Packages; +in +{ + config = mkIf cfg.enable { + nix.registry."system".to = { + type = "path"; + path = "${config.home.homeDirectory}/nix"; + }; + + programs = { + git.signing.signByDefault = true; + home-manager.enable = true; + }; + + xdg.configFile."home-manager" = { + source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix"; + }; + }; +} diff --git a/home/environ/ssh-match.nix b/home/environ/ssh-match.nix new file mode 100644 index 0000000..1bb3788 --- /dev/null +++ b/home/environ/ssh-match.nix @@ -0,0 +1 @@ +# This file has been lustrated. diff --git a/home/environ/ssh.nix b/home/environ/ssh.nix new file mode 100644 index 0000000..29829be --- /dev/null +++ b/home/environ/ssh.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; +in +{ + config = mkIf cfg.enable { + programs.ssh = { + enable = true; + + compression = true; + controlMaster = "autoask"; + controlPath = "/run/user/%i/ssh/master-%r@%n:%p"; + + extraOptionOverrides.AddKeysToAgent = "true"; + + matchBlocks = import ./ssh-match.nix; + }; + + systemd.user.tmpfiles.rules = [ + "d %t/ssh 0700" + ]; + }; +} diff --git a/home/environ/tmux.nix b/home/environ/tmux.nix new file mode 100644 index 0000000..223851d --- /dev/null +++ b/home/environ/tmux.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; +in +{ + options.local.environ.tmuxPass = { + enable = mkEnableOption "tmux-pass plugin"; + }; + + config = mkIf cfg.enable { + programs.tmux = { + enable = true; + aggressiveResize = true; + clock24 = true; + escapeTime = 10; + terminal = "xterm-256color"; + keyMode = "vi"; + + plugins = optional cfg.tmuxPass.enable { + plugin = pkgs.local.tmux-pass; + extraConfig = '' + set -g @pass-key BSpace + set -g @pass-copy-to-clipboard on + set -g @pass-window-size 15 + set -g @pass-hide-pw-from-preview 'on' + set -g @pass-hide-preview on + ''; + }; + + extraConfig = '' + set -g mouse on + set -ga update-environment " LIFT_PID" + set -g set-titles on + set -g renumber-windows on + set -sa terminal-overrides ',xterm-termite:RGB' + set -g status-right "#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,} %H:%M %d-%b-%y" + bind-key X set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}" + ''; + }; + }; +} diff --git a/home/environ/units.nix b/home/environ/units.nix new file mode 100644 index 0000000..bb039b7 --- /dev/null +++ b/home/environ/units.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: +with lib; let + cfg = config.local.environ; +in +{ + config = mkIf cfg.enable { + systemd.user = { + timers = { + units-cur = { + Install.WantedBy = [ "timers.target" ]; + Timer.OnCalendar = "daily"; + Unit.Description = "Update currency information for 'units'"; + }; + }; + + services = { + units-cur = { + Unit.Description = "Update currency information for 'units'"; + + Service = { + Type = "exec"; + ExecStart = "${pkgs.units}/bin/units_cur .units"; + }; + }; + }; + }; + + home.file = { + #TODO: .calc_history + ".units_history".source = config.lib.file.mkOutOfStoreSymlink "/dev/null"; + }; + }; +} diff --git a/home/environ/vtmp.nix b/home/environ/vtmp.nix new file mode 100644 index 0000000..9481b6f --- /dev/null +++ b/home/environ/vtmp.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: +with lib; let + cfg = config.local.environ; +in +{ + config = mkIf cfg.enable { + systemd.user.tmpfiles.rules = [ + "d %t/vtmp 0700" + ]; + + home.file = { + "vtmp".source = config.lib.file.mkOutOfStoreSymlink "/run/user/${toString config.local.uid}/vtmp"; + }; + + gtk.gtk3.bookmarks = [ + "file://${config.home.homeDirectory}/vtmp" + "file://${config.home.homeDirectory}/tmp" + ]; + }; +} diff --git a/home/git.nix b/home/git.nix deleted file mode 100644 index de108ed..0000000 --- a/home/git.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config = { - programs.git = { - enable = true; - userName = "Alejandro Soto"; - userEmail = "alejandro@34project.org"; - - signing = mkIf (!config.home.isolation.active) { - signByDefault = true; - }; - }; - }; -} diff --git a/home/gpg.nix b/home/gpg.nix deleted file mode 100644 index 9117c1f..0000000 --- a/home/gpg.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config = mkIf (!config.home.isolation.active) { - programs.gpg = { - enable = true; - scdaemonSettings.disable-ccid = true; - }; - - services.gpg-agent = { - enable = true; - - enableBashIntegration = true; - enableZshIntegration = true; - - enableExtraSocket = true; - enableSshSupport = true; - - defaultCacheTtl = 3600 * 3; - defaultCacheTtlSsh = 3600 * 3; - - maxCacheTtl = 3600 * 6; - maxCacheTtlSsh = 3600 * 6; - - pinentryPackage = pkgs.pinentry-gtk2; - }; - }; -} diff --git a/home/graphics.nix b/home/graphics.nix deleted file mode 100644 index f964a7b..0000000 --- a/home/graphics.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config = { - fonts.fontconfig.enable = true; - - gtk = { - enable = true; - gtk3.bookmarks = [ "file:///home/ale/vtmp" "file:///home/ale/tmp" ]; - - gtk2.extraConfig = '' - gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ - gtk-menu-images=1 - gtk-button-images=1 - ''; - - font = { - package = pkgs.noto-fonts; - name = "Noto Sans Regular"; - #size = 14; <- caga layout de páginas - }; - - theme = { - package = pkgs.materia-theme; - name = "Materia-dark"; - }; - }; - - qt.enable = true; - }; -} diff --git a/home/isolation.nix b/home/isolation.nix deleted file mode 100644 index 5a15468..0000000 --- a/home/isolation.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ lib, ... }: -with lib; { - home.isolation = { - enable = true; - btrfsSupport = true; - - defaults = { - static = false; - bindHome = "home"; - - persist = { - base = "shenvs"; - btrfs = true; - }; - }; - - modulesUnder = ./shenvs; - }; -} diff --git a/home/isolation/default.nix b/home/isolation/default.nix new file mode 100644 index 0000000..d5d2979 --- /dev/null +++ b/home/isolation/default.nix @@ -0,0 +1,34 @@ +{ config, lib, ... }: +with lib; let + cfg = config.local.shenvs; +in +{ + options.local.shenvs = { + enable = mkEnableOption "hm-isolation shenvs"; + }; + + config = mkIf cfg.enable { + home.isolation = { + enable = true; + btrfsSupport = true; + + defaults = { + static = false; + bindHome = "home"; + + persist = { + base = "shenvs"; + btrfs = true; + }; + }; + + modulesUnder = ../shenvs; + }; + + local = mkIf config.home.isolation.active { + desktop.enable = mkForce false; + environ.enable = mkForce false; + mail.enable = mkForce false; + }; + }; +} diff --git a/home/mail/default.nix b/home/mail/default.nix index 06d1225..f070b2f 100644 --- a/home/mail/default.nix +++ b/home/mail/default.nix @@ -1,6 +1,11 @@ { config, lib, pkgs, ... }: -with lib; { +with lib; let + cfg = config.local.mail; +in +{ options.local.mail = with types; { + enable = mkEnableOption "mail"; + address = mkOption { type = str; }; @@ -12,7 +17,7 @@ with lib; { sieve.enable = mkEnableOption "sieve filter"; }; - config = mkIf (!config.home.isolation.active) { + config = mkIf cfg.enable { accounts.email = { maildirBasePath = "mail"; diff --git a/home/pass.nix b/home/pass.nix deleted file mode 100644 index cc05869..0000000 --- a/home/pass.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config.programs.password-store = mkIf (!config.home.isolation.active) { - enable = true; - package = pkgs.pass.withExtensions (exts: (with exts; [ - pass-audit - pass-genphrase - pass-otp - pass-tomb - pass-update - ]) ++ [ - pkgs.local.pass-bcr - ]); - - settings = { - PASSWORD_STORE_DIR = "${config.home.homeDirectory}/pass"; - PASSWORD_STORE_TOMB_KEY = "${config.home.homeDirectory}/tomb/pass.key.gpg"; - PASSWORD_STORE_TOMB_FILE = "${config.home.homeDirectory}/tomb/pass.tomb"; - }; - }; -} diff --git a/home/path.nix b/home/path.nix deleted file mode 100644 index acacdbe..0000000 --- a/home/path.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - home.packages = - let - py = pkgs.python3Packages; - in - [ - pkgs.file - pkgs.killall - pkgs.man-pages - pkgs.man-pages-posix - pkgs.tree - pkgs.unzip - pkgs.wget - pkgs.zip - ] ++ optionals (!config.home.isolation.active) [ - pkgs.calc - pkgs.cloc - pkgs.gcc - pkgs.gnome-screenshot - pkgs.loupe # 'gpicview' has been removed due to lack of maintenance upstream - pkgs.gruvbox-dark-icons-gtk - pkgs.hack-font - pkgs.i3-gaps - pkgs.imagemagick - py.ipython - pkgs.jq - pkgs.libreoffice-fresh - pkgs.lsof - pkgs.mosh - pkgs.mpv - pkgs.libsForQt5.okular - pkgs.pavucontrol - pkgs.pciutils - py.python - pkgs.rustup - pkgs.local.scripts - pkgs.local.st - pkgs.tdesktop - pkgs.local.tmux-lift - pkgs.teams-for-linux - pkgs.tomb - pkgs.units - pkgs.usbutils - pkgs.wl-clipboard - pkgs.xsel - pkgs.xournalpp - pkgs.yubikey-manager - pkgs.zoom-us - ]; -} diff --git a/home/ssh/default.nix b/home/ssh/default.nix deleted file mode 100644 index 220d18d..0000000 --- a/home/ssh/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; { - config = { - programs.ssh = mkIf (!config.home.isolation.active) { - enable = true; - - compression = true; - controlMaster = "autoask"; - controlPath = "/run/user/%i/ssh/master-%r@%n:%p"; - - extraOptionOverrides.AddKeysToAgent = "true"; - - matchBlocks = import ./match.nix; - }; - - systemd.user.tmpfiles.rules = [ - "d %t/ssh 0700" - ]; - }; -} diff --git a/home/ssh/match.nix b/home/ssh/match.nix deleted file mode 100644 index 4209e9b..0000000 --- a/home/ssh/match.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ - "34" = { - hostname = "34project.org"; - port = 2234; - serverAliveInterval = 30; - }; - - "gate.34project.org" = { - serverAliveInterval = 30; - }; - - "hv" = { - port = 2242; - hostname = "::1"; - - user = "root"; - identityFile = "~/.ssh/id_hv_sk"; - identitiesOnly = true; - }; - - "olger.dev" = { - hostname = "201.205.177.184"; - port = 1025; - }; - - "ramips" = { - hostname = "10.34.42.1"; - user = "root"; - }; - - "eric-8100" = { - hostname = "10.34.42.43"; - user = "admin"; - }; - - "hackintosh" = { - hostname = "10.34.42.44"; - user = "ileana"; - }; - - "ramips-lan" = { - hostname = "192.168.34.1"; - user = "root"; - }; - - "xiaomi-lan" = { - hostname = "192.168.42.6"; - user = "u0_a89"; - port = 8022; - }; - - "eric-8100-lan" = { - hostname = "192.168.42.18"; - user = "admin"; - }; - - "github.com" = { - identitiesOnly = true; - identityFile = "~/.ssh/id_rsa"; - user = "git"; - }; - - # Cambiar esto por "itcr3442@github.com" (matchBlocks.*.match aparecerá en 23.05) - "github-itcr" = { - identitiesOnly = true; - identityFile = "~/.ssh/id_klein"; - user = "git"; - hostname = "github.com"; - }; - - "kiev" = { - user = "u0_a177"; - port = 8022; - hostname = "10.34.42.2"; - }; - - "kiev-lan" = { - user = "u0_a177"; - port = 8022; - hostname = "192.168.34.211"; - }; -} diff --git a/home/zshrc.nix b/home/zshrc.nix deleted file mode 100644 index a82ab7a..0000000 --- a/home/zshrc.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ grml-zsh-config, local, ... }: '' - source ${grml-zsh-config}/etc/zsh/zshrc - - export PATH="$PATH:$HOME/.cargo/bin" - - alias reset='tput reset' - alias reload='exec zsh' - alias this-date='date +%b%d | sed "s/^\w/\U&/g"' - - function spawn() { - if [ ! -x "$(command -v $1)" ]; then - echo "spawn: no such command: $1" >&2 - return 1 - fi - - $@ >/dev/null 0>&1 2>&1 & - disown - } - - function xseli() { - T=$(mktemp) - $EDITOR -n $T - xsel -b <$T - rm $T - } - - autoload -Uz up-line-or-beginning-search - zle -N up-line-or-beginning-search - autoload -Uz down-line-or-beginning-search - zle -N down-line-or-beginning-search - bindkey '\eOA' up-line-or-beginning-search - bindkey '\e[A' up-line-or-beginning-search - bindkey '\eOB' down-line-or-beginning-search - bindkey '\e[B' down-line-or-beginning-search - - INSTALLABLES=() - while read -d: PATH_ITEM; do - if [[ "$PATH_ITEM" =~ "^(/nix/store/[a-z0-9]+-([a-zA-Z][a-zA-Z0-9_]*(-[a-zA-Z][a-zA-Z0-9_]*)*)(-[^/]+)?)/" ]]; then - INSTALLABLES+=("''${match[2]}") - fi - done <<<"$PATH" - - if [ "''${#INSTALLABLES[@]}" -gt 0 ]; then - _GRML_NIX_SHELL="{''${INSTALLABLES[@]}} " - fi - - unset INSTALLABLES PATH_ITEM - - function grml_nix_shell() { - REPLY="$_GRML_NIX_SHELL" - } - - grml_theme_add_token nix-shell -f grml_nix_shell '%F{red}' '%f' - - zstyle ':prompt:grml:left:setup' items $([ ''${NO_USERATHOST:-0} -gt 0 ] || echo user at host) path nix-shell percent - zstyle ':prompt:grml:right:setup' items sad-smiley vcs $([ ''${NO_BATTERY:-0} -gt 0 ] || echo battery) time - zstyle ':prompt:grml:right:items:time' pre ' %F{yellow}' - - unsetopt sharehistory - setopt appendhistory - setopt extendedhistory - - source ${local.git-aliases} -'' -- cgit v1.2.3