From 495f31e58f42e2495e5a443fdc10858b3a111d2f Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 8 Apr 2024 01:57:57 +0900 Subject: [PATCH 1/3] Prefer upstream channel for plemoljp-nf Follow #552 --- flake.lock | 19 +------------------ flake.nix | 7 +------ home-manager/packages.nix | 4 ++-- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/flake.lock b/flake.lock index 3b404afe..a00aa9d0 100644 --- a/flake.lock +++ b/flake.lock @@ -71,29 +71,12 @@ "type": "github" } }, - "plemoljp-nixpkgs": { - "locked": { - "lastModified": 1712180235, - "narHash": "sha256-SoVHji39cMcAsH872HFPppzOgRnCVVS/vloXSWOnvk4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fe6c0ea25c89b9efe12d1fcd236c8b1432b36967", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fe6c0ea25c89b9efe12d1fcd236c8b1432b36967", - "type": "github" - } - }, "root": { "inputs": { "edge-nixpkgs": "edge-nixpkgs", "flake-utils": "flake-utils", "home-manager": "home-manager", - "nixpkgs": "nixpkgs", - "plemoljp-nixpkgs": "plemoljp-nixpkgs" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index 020fde1a..e829ae66 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,6 @@ # - `nix flake update --commit-lock-file` # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-update.html nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; edge-nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - plemoljp-nixpkgs.url = "github:NixOS/nixpkgs/fe6c0ea25c89b9efe12d1fcd236c8b1432b36967"; flake-utils.url = "github:numtide/flake-utils"; # https://github.com/nix-community/home-manager/blob/release-23.11/docs/manual/nix-flakes.md home-manager = { @@ -16,12 +15,11 @@ }; }; - outputs = { self, nixpkgs, edge-nixpkgs, home-manager, flake-utils, plemoljp-nixpkgs }: + outputs = { self, nixpkgs, edge-nixpkgs, home-manager, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; edge-pkgs = edge-nixpkgs.legacyPackages.${system}; - edge-fonts-pkgs = plemoljp-nixpkgs.legacyPackages.${system}; in rec { # Q. Why nixpkgs-fmt? Not nixfmt? and alejandra? @@ -62,7 +60,6 @@ modules = [ ./home-manager/kachick.nix ]; extraSpecialArgs = { inherit edge-pkgs; - inherit edge-fonts-pkgs; }; }; @@ -76,7 +73,6 @@ ]; extraSpecialArgs = { inherit edge-pkgs; - inherit edge-fonts-pkgs; }; }; @@ -91,7 +87,6 @@ ]; extraSpecialArgs = { inherit edge-pkgs; - inherit edge-fonts-pkgs; }; }; }; diff --git a/home-manager/packages.nix b/home-manager/packages.nix index 4df3ce10..11efa315 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -1,4 +1,4 @@ -{ pkgs, edge-pkgs, edge-fonts-pkgs, lib, ... }: +{ pkgs, edge-pkgs, lib, ... }: { # Prefer stable pkgs as possible, if you want to use edge pkgs @@ -96,7 +96,7 @@ # You can also use 0 = `Slashed zero style` with enabling `"editor.fontLigatures": "'zero'"` in vscode # but cannot use it in alacritty https://github.com/alacritty/alacritty/issues/50 - edge-fonts-pkgs.plemoljp-nf + edge-pkgs.plemoljp-nf pkgs.ibm-plex # For sans-serif, use plemoljp for developing pkgs.source-han-code-jp # Includes many definitions, useful for fallback From 90f176b4075e2e5141ce843c2b922667196fe619 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 8 Apr 2024 02:04:03 +0900 Subject: [PATCH 2/3] Replace nixfmt(nixfmt-classic) with nixfmt-rfc-style ``` trace: warning: nixfmt was renamed to nixfmt-classic. The nixfmt attribute may be used for the new RFC 166-style formatter in the future, which is currently available as nixfmt-rfc-style ``` Print the nixfmt-rfc-style version in deps command --- cmd/deps/main.go | 7 +++++++ flake.nix | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/deps/main.go b/cmd/deps/main.go index aedecaef..22966a4f 100644 --- a/cmd/deps/main.go +++ b/cmd/deps/main.go @@ -17,7 +17,14 @@ func main() { {Path: "typos", Args: []string{"--version"}}, {Path: "gitleaks", Args: []string{"version"}}, {Path: "goreleaser", Args: []string{"--version"}}, + + // Even if nixfmt returns old version as v0.5.0, the actual code is latest + // https://github.com/NixOS/nixpkgs/pull/292625/files#diff-cf53ba433c9a367969e739cd32bc5a6fb9be271ed0ec604c34a3542a54ff1f5fR9-R12 + {Path: "nixfmt", Args: []string{"--version"}}, + // store path includes the date, but nix develop is too slow + {Path: "bash", Args: []string{"-c", "which nixfmt"}}, } + // No side-effect commands, but keeping sequential for readability cmds.SequentialRun() } diff --git a/flake.nix b/flake.nix index e829ae66..2ad00f17 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 bashInteractive edge-pkgs.nixpkgs-fmt - edge-pkgs.nixfmt # Using a sub formatter + edge-pkgs.nixfmt-rfc-style # Using as a sub formatter for now, the command is still `nixfmt` edge-pkgs.nil # To get sha256 around pkgs.fetchFromGitHub in CLI nix-prefetch-git From 720340cef10fcdc0f6ee1bbf8793769e3ab33575 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 8 Apr 2024 02:37:28 +0900 Subject: [PATCH 3/3] Replace nixpkgs-fmt with nixfmt-rfc-style --- .vscode/settings.json | 2 +- cmd/lint/main.go | 4 +- flake.nix | 85 ++++---- home-manager/bash.nix | 56 +++-- home-manager/common.nix | 54 ++--- home-manager/fish.nix | 66 +++--- home-manager/git.nix | 103 ++++++---- home-manager/gpg.nix | 1 - home-manager/homemade.nix | 415 +++++++++++++++++++------------------- home-manager/kachick.nix | 4 +- home-manager/packages.nix | 254 ++++++++++++----------- home-manager/ssh.nix | 9 +- home-manager/zsh.nix | 22 +- 13 files changed, 574 insertions(+), 501 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 715f1115..bf88441f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,7 @@ "nix.enableLanguageServer": true, "nix.serverSettings": { "nil": { - "formatting": { "command": ["nixpkgs-fmt"] } + "formatting": { "command": ["nixfmt"] } } }, "gopls": { diff --git a/cmd/lint/main.go b/cmd/lint/main.go index 26b6ac31..fd6279b3 100644 --- a/cmd/lint/main.go +++ b/cmd/lint/main.go @@ -12,14 +12,12 @@ func main() { walker := fileutils.GetWalker() bashPaths := walker.GetAllBash() - nixPaths := walker.GetAllNix() cmds := runner.Commands{ {Path: "dprint", Args: []string{"check"}}, {Path: "shfmt", Args: append([]string{"--language-dialect", "bash", "--diff"}, bashPaths...)}, {Path: "shellcheck", Args: bashPaths}, - // nix fmt doesn't have check option: https://github.com/NixOS/nix/issues/6918 - {Path: "nixpkgs-fmt", Args: append([]string{"--check"}, nixPaths...)}, + // nix fmt doesn't have check option: https://github.com/NixOS/nix/issues/6918, so do not include here {Path: "typos", Args: constants.GetTyposTargetedRoots()}, {Path: "gitleaks", Args: []string{"detect"}}, {Path: "go", Args: []string{"vet", "./..."}}, diff --git a/flake.nix b/flake.nix index 2ad00f17..ec5f68bc 100644 --- a/flake.nix +++ b/flake.nix @@ -15,27 +15,34 @@ }; }; - outputs = { self, nixpkgs, edge-nixpkgs, home-manager, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + edge-nixpkgs, + home-manager, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: let pkgs = nixpkgs.legacyPackages.${system}; edge-pkgs = edge-nixpkgs.legacyPackages.${system}; in rec { - # Q. Why nixpkgs-fmt? Not nixfmt? and alejandra? - # A. nixfmt will be official, but too opinionated and non stable now + # nixfmt will be official # - https://github.com/NixOS/nixfmt/issues/153 # - https://github.com/NixOS/nixfmt/issues/129 # - https://github.com/NixOS/rfcs/pull/166 # - https://github.com/NixOS/nixfmt/blob/a81f922a2b362f347a6cbecff5fb14f3052bc25d/README.md#L19 - formatter = edge-pkgs.nixpkgs-fmt; - devShells.default = with pkgs; + formatter = edge-pkgs.nixfmt-rfc-style; + devShells.default = + with pkgs; mkShell { buildInputs = [ # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 bashInteractive - edge-pkgs.nixpkgs-fmt - edge-pkgs.nixfmt-rfc-style # Using as a sub formatter for now, the command is still `nixfmt` + edge-pkgs.nixfmt-rfc-style edge-pkgs.nil # To get sha256 around pkgs.fetchFromGitHub in CLI nix-prefetch-git @@ -91,46 +98,42 @@ }; }; - packages.bump_completions = - pkgs.writeShellScriptBin "bump_completions" '' - set -euo pipefail + packages.bump_completions = pkgs.writeShellScriptBin "bump_completions" '' + set -euo pipefail - ${edge-pkgs.podman}/bin/podman completion bash > ./dependencies/podman/completions.bash - ${edge-pkgs.podman}/bin/podman completion zsh > ./dependencies/podman/completions.zsh - ${edge-pkgs.podman}/bin/podman completion fish > ./dependencies/podman/completions.fish + ${edge-pkgs.podman}/bin/podman completion bash > ./dependencies/podman/completions.bash + ${edge-pkgs.podman}/bin/podman completion zsh > ./dependencies/podman/completions.zsh + ${edge-pkgs.podman}/bin/podman completion fish > ./dependencies/podman/completions.fish - ${edge-pkgs.dprint}/bin/dprint completions bash > ./dependencies/dprint/completions.bash - ${edge-pkgs.dprint}/bin/dprint completions zsh > ./dependencies/dprint/completions.zsh - ${edge-pkgs.dprint}/bin/dprint completions fish > ./dependencies/dprint/completions.fish - ''; + ${edge-pkgs.dprint}/bin/dprint completions bash > ./dependencies/dprint/completions.bash + ${edge-pkgs.dprint}/bin/dprint completions zsh > ./dependencies/dprint/completions.zsh + ${edge-pkgs.dprint}/bin/dprint completions fish > ./dependencies/dprint/completions.fish + ''; - packages.check_no_dirty_xz_in_nix_store = - pkgs.writeShellApplication { - name = "check_no_dirty_xz_in_nix_store"; - runtimeInputs = with pkgs; [ fd ]; - text = '' - # nix store should have xz: https://github.com/NixOS/nixpkgs/blob/b96bc828b81140dd3fb096b4e66a6446d6d5c9dc/doc/stdenv/stdenv.chapter.md?plain=1#L177 - # You can't use --max-results instead of --has-results even if you want the log, it always returns true - fd '^\w+-xz-[0-9\.]+\.drv' --search-path /nix/store --has-results + packages.check_no_dirty_xz_in_nix_store = pkgs.writeShellApplication { + name = "check_no_dirty_xz_in_nix_store"; + runtimeInputs = with pkgs; [ fd ]; + text = '' + # nix store should have xz: https://github.com/NixOS/nixpkgs/blob/b96bc828b81140dd3fb096b4e66a6446d6d5c9dc/doc/stdenv/stdenv.chapter.md?plain=1#L177 + # You can't use --max-results instead of --has-results even if you want the log, it always returns true + fd '^\w+-xz-[0-9\.]+\.drv' --search-path /nix/store --has-results - # Why toggling errexit and return code here: https://github.com/kachick/times_kachick/issues/278 - set +o errexit - fd '^\w+-xz-5\.6\.[01]\.drv' --search-path /nix/store --has-results - fd_return_code="$?" # Do not directly use the $? to prevent feature broken if inserting another command before check - set -o errexit - [[ "$fd_return_code" -eq 1 ]] - ''; - meta = { - description = "Prevent #530 (around CVE-2024-3094)"; - }; + # Why toggling errexit and return code here: https://github.com/kachick/times_kachick/issues/278 + set +o errexit + fd '^\w+-xz-5\.6\.[01]\.drv' --search-path /nix/store --has-results + fd_return_code="$?" # Do not directly use the $? to prevent feature broken if inserting another command before check + set -o errexit + [[ "$fd_return_code" -eq 1 ]] + ''; + meta = { + description = "Prevent #530 (around CVE-2024-3094)"; }; + }; apps = { # example: `nix run .#home-manager -- switch -n -b backup --flake .#kachick` # https://github.com/NixOS/nix/issues/6448#issuecomment-1132855605 - home-manager = flake-utils.lib.mkApp { - drv = home-manager.defaultPackage.${system}; - }; + home-manager = flake-utils.lib.mkApp { drv = home-manager.defaultPackage.${system}; }; bump_completions = { type = "app"; @@ -142,6 +145,6 @@ program = "${packages.check_no_dirty_xz_in_nix_store}/bin/check_no_dirty_xz_in_nix_store"; }; }; - }); + } + ); } - diff --git a/home-manager/bash.nix b/home-manager/bash.nix index 2f5a3bdc..50044ba1 100644 --- a/home-manager/bash.nix +++ b/home-manager/bash.nix @@ -1,4 +1,10 @@ -{ config, lib, pkgs, edge-pkgs, ... }: +{ + config, + lib, + pkgs, + edge-pkgs, + ... +}: { services.gpg-agent.enableBashIntegration = true; @@ -68,9 +74,25 @@ historySize = 100000; historyFile = "${config.xdg.stateHome}/bash/history"; historyFileSize = 4200000; - historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; + historyControl = [ + "erasedups" + "ignoredups" + "ignorespace" + ]; # NOTE: I didn't check it should have different globs as zsh or not, at least the sepelator is not same. - historyIgnore = [ "cd" "pushd" "popd" "z" "ls" "ll" "la" "rm" "rmdir" "git show" "exit" ]; + historyIgnore = [ + "cd" + "pushd" + "popd" + "z" + "ls" + "ll" + "la" + "rm" + "rmdir" + "git show" + "exit" + ]; # Switch to another shell when bash used as a login shell profileExtra = '' @@ -84,23 +106,25 @@ ''; # Extracting because embedded here requires complex escape with nix multiline. - initExtra = '' - # https://github.com/starship/starship/blob/0d98c4c0b7999f5a8bd6e7db68fd27b0696b3bef/docs/uk-UA/advanced-config/README.md#change-window-title - function set_win_title() { - echo -ne "\033]0; $(${lib.getBin pkgs.coreutils}/bin/basename "$PWD") \007" - } - # shellcheck disable=SC2034 - starship_precmd_user_func="set_win_title" + initExtra = + '' + # https://github.com/starship/starship/blob/0d98c4c0b7999f5a8bd6e7db68fd27b0696b3bef/docs/uk-UA/advanced-config/README.md#change-window-title + function set_win_title() { + echo -ne "\033]0; $(${lib.getBin pkgs.coreutils}/bin/basename "$PWD") \007" + } + # shellcheck disable=SC2034 + starship_precmd_user_func="set_win_title" - eval "$(${lib.getExe edge-pkgs.mise} activate bash)" + eval "$(${lib.getExe edge-pkgs.mise} activate bash)" - source "${edge-pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh" + source "${edge-pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh" - source "${../dependencies/podman/completions.bash}" - source "${../dependencies/dprint/completions.bash}" + source "${../dependencies/podman/completions.bash}" + source "${../dependencies/dprint/completions.bash}" - source "${config.xdg.configHome}/posix_shells/shared_functions.sh" - '' + builtins.readFile ./initExtra.bash; + source "${config.xdg.configHome}/posix_shells/shared_functions.sh" + '' + + builtins.readFile ./initExtra.bash; logoutExtra = '' # when leaving the console clear the screen to increase privacy diff --git a/home-manager/common.nix b/home-manager/common.nix index 3797b318..19540252 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -1,4 +1,9 @@ -{ config, pkgs, edge-pkgs, ... }: +{ + config, + pkgs, + edge-pkgs, + ... +}: { imports = [ @@ -14,7 +19,8 @@ # home.username = ""; # TODO: How to cover lima? The default is /home/kachick.local - home.homeDirectory = if pkgs.stdenv.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; + home.homeDirectory = + if pkgs.stdenv.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; # https://github.com/nix-community/home-manager/blob/release-23.11/modules/misc/xdg.nix xdg.enable = true; @@ -124,7 +130,8 @@ ''; xdg.configFile."alacritty/alacritty.toml".source = ../config/alacritty/alacritty-unix.toml; - xdg.configFile."alacritty/unix.toml".source = if pkgs.stdenv.isDarwin then ../config/alacritty/macos.toml else ../config/alacritty/linux.toml; + xdg.configFile."alacritty/unix.toml".source = + if pkgs.stdenv.isDarwin then ../config/alacritty/macos.toml else ../config/alacritty/linux.toml; xdg.configFile."alacritty/common.toml".source = ../config/alacritty/common.toml; xdg.configFile."alacritty/themes" = { source = ../config/alacritty/themes; @@ -145,26 +152,22 @@ # Should have `root = true` in the file. - https://github.com/kachick/anylang-template/blob/45d7ef685ac4fd3836c3b32b8ce8fb45e909b771/.editorconfig#L1 # Intentionally avoided to use https://github.com/nix-community/home-manager/blob/f58889c07efa8e1328fdf93dc1796ec2a5c47f38/modules/misc/editorconfig.nix home.file.".editorconfig".source = - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "anylang-template"; - rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; - sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; - } - + "/.editorconfig" - ; + pkgs.fetchFromGitHub { + owner = "kachick"; + repo = "anylang-template"; + rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; + sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; + } + + "/.editorconfig"; xdg.configFile."irb/irbrc".source = - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "irb-power_assert"; - rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; - sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; - } - + "/examples/.irbrc" - ; + pkgs.fetchFromGitHub { + owner = "kachick"; + repo = "irb-power_assert"; + rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; + sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; + } + + "/examples/.irbrc"; # typos does not have global config feature, this is used in git hooks for https://github.com/kachick/dotfiles/issues/412 xdg.configFile."typos/_typos.toml".source = ../_typos.toml; @@ -188,9 +191,7 @@ # ALT-C changeDirWidgetCommand = "${pkgs.fd}/bin/fd --type d"; - changeDirWidgetOptions = [ - "--preview '${pkgs.eza}/bin/eza --color=always --tree {} | head -200'" - ]; + changeDirWidgetOptions = [ "--preview '${pkgs.eza}/bin/eza --color=always --tree {} | head -200'" ]; }; # https://github.com/nix-community/home-manager/blob/release-23.11/modules/programs/starship.nix @@ -260,7 +261,6 @@ }; }; - # https://github.com/nix-community/home-manager/blob/release-23.11/modules/programs/vim.nix # https://nixos.wiki/wiki/Vim programs.vim = { @@ -268,7 +268,9 @@ # nix-env -f '' -qaP -A vimPlugins plugins = [ pkgs.vimPlugins.iceberg-vim ]; - settings = { background = "dark"; }; + settings = { + background = "dark"; + }; extraConfig = '' colorscheme iceberg set termguicolors diff --git a/home-manager/fish.nix b/home-manager/fish.nix index cf6f04fb..7ef03329 100644 --- a/home-manager/fish.nix +++ b/home-manager/fish.nix @@ -1,4 +1,9 @@ -{ lib, pkgs, edge-pkgs, ... }: +{ + lib, + pkgs, + edge-pkgs, + ... +}: { services.gpg-agent.enableFishIntegration = true; @@ -24,28 +29,27 @@ programs.fish = { enable = true; - shellInit = - '' - switch (uname -s) - case Linux - # Keep this comment - case Darwin - # nix - # https://github.com/NixOS/nix/issues/2280 - if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' - fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' - end - case FreeBSD NetBSD DragonFly - # Keep this comment - case '*' - # Keep this comment - end - + shellInit = '' + switch (uname -s) + case Linux + # Keep this comment + case Darwin # nix - if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" - fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" + # https://github.com/NixOS/nix/issues/2280 + if test -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' + fenv source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' end - ''; + case FreeBSD NetBSD DragonFly + # Keep this comment + case '*' + # Keep this comment + end + + # nix + if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" + fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" + end + ''; interactiveShellInit = '' # I define another la as a homemade scripts @@ -57,14 +61,16 @@ eval "$(${lib.getExe edge-pkgs.mise} activate zsh)" ''; - plugins = [{ - name = "foreign-env"; - src = pkgs.fetchFromGitHub { - owner = "oh-my-fish"; - repo = "plugin-foreign-env"; - rev = "3ee95536106c11073d6ff466c1681cde31001383"; - sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; - }; - }]; + plugins = [ + { + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "3ee95536106c11073d6ff466c1681cde31001383"; + sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; + }; + } + ]; }; } diff --git a/home-manager/git.nix b/home-manager/git.nix index 2e5dbbe1..95f626ba 100644 --- a/home-manager/git.nix +++ b/home-manager/git.nix @@ -1,4 +1,10 @@ -{ pkgs, edge-pkgs, lib, config, ... }: +{ + pkgs, + edge-pkgs, + lib, + config, + ... +}: { home.file."repos/.keep".text = "Put repositories here"; @@ -28,36 +34,43 @@ # TODO: They will be overridden by local hooks, Fixes in #545 hooks = { - commit-msg = lib.getExe (pkgs.writeShellApplication { - name = "prevent_typos_in_commit_mssage.bash"; - meta.description = "#325"; - runtimeInputs = [ edge-pkgs.typos ]; - text = '' - typos --config "${config.xdg.configHome}/typos/_typos.toml" "$1" - ''; - }); - - post-checkout = lib.getExe (pkgs.writeShellApplication { - name = "alert_typos_in_branch_name.bash"; - meta.description = "#540"; - runtimeInputs = with pkgs; [ git edge-pkgs.typos ]; - # What arguments: https://git-scm.com/docs/githooks#_post_checkout - text = '' - is_file_checkout="$3" # 0: file, 1: branch - if [[ "$is_file_checkout" -eq 0 ]]; then - exit 0 - fi - - branch_name="$(git rev-parse --abbrev-ref 'HEAD')" - - # Checkout to no branch and no tag - if [[ "$branch_name" = 'HEAD' ]]; then - exit 0 - fi - - (echo "$branch_name" | typos --config "${config.xdg.configHome}/typos/_typos.toml" -) || true - ''; - }); + commit-msg = lib.getExe ( + pkgs.writeShellApplication { + name = "prevent_typos_in_commit_mssage.bash"; + meta.description = "#325"; + runtimeInputs = [ edge-pkgs.typos ]; + text = '' + typos --config "${config.xdg.configHome}/typos/_typos.toml" "$1" + ''; + } + ); + + post-checkout = lib.getExe ( + pkgs.writeShellApplication { + name = "alert_typos_in_branch_name.bash"; + meta.description = "#540"; + runtimeInputs = with pkgs; [ + git + edge-pkgs.typos + ]; + # What arguments: https://git-scm.com/docs/githooks#_post_checkout + text = '' + is_file_checkout="$3" # 0: file, 1: branch + if [[ "$is_file_checkout" -eq 0 ]]; then + exit 0 + fi + + branch_name="$(git rev-parse --abbrev-ref 'HEAD')" + + # Checkout to no branch and no tag + if [[ "$branch_name" = 'HEAD' ]]; then + exit 0 + fi + + (echo "$branch_name" | typos --config "${config.xdg.configHome}/typos/_typos.toml" -) || true + ''; + } + ); }; extraConfig = { @@ -141,22 +154,24 @@ settings = { aliases = { # https://github.com/kachick/wait-other-jobs/blob/b576def89f0816aab642bed952817a018e99b373/docs/examples.md#github_token-vs-pat - setup = ''!gh repo edit --enable-auto-merge && \ - gh api --method PUT --verbose \ - --header 'Accept: application/vnd.github+json' \ - --header 'X-GitHub-Api-Version: 2022-11-28' \ - '/repos/{owner}/{repo}/actions/permissions/workflow' \ - --field 'can_approve_pull_request_reviews=true' \ - --raw-field 'default_workflow_permissions=write' + setup = '' + !gh repo edit --enable-auto-merge && \ + gh api --method PUT --verbose \ + --header 'Accept: application/vnd.github+json' \ + --header 'X-GitHub-Api-Version: 2022-11-28' \ + '/repos/{owner}/{repo}/actions/permissions/workflow' \ + --field 'can_approve_pull_request_reviews=true' \ + --raw-field 'default_workflow_permissions=write' ''; # https://www.collinsdictionary.com/dictionary/english/burl - burl = ''!cd "$(${pkgs.ghq}/bin/ghq root)/github.com/$(git config --global ghq.user)" && \ - gh repo create "$1" --private --clone --template='kachick/anylang-template' --description='🚧' && \ - cd "$1" && \ - gh setup && \ - ${pkgs.direnv}/bin/direnv allow && \ - ${pkgs.neo-cowsay}/bin/cowsay -W 100 --rainbow "cdg $1" + burl = '' + !cd "$(${pkgs.ghq}/bin/ghq root)/github.com/$(git config --global ghq.user)" && \ + gh repo create "$1" --private --clone --template='kachick/anylang-template' --description='🚧' && \ + cd "$1" && \ + gh setup && \ + ${pkgs.direnv}/bin/direnv allow && \ + ${pkgs.neo-cowsay}/bin/cowsay -W 100 --rainbow "cdg $1" ''; }; }; diff --git a/home-manager/gpg.nix b/home-manager/gpg.nix index 515fc6af..e77502f2 100644 --- a/home-manager/gpg.nix +++ b/home-manager/gpg.nix @@ -1,6 +1,5 @@ { config, pkgs, ... }: - # ## FAQ - GPG # # - How to list keys? diff --git a/home-manager/homemade.nix b/home-manager/homemade.nix index 53287044..ab83045e 100644 --- a/home-manager/homemade.nix +++ b/home-manager/homemade.nix @@ -12,216 +12,221 @@ let }; in [ - (pkgs.writeShellApplication - { - name = "bench_shells"; - runtimeInputs = with pkgs; [ hyperfine zsh bashInteractive fish ]; - text = '' - # ~ my feeling ~ - # 50ms : blazing fast! - # 110ms : acceptable - # 150ms : slow - # 200ms : 1980s? - # 300ms : much slow! - - # zsh should be first, because it often makes much slower with the completion - hyperfine --warmup 1 --runs 5 \ - 'zsh --interactive -c exit' \ - 'bash -i -c exit' \ - 'fish --interactive --command exit' - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "updeps"; - # Do no include "nix" in inputs: https://github.com/NixOS/nix/issues/5473 - runtimeInputs = [ edge-pkgs.mise ]; - text = '' - echo 'this updater assume you have the privilege and sudo command' - - set -x - - case ''${OSTYPE} in - linux*) - sudo apt update --yes && sudo apt upgrade --yes - ;; - darwin*) - softwareupdate --install --recommended - ;; - esac - - sudo -i nix upgrade-nix - - mise plugins update - ''; - } - ) + (pkgs.writeShellApplication { + name = "bench_shells"; + runtimeInputs = with pkgs; [ + hyperfine + zsh + bashInteractive + fish + ]; + text = '' + # ~ my feeling ~ + # 50ms : blazing fast! + # 110ms : acceptable + # 150ms : slow + # 200ms : 1980s? + # 300ms : much slow! + + # zsh should be first, because it often makes much slower with the completion + hyperfine --warmup 1 --runs 5 \ + 'zsh --interactive -c exit' \ + 'bash -i -c exit' \ + 'fish --interactive --command exit' + ''; + }) + + (pkgs.writeShellApplication { + name = "updeps"; + # Do no include "nix" in inputs: https://github.com/NixOS/nix/issues/5473 + runtimeInputs = [ edge-pkgs.mise ]; + text = '' + echo 'this updater assume you have the privilege and sudo command' + + set -x + + case ''${OSTYPE} in + linux*) + sudo apt update --yes && sudo apt upgrade --yes + ;; + darwin*) + softwareupdate --install --recommended + ;; + esac + + sudo -i nix upgrade-nix + + mise plugins update + ''; + }) la - (pkgs.writeShellApplication - { - name = "lat"; - runtimeInputs = [ la ]; - text = '' - la --tree "$@" - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "walk"; - runtimeInputs = with pkgs; [ edge-pkgs.fzf bat micro ]; - text = '' - # TODO: Apply walker-* options since https://github.com/NixOS/nixpkgs/pull/295978 is useable - eval "$EDITOR" "$(fzf --preview 'bat --color=always {}' --preview-window '~3')" - ''; - } - ) + (pkgs.writeShellApplication { + name = "lat"; + runtimeInputs = [ la ]; + text = '' + la --tree "$@" + ''; + }) + + (pkgs.writeShellApplication { + name = "walk"; + runtimeInputs = with pkgs; [ + edge-pkgs.fzf + bat + micro + ]; + text = '' + # TODO: Apply walker-* options since https://github.com/NixOS/nixpkgs/pull/295978 is useable + eval "$EDITOR" "$(fzf --preview 'bat --color=always {}' --preview-window '~3')" + ''; + }) # Why need the wrapper? # nixpkgs provide 4.9.3 is not including podman-remote. # https://github.com/NixOS/nixpkgs/blob/e3474e1d1e53b70e2b2af73ea26d6340e82f6b8b/pkgs/applications/virtualization/podman/default.nix#L104-L108 - (pkgs.writeShellApplication - { - name = "podman"; - runtimeInputs = [ edge-pkgs.mise ]; - text = '' - mise exec podman@latest -- podman "$@" - ''; - } - ) - - - (pkgs.writeShellApplication - { - name = "zj"; - runtimeInputs = with pkgs; [ coreutils zellij ]; - text = '' - name="$(basename "$PWD")" - - zellij attach "$name" || zellij --session "$name" - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "p"; - runtimeInputs = with pkgs; [ nix ]; - text = '' - # Needless to trim the default command, nix-shell only runs last command if given multiple. - nix-shell --command "$SHELL" --packages "$@" - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "g"; - runtimeInputs = with pkgs; [ git ]; - text = '' - git "$@" - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "git-delete-merged-branches"; - runtimeInputs = with pkgs; [ git coreutils findutils ]; - text = '' - # Care these traps if you change this code - # - Prefer git built-in features to filter as possible, handling correct regex is often hard for human - # - grep returns false if empty, it does not fit for pipefail use. --no-run-if-empty as xargs does not exists in the grep options - # - Always specify --sort to ensure it can be used in comm command. AFAIK, refname is most fit key here. - # Make sure, this result should not be changed even if you changed in global git config with git.nix - # Candidates: https://github.com/git/git/blob/3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0/ref-filter.c#L902-L959 - git branch --sort=refname --format='%(refname:short)' --list main master trunk develop development | - comm --check-order -13 - <(git branch --sort=refname --format='%(refname:short)' --merged) | - xargs --no-run-if-empty --max-lines=1 git branch --delete - ''; - } - ) - - (pkgs.writeShellApplication - { - name = "fzf-bind-posix-shell-history-to-git-commit-message"; - runtimeInputs = with pkgs; [ git edge-pkgs.fzf edge-pkgs.ruby_3_3 ]; - text = '' - # Avoiding nested single quote use - bind="$( - cat<<'EOF' - enter:become(echo '`{}`' | git commit -a -F -) - EOF - )" - - # Why ruby? - # - bash keeps whitespace prefix even specified -n option for fc -l - # - lstrip is not enough for some history - # shellcheck disable=SC2016 disable=SC2086 - ruby -pe '$_.strip!' | \ - fzf --height ''${FZF_TMUX_HEIGHT:-40%} ''${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind "$bind" - ''; - meta = { - description = "Used in git alias"; - }; - } - ) - - (pkgs.writeShellApplication - { - name = "todo"; - runtimeInputs = with pkgs; [ git edge-pkgs.fzf micro ]; - text = '' - git grep --perl-regexp --line-number --column '\b(?<=TODO|FIXME|BUG)\b\S+' | \ - fzf --delimiter : --nth 4.. --bind 'enter:become(micro -parsecursor=true {1}:{2}:{3})' - ''; - meta = { - description = "List todo family"; - }; - } - ) - - (pkgs.writeShellApplication - { - name = "ghqf"; - runtimeInputs = with pkgs; [ ghq edge-pkgs.fzf la ]; - text = '' - if [ $# -ge 1 ]; then - query="$1" - else - query="" - fi - - # shellcheck disable=SC2016 - ghq list | fzf --query "$query" --delimiter / --nth 3.. --preview 'la "$( - ghq list --full-path --exact {} - )"' --preview-window '~3' - ''; - meta = { - description = "ghq + fzf result"; - }; - } - ) - - (pkgs.writeShellApplication - { - name = "archive-home-files"; - runtimeInputs = with pkgs; [ gnutar ripgrep coreutils ]; - text = '' - archive_basename="$1" - # * Basically used in container for backup use, so keep fixed file name for the archive - # * Specify the subdir of hm-gen/home-files, the dereference and recursive from generation root doesn't end - tar --create --file="''${archive_basename}.tar.gz" --auto-compress --dereference --recursive --verify \ - --directory="$(home-manager generations | rg 'id \d+ -> /nix/store' | head -n1 | cut -d ' ' -f 7)/home-files" . - ''; - meta = { - description = "Backup dotfiles they are generated with home-manager. See #243"; - }; - } - ) + (pkgs.writeShellApplication { + name = "podman"; + runtimeInputs = [ edge-pkgs.mise ]; + text = '' + mise exec podman@latest -- podman "$@" + ''; + }) + + (pkgs.writeShellApplication { + name = "zj"; + runtimeInputs = with pkgs; [ + coreutils + zellij + ]; + text = '' + name="$(basename "$PWD")" + + zellij attach "$name" || zellij --session "$name" + ''; + }) + + (pkgs.writeShellApplication { + name = "p"; + runtimeInputs = with pkgs; [ nix ]; + text = '' + # Needless to trim the default command, nix-shell only runs last command if given multiple. + nix-shell --command "$SHELL" --packages "$@" + ''; + }) + + (pkgs.writeShellApplication { + name = "g"; + runtimeInputs = with pkgs; [ git ]; + text = '' + git "$@" + ''; + }) + + (pkgs.writeShellApplication { + name = "git-delete-merged-branches"; + runtimeInputs = with pkgs; [ + git + coreutils + findutils + ]; + text = '' + # Care these traps if you change this code + # - Prefer git built-in features to filter as possible, handling correct regex is often hard for human + # - grep returns false if empty, it does not fit for pipefail use. --no-run-if-empty as xargs does not exists in the grep options + # - Always specify --sort to ensure it can be used in comm command. AFAIK, refname is most fit key here. + # Make sure, this result should not be changed even if you changed in global git config with git.nix + # Candidates: https://github.com/git/git/blob/3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0/ref-filter.c#L902-L959 + git branch --sort=refname --format='%(refname:short)' --list main master trunk develop development | + comm --check-order -13 - <(git branch --sort=refname --format='%(refname:short)' --merged) | + xargs --no-run-if-empty --max-lines=1 git branch --delete + ''; + }) + + (pkgs.writeShellApplication { + name = "fzf-bind-posix-shell-history-to-git-commit-message"; + runtimeInputs = with pkgs; [ + git + edge-pkgs.fzf + edge-pkgs.ruby_3_3 + ]; + text = '' + # Avoiding nested single quote use + bind="$( + cat<<'EOF' + enter:become(echo '`{}`' | git commit -a -F -) + EOF + )" + + # Why ruby? + # - bash keeps whitespace prefix even specified -n option for fc -l + # - lstrip is not enough for some history + # shellcheck disable=SC2016 disable=SC2086 + ruby -pe '$_.strip!' | \ + fzf --height ''${FZF_TMUX_HEIGHT:-40%} ''${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind "$bind" + ''; + meta = { + description = "Used in git alias"; + }; + }) + + (pkgs.writeShellApplication { + name = "todo"; + runtimeInputs = with pkgs; [ + git + edge-pkgs.fzf + micro + ]; + text = '' + git grep --perl-regexp --line-number --column '\b(?<=TODO|FIXME|BUG)\b\S+' | \ + fzf --delimiter : --nth 4.. --bind 'enter:become(micro -parsecursor=true {1}:{2}:{3})' + ''; + meta = { + description = "List todo family"; + }; + }) + + (pkgs.writeShellApplication { + name = "ghqf"; + runtimeInputs = with pkgs; [ + ghq + edge-pkgs.fzf + la + ]; + text = '' + if [ $# -ge 1 ]; then + query="$1" + else + query="" + fi + + # shellcheck disable=SC2016 + ghq list | fzf --query "$query" --delimiter / --nth 3.. --preview 'la "$( + ghq list --full-path --exact {} + )"' --preview-window '~3' + ''; + meta = { + description = "ghq + fzf result"; + }; + }) + + (pkgs.writeShellApplication { + name = "archive-home-files"; + runtimeInputs = with pkgs; [ + gnutar + ripgrep + coreutils + ]; + text = '' + archive_basename="$1" + # * Basically used in container for backup use, so keep fixed file name for the archive + # * Specify the subdir of hm-gen/home-files, the dereference and recursive from generation root doesn't end + tar --create --file="''${archive_basename}.tar.gz" --auto-compress --dereference --recursive --verify \ + --directory="$(home-manager generations | rg 'id \d+ -> /nix/store' | head -n1 | cut -d ' ' -f 7)/home-files" . + ''; + meta = { + description = "Backup dotfiles they are generated with home-manager. See #243"; + }; + }) ] diff --git a/home-manager/kachick.nix b/home-manager/kachick.nix index 5186e1c4..47486a47 100644 --- a/home-manager/kachick.nix +++ b/home-manager/kachick.nix @@ -1,9 +1,7 @@ { lib, ... }: { - imports = [ - ./common.nix - ]; + imports = [ ./common.nix ]; home.username = lib.mkDefault "kachick"; diff --git a/home-manager/packages.nix b/home-manager/packages.nix index 11efa315..bb95b538 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -1,127 +1,137 @@ -{ pkgs, edge-pkgs, lib, ... }: +{ + pkgs, + edge-pkgs, + lib, + ... +}: { # Prefer stable pkgs as possible, if you want to use edge pkgs # - Keep zero or tiny config in home-manager layer # - Set `mod-name.package = edge-pkgs.the-one;` - home.packages = with pkgs; [ - # Use `bashInteractive`, don't `bash` - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 - # bash - # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 - bashInteractive - # readline # needless and using it does not fix bash problems - zsh - fish - powershell # Keep to stable nixpkgs, because this is one of the depending to xz. See #530 - starship - direnv - zoxide # Used in alias `z`, alt cd/pushd. popd = `z -`, fzf-mode = `zi` - - # Using in stable home-manager integration, but using edge fzf here. - # Because strongly want to use the new features. Consider to translate Nix -> native config style - edge-pkgs.fzf # History: CTRL+R, Walker: CTRL+T - # https://github.com/junegunn/fzf/blob/d579e335b5aa30e98a2ec046cb782bbb02bc28ad/ADVANCED.md#key-bindings-for-git-objects - # CTRL+O does not open web browser in WSL: https://github.com/kachick/dotfiles/issues/499 - edge-pkgs.fzf-git-sh # CTRL-G CTRL-{} keybinds for git - - # Used in anywhere - coreutils - less # container base image doesn't have less even for ubuntu official - procps # `ps` - - # Use same tools even in macOS - findutils - diffutils - gnugrep - gnused - gawk - netcat # `nc` - - edge-pkgs.mise # alt asdf - - git - tig - lazygit - gh - ghq - - # GPG - gnupg - - # Do not specify vim and the plugins at here, it made collisions from home-manager vim module. - # See following issues - # - https://github.com/kachick/dotfiles/issues/280 - # - https://discourse.nixos.org/t/home-manager-neovim-collision/16963/2 - - micro # alt nano - - tree - eza # alt ls - curl - wget - jq - edge-pkgs.jnv # interactive jq - ripgrep # `rg` - bat # alt cat - hexyl # hex viewer - dysk # alt df - fd # alt find - du-dust # `dust`, alt du - procs - bottom # `btm`, alt top - xh # alt HTTPie - zellij - edge-pkgs.alacritty - edge-pkgs.typos - hyperfine - difftastic - gnumake - gitleaks - gitleaks - edge-pkgs.deno - edge-pkgs.ruby_3_3 - unzip # Required in many asdf plugins - _7zz # `7zz` 7zip, not - tlrc # `tldr` rust client, tealdeer is another candidate - - # How to get the installed font names - # fontconfig by nix: `fc-list : family style` - # darwin: system_profiler SPFontsDataType - fontconfig # `fc-list`, `fc-cache` - - # - You can use major Nerd Fonts as `pkgs.nerdfonts.override ...` - # - Should have at least 1 composite font that includes Monospace + Japanese + Nerd fonts, - # because of alacritty does not have the fallback font feature. https://github.com/alacritty/alacritty/issues/957 - # - Keep fewer nerd fonts to reduce disk space - - # You can also use 0 = `Slashed zero style` with enabling `"editor.fontLigatures": "'zero'"` in vscode - # but cannot use it in alacritty https://github.com/alacritty/alacritty/issues/50 - edge-pkgs.plemoljp-nf - pkgs.ibm-plex # For sans-serif, use plemoljp for developing - - pkgs.source-han-code-jp # Includes many definitions, useful for fallback - pkgs.inconsolata - pkgs.mplus-outline-fonts.githubRelease # https://github.com/NixOS/nixpkgs/blob/c56f470377573b3170b62242ce21abcc196cb4ef/pkgs/data/fonts/mplus-outline-fonts/default.nix#L33 - # pkgs.sarasa-gothic # Large filesize - - # Includes follows in each repository if needed, not in global - # gcc - # rustup - # go - # crystal - # elmPackages.elm - # sqlite - # postgresql - # cargo-make - - # If you need to build cruby from source, this section may remind the struggle - # Often failed to build cruby even if I enabled following dependencies - # zlib - # libyaml - # openssl - - ] ++ (import ./homemade.nix { inherit pkgs; inherit edge-pkgs; }) ++ (lib.optionals stdenv.isLinux + home.packages = + with pkgs; [ + # Use `bashInteractive`, don't `bash` - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 + # bash + # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 + bashInteractive + # readline # needless and using it does not fix bash problems + zsh + fish + powershell # Keep to stable nixpkgs, because this is one of the depending to xz. See #530 + starship + direnv + zoxide # Used in alias `z`, alt cd/pushd. popd = `z -`, fzf-mode = `zi` + + # Using in stable home-manager integration, but using edge fzf here. + # Because strongly want to use the new features. Consider to translate Nix -> native config style + edge-pkgs.fzf # History: CTRL+R, Walker: CTRL+T + # https://github.com/junegunn/fzf/blob/d579e335b5aa30e98a2ec046cb782bbb02bc28ad/ADVANCED.md#key-bindings-for-git-objects + # CTRL+O does not open web browser in WSL: https://github.com/kachick/dotfiles/issues/499 + edge-pkgs.fzf-git-sh # CTRL-G CTRL-{} keybinds for git + + # Used in anywhere + coreutils + less # container base image doesn't have less even for ubuntu official + procps # `ps` + + # Use same tools even in macOS + findutils + diffutils + gnugrep + gnused + gawk + netcat # `nc` + + edge-pkgs.mise # alt asdf + + git + tig + lazygit + gh + ghq + + # GPG + gnupg + + # Do not specify vim and the plugins at here, it made collisions from home-manager vim module. + # See following issues + # - https://github.com/kachick/dotfiles/issues/280 + # - https://discourse.nixos.org/t/home-manager-neovim-collision/16963/2 + + micro # alt nano + + tree + eza # alt ls + curl + wget + jq + edge-pkgs.jnv # interactive jq + ripgrep # `rg` + bat # alt cat + hexyl # hex viewer + dysk # alt df + fd # alt find + du-dust # `dust`, alt du + procs + bottom # `btm`, alt top + xh # alt HTTPie + zellij + edge-pkgs.alacritty + edge-pkgs.typos + hyperfine + difftastic + gnumake + gitleaks + gitleaks + edge-pkgs.deno + edge-pkgs.ruby_3_3 + unzip # Required in many asdf plugins + _7zz # `7zz` 7zip, not + tlrc # `tldr` rust client, tealdeer is another candidate + + # How to get the installed font names + # fontconfig by nix: `fc-list : family style` + # darwin: system_profiler SPFontsDataType + fontconfig # `fc-list`, `fc-cache` + + # - You can use major Nerd Fonts as `pkgs.nerdfonts.override ...` + # - Should have at least 1 composite font that includes Monospace + Japanese + Nerd fonts, + # because of alacritty does not have the fallback font feature. https://github.com/alacritty/alacritty/issues/957 + # - Keep fewer nerd fonts to reduce disk space + + # You can also use 0 = `Slashed zero style` with enabling `"editor.fontLigatures": "'zero'"` in vscode + # but cannot use it in alacritty https://github.com/alacritty/alacritty/issues/50 + edge-pkgs.plemoljp-nf + pkgs.ibm-plex # For sans-serif, use plemoljp for developing + + pkgs.source-han-code-jp # Includes many definitions, useful for fallback + pkgs.inconsolata + pkgs.mplus-outline-fonts.githubRelease # https://github.com/NixOS/nixpkgs/blob/c56f470377573b3170b62242ce21abcc196cb4ef/pkgs/data/fonts/mplus-outline-fonts/default.nix#L33 + # pkgs.sarasa-gothic # Large filesize + + # Includes follows in each repository if needed, not in global + # gcc + # rustup + # go + # crystal + # elmPackages.elm + # sqlite + # postgresql + # cargo-make + + # If you need to build cruby from source, this section may remind the struggle + # Often failed to build cruby even if I enabled following dependencies + # zlib + # libyaml + # openssl + ] + ++ (import ./homemade.nix { + inherit pkgs; + inherit edge-pkgs; + }) + ++ (lib.optionals stdenv.isLinux [ # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` glibc @@ -129,11 +139,9 @@ openssh iputils # `ping` etc - ] - ) ++ (lib.optionals stdenv.isDarwin - [ + ]) + ++ (lib.optionals stdenv.isDarwin [ # https://github.com/NixOS/nixpkgs/issues/240819 pinentry_mac - ] - ); + ]); } diff --git a/home-manager/ssh.nix b/home-manager/ssh.nix index 7b5fcbfe..ce253aaf 100644 --- a/home-manager/ssh.nix +++ b/home-manager/ssh.nix @@ -6,10 +6,9 @@ let # - https://wiki.archlinux.jp/index.php/XDG_Base_Directory # - https://superuser.com/a/1606519/120469 sshDir = "${config.home.homeDirectory}/.ssh"; - - # - id_*: Do NOT share in different machines, do NOT tell to anyone. They are secrets. - # - id_*.pub: I CAN register them for different services. in +# - id_*: Do NOT share in different machines, do NOT tell to anyone. They are secrets. +# - id_*.pub: I CAN register them for different services. { # https://github.com/nix-community/home-manager/blob/release-23.11/modules/services/ssh-agent.nix services.ssh-agent.enable = if pkgs.stdenv.isLinux then true else false; @@ -47,9 +46,7 @@ in controlPersist = "10m"; # Enable custom or temporary config without `home-manager switch` - includes = [ - "${sshDir}/config.local" - ]; + includes = [ "${sshDir}/config.local" ]; # https://www.clear-code.com/blog/2023/4/3/recommended-ssh-config.html # https://gitlab.com/clear-code/ssh.d/-/blob/main/global.conf?ref_type=heads diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix index 1da09460..14eac1b3 100644 --- a/home-manager/zsh.nix +++ b/home-manager/zsh.nix @@ -1,4 +1,10 @@ -{ config, lib, pkgs, edge-pkgs, ... }: +{ + config, + lib, + pkgs, + edge-pkgs, + ... +}: { services.gpg-agent.enableZshIntegration = true; @@ -37,7 +43,19 @@ # https://askubuntu.com/questions/999923/syntax-in-history-ignore # https://github.com/zsh-users/zsh/blob/aa8e4a02904b3a1c4b3064eb7502d887f7de958b/Src/hist.c#L3006-L3015 - ignorePatterns = [ "cd *" "pushd *" "popd *" "z *" "ls *" "ll *" "la *" "rm *" "rmdir *" "git show *" "exit" ]; + ignorePatterns = [ + "cd *" + "pushd *" + "popd *" + "z *" + "ls *" + "ll *" + "la *" + "rm *" + "rmdir *" + "git show *" + "exit" + ]; # Hist memory size should be grater than saving file size if enabled expireDuplicatesFirst = true;