From 881b22c9b2ae1971f4d17fbc520ddfeda606f2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 8 Jan 2024 21:48:31 +0100 Subject: [PATCH] Move gpg, git, tmux/screen to separate file --- hm/common.nix | 135 +--------------------------------------- hm/default.nix | 3 + hm/desktop/i3.nix | 1 + hm/git/default.nix | 74 ++++++++++++++++++++++ hm/gpg/default.nix | 40 ++++++++++++ hm/style.nix | 5 -- hm/tmux/default.nix | 34 ++++++++++ hm/{ => tmux}/screenrc | 0 hm/{ => tmux}/tmux.conf | 0 9 files changed, 155 insertions(+), 137 deletions(-) create mode 100644 hm/git/default.nix create mode 100644 hm/gpg/default.nix create mode 100644 hm/tmux/default.nix rename hm/{ => tmux}/screenrc (100%) rename hm/{ => tmux}/tmux.conf (100%) diff --git a/hm/common.nix b/hm/common.nix index 507f0a8..5108f09 100644 --- a/hm/common.nix +++ b/hm/common.nix @@ -213,37 +213,8 @@ in echo -en "\033]0; $USER@$HOST $PWD\007" ''; }; - gpg = { - enable = true; - homedir = "${config.xdg.stateHome}/gnupg"; - settings = { - # Remove fluff - no-greeting = true; - no-emit-version = true; - no-comments = true; - # Output format that I prefer - keyid-format = "0xlong"; - # Show fingerprints - with-fingerprint = true; - # Make sure to show if key is invalid - # (should be default on most platform, - # but just to be sure) - list-options = "show-uid-validity"; - verify-options = "show-uid-validity"; - # Stronger algorithm (https://wiki.archlinux.org/title/GnuPG#Different_algorithm) - personal-digest-preferences = "SHA512"; - cert-digest-algo = "SHA512"; - default-preference-list = "SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed"; - personal-cipher-preferences = "TWOFISH CAMELLIA256 AES 3DES"; - }; - publicKeys = [{ - source = builtins.fetchurl { - url = "https://keys.openpgp.org/vks/v1/by-fingerprint/4FBA930D314A03215E2CDB0A8312C8CAC1BAC289"; - sha256 = "sha256:10y9xqcy1vyk2p8baay14p3vwdnlwynk0fvfbika65hz2z8yw2cm"; - }; - trust = "ultimate"; - }]; - }; + git.enable = true; + gpg.enable = true; fzf = { enable = true; enableZshIntegration = true; @@ -259,46 +230,6 @@ in enableZshIntegration = true; }; less.enable = true; - git = { - enable = true; - package = pkgs.gitFull; - aliases = { - "git" = "!exec git"; # In case I write one too many git - }; - ignores = [ - "*.swp" - "*.swo" - "*.ycm_extra_conf.py" - "tags" - ".mypy_cache" - ]; - delta = { - enable = true; - options = { - line-numbers = true; - syntax-theme = "base16"; - }; - }; - lfs.enable = true; - userEmail = lib.mkDefault "geoffrey@frogeye.fr"; - userName = lib.mkDefault "Geoffrey Frogeye"; - extraConfig = { - core = { - editor = "nvim"; - }; - push = { - default = "matching"; - }; - pull = { - ff = "only"; - }; - } // lib.optionalAttrs config.frogeye.desktop.xorg { - diff.tool = "meld"; - difftool.prompt = false; - "difftool \"meld\"".cmd = "${pkgs.meld}/bin/meld \"$LOCAL\" \"$REMOTE\""; - # This escapes quotes, which isn't the case in the original, hoping this isn't an issue. - }; - }; readline = { enable = true; variables = { @@ -327,50 +258,10 @@ in }; extraConfig = builtins.readFile ./inputrc; }; - tmux = - let - themepack = pkgs.tmuxPlugins.mkTmuxPlugin - rec { - pluginName = "tmux-themepack"; - version = "1.1.0"; - rtpFilePath = "themepack.tmux"; - src = pkgs.fetchFromGitHub { - owner = "jimeh"; - repo = "tmux-themepack"; - rev = "${version}"; - sha256 = "f6y92kYsKDFanNx5ATx4BkaB/E7UrmyIHU/5Z01otQE="; - }; - }; - in - { - enable = true; - mouse = false; - clock24 = true; - # TODO Vim mode? - plugins = with pkgs.tmuxPlugins; [ - sensible - ]; - extraConfig = builtins.readFile ./tmux.conf + "source-file ${themepack}/share/tmux-plugins/tmux-themepack/powerline/default/green.tmuxtheme\n"; - }; + tmux.enable = true; translate-shell.enable = true; # TODO Cool config? password-store.enable = true; }; - services = { - gpg-agent = { - enableBashIntegration = true; - enableZshIntegration = true; - }; - git-sync = { - enable = false; # The real thing syncs too quickly and asks for passphrase, which is annoying - # So for now it's just a way to park config which will be reused by git-sync-* commands - repositories = { - dotfiles = { - path = "${config.xdg.configHome}/dotfiles"; - uri = lib.mkDefault "https://git.frogeye.fr/geoffrey/dotfiles.git"; - }; - }; - }; - }; xdg = { configFile = { "ccache.conf" = { @@ -397,9 +288,6 @@ in "pythonstartup.py" = { text = (builtins.readFile ./pythonstartup.py); }; - "screenrc" = { - text = (builtins.readFile ./screenrc); - }; }; }; home = { @@ -478,22 +366,6 @@ in # password pwgen - (pkgs.writeShellApplication { - name = "git-sync-init"; - text = (lib.strings.concatLines - (map (r: ''[ -d "${r.path}" ] || ${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"'') - (lib.attrsets.attrValues config.services.git-sync.repositories) - ) - ); - }) - (pkgs.writeShellApplication { - name = "git-sync-pull"; - text = (lib.strings.concatLines - (map (r: ''(cd "${r.path}"; echo "$PWD"; ${pkgs.git}/bin/git pull || true)'') - (lib.attrsets.attrValues config.services.git-sync.repositories) - ) - ); - }) ]; sessionVariables = { # Favourite commands @@ -509,7 +381,6 @@ in PYTHONSTARTUP = "${config.xdg.configHome}/pythonstartup.py"; # TODO I think we're not using the urxvt daemon on purpose? # TODO this should be desktop only, as a few things are too. - SCREENRC = "${config.xdg.configHome}/screenrc"; SQLITE_HISTFILE = "${config.xdg.stateHome}/sqlite_history"; YARN_DISABLE_SELF_UPDATE_CHECK = "true"; # This also disable the creation of a ~/.yarnrc file } // lib.optionalAttrs config.frogeye.desktop.xorg { diff --git a/hm/default.nix b/hm/default.nix index 978ddc0..b3cd5c2 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -7,9 +7,12 @@ ./dev.nix ./extra.nix ./gaming + ./git + ./gpg ./rebuild ./ssh.nix ./style.nix + ./tmux ./usernix ./vim.nix ]; diff --git a/hm/desktop/i3.nix b/hm/desktop/i3.nix index c5dabe4..91d2459 100644 --- a/hm/desktop/i3.nix +++ b/hm/desktop/i3.nix @@ -53,6 +53,7 @@ let in { config = lib.mkIf config.xsession.windowManager.i3.enable { + stylix.targets.i3.enable = false; xsession.windowManager.i3.config = { modifier = "Mod4"; fonts = { diff --git a/hm/git/default.nix b/hm/git/default.nix new file mode 100644 index 0000000..39897b9 --- /dev/null +++ b/hm/git/default.nix @@ -0,0 +1,74 @@ +{ pkgs, lib, config, ... }: +{ + config = lib.mkIf config.programs.git.enable { + home.packages = [ + (pkgs.writeShellApplication { + name = "git-sync-init"; + text = (lib.strings.concatLines + (map (r: ''[ -d "${r.path}" ] || ${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"'') + (lib.attrsets.attrValues config.services.git-sync.repositories) + ) + ); + }) + (pkgs.writeShellApplication { + name = "git-sync-pull"; + text = (lib.strings.concatLines + (map (r: ''(cd "${r.path}"; echo "$PWD"; ${pkgs.git}/bin/git pull || true)'') + (lib.attrsets.attrValues config.services.git-sync.repositories) + ) + ); + }) + ]; + programs.git = { + package = pkgs.gitFull; + aliases = { + "git" = "!exec git"; # In case I write one too many git + }; + ignores = [ + "*.swp" + "*.swo" + "*.ycm_extra_conf.py" + "tags" + ".mypy_cache" + ]; + delta = { + enable = true; + options = { + line-numbers = true; + syntax-theme = "base16"; + }; + }; + lfs.enable = true; + userEmail = lib.mkDefault "geoffrey@frogeye.fr"; + userName = lib.mkDefault "Geoffrey Frogeye"; + extraConfig = { + core = { + editor = "nvim"; + }; + push = { + default = "matching"; + }; + pull = { + ff = "only"; + }; + } // lib.optionalAttrs config.frogeye.desktop.xorg { + diff.tool = "meld"; + difftool.prompt = false; + "difftool \"meld\"".cmd = "${pkgs.meld}/bin/meld \"$LOCAL\" \"$REMOTE\""; + # This escapes quotes, which isn't the case in the original, hoping this isn't an issue. + }; + }; + services = { + git-sync = { + enable = false; # The real thing syncs too quickly and asks for passphrase, which is annoying + # So for now it's just a way to park config which will be reused by git-sync-* commands + repositories = { + dotfiles = { + path = "${config.xdg.configHome}/dotfiles"; + uri = lib.mkDefault "https://git.frogeye.fr/geoffrey/dotfiles.git"; + }; + }; + }; + }; + }; +} diff --git a/hm/gpg/default.nix b/hm/gpg/default.nix new file mode 100644 index 0000000..2b0d53a --- /dev/null +++ b/hm/gpg/default.nix @@ -0,0 +1,40 @@ +{ pkgs, lib, config, ... }: +{ + config = lib.mkIf config.programs.gpg.enable { + programs.gpg = { + homedir = "${config.xdg.stateHome}/gnupg"; + settings = { + # Remove fluff + no-greeting = true; + no-emit-version = true; + no-comments = true; + # Output format that I prefer + keyid-format = "0xlong"; + # Show fingerprints + with-fingerprint = true; + # Make sure to show if key is invalid + # (should be default on most platform, + # but just to be sure) + list-options = "show-uid-validity"; + verify-options = "show-uid-validity"; + # Stronger algorithm (https://wiki.archlinux.org/title/GnuPG#Different_algorithm) + personal-digest-preferences = "SHA512"; + cert-digest-algo = "SHA512"; + default-preference-list = "SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed"; + personal-cipher-preferences = "TWOFISH CAMELLIA256 AES 3DES"; + }; + publicKeys = [{ + source = builtins.fetchurl { + url = "https://keys.openpgp.org/vks/v1/by-fingerprint/4FBA930D314A03215E2CDB0A8312C8CAC1BAC289"; + sha256 = "sha256:10y9xqcy1vyk2p8baay14p3vwdnlwynk0fvfbika65hz2z8yw2cm"; + }; + trust = "ultimate"; + }]; + }; + services.gpg-agent = { + enableBashIntegration = true; + enableZshIntegration = true; + }; + }; + +} diff --git a/hm/style.nix b/hm/style.nix index 005dbea..28fd0bf 100644 --- a/hm/style.nix +++ b/hm/style.nix @@ -26,11 +26,6 @@ in name = "DejaVuSansM Nerd Font"; }; }; - - targets = { - i3.enable = false; # I prefer my own styles - tmux.enable = false; # Using another theme - }; }; diff --git a/hm/tmux/default.nix b/hm/tmux/default.nix new file mode 100644 index 0000000..b6724ce --- /dev/null +++ b/hm/tmux/default.nix @@ -0,0 +1,34 @@ +{ pkgs, lib, config, ... }: +let + themepack = pkgs.tmuxPlugins.mkTmuxPlugin + rec { + pluginName = "tmux-themepack"; + version = "1.1.0"; + rtpFilePath = "themepack.tmux"; + src = pkgs.fetchFromGitHub { + owner = "jimeh"; + repo = "tmux-themepack"; + rev = "${version}"; + sha256 = "f6y92kYsKDFanNx5ATx4BkaB/E7UrmyIHU/5Z01otQE="; + }; + }; +in +{ + config = lib.mkIf config.programs.tmux.enable { + home = { + packages = [ pkgs.screen ]; + sessionVariables.SCREENRC = "${config.xdg.configHome}/screenrc"; + }; + programs.tmux = { + mouse = false; + clock24 = true; + # TODO Vim mode? + plugins = with pkgs.tmuxPlugins; [ + sensible + ]; + extraConfig = builtins.readFile ./tmux.conf + "source-file ${themepack}/share/tmux-plugins/tmux-themepack/powerline/default/green.tmuxtheme\n"; + }; + stylix.targets.tmux.enable = false; + xdg.configFile.screenrc.text = (builtins.readFile ./screenrc); + }; +} diff --git a/hm/screenrc b/hm/tmux/screenrc similarity index 100% rename from hm/screenrc rename to hm/tmux/screenrc diff --git a/hm/tmux.conf b/hm/tmux/tmux.conf similarity index 100% rename from hm/tmux.conf rename to hm/tmux/tmux.conf