From 325fc194538daea60bbf141f7ac74bf17e36c8e7 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 11:37:29 +0900 Subject: [PATCH 01/17] Add home-manager CI --- .github/workflows/ci-home.yml | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/ci-home.yml diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml new file mode 100644 index 00000000..d43b9e3e --- /dev/null +++ b/.github/workflows/ci-home.yml @@ -0,0 +1,36 @@ +name: CI - Home +on: + push: + branches: [main] + paths: + - '.github/workflows/ci-home.yml' + - '**home.nix' + - 'Makefile.toml' + pull_request: + paths: + - '.github/workflows/ci-home.yml' + - '**home.nix' + - 'Makefile.toml' + schedule: + # Every 10:42 JST + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule + - cron: '42 1 * * *' + workflow_dispatch: + +jobs: + tasks: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: DeterminateSystems/nix-installer-action@v4 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Register Nix Channels + run: | + nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager + nix-channel --update + nix-channel --list + - uses: actions/checkout@v3 + - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' + - run: nix-shell --run 'makers apply' + - run: | + fish --command 'starship --version' From 266db5b817a882cdad8eea52db20cfb3229c2c1a Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 11:41:53 +0900 Subject: [PATCH 02/17] Install home-manager --- .github/workflows/ci-home.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index d43b9e3e..9681210f 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -29,6 +29,7 @@ jobs: nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager nix-channel --update nix-channel --list + - run: nix-shell '' -A install - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - run: nix-shell --run 'makers apply' From 51a1aa22bca89e0f6017de17e26c0a742dd486f4 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:09:25 +0900 Subject: [PATCH 03/17] Split files --- .github/workflows/ci-home.yml | 4 +- Makefile.toml | 8 + home/.config/home-manager/common.nix | 439 +++++++++++++++++++ home/.config/home-manager/github-actions.nix | 6 + home/.config/home-manager/kachick.nix | 6 + 5 files changed, 461 insertions(+), 2 deletions(-) create mode 100644 home/.config/home-manager/common.nix create mode 100644 home/.config/home-manager/github-actions.nix create mode 100644 home/.config/home-manager/kachick.nix diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 9681210f..29da2ecb 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -19,7 +19,7 @@ on: jobs: tasks: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 timeout-minutes: 60 steps: - uses: DeterminateSystems/nix-installer-action@v4 @@ -32,6 +32,6 @@ jobs: - run: nix-shell '' -A install - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - - run: nix-shell --run 'makers apply' + - run: nix-shell --run 'makers ci-home-apply' - run: | fish --command 'starship --version' diff --git a/Makefile.toml b/Makefile.toml index c1f37a12..ccf7ff3b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -68,6 +68,14 @@ args = [ './home/.config/home-manager/home.nix', ] +[tasks.ci-home-apply] +command = 'home-manager' +args = [ + 'switch', + '-f', + './home/.config/home-manager/github-actions.nix', +] + [tasks.enable_login_shells] command = 'sudo' args = [ diff --git a/home/.config/home-manager/common.nix b/home/.config/home-manager/common.nix new file mode 100644 index 00000000..5987d14e --- /dev/null +++ b/home/.config/home-manager/common.nix @@ -0,0 +1,439 @@ +{ config, pkgs, ... }: + +# FAQ +# - How to get sha256? => assume by `lib.fakeSha256` + +{ + # TODO: How to cover lima? The default is /home/kachick.local + home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; + + # https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix + xdg.enable = true; + + # 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. + home.stateVersion = "23.05"; + + home = { + sessionVariables = { + INPUTRC = "${config.home.sessionVariables.XDG_CONFIG_HOME}/readline/inputrc"; + EDITOR = "code -w"; + VISUAL = "nano"; + PAGER = "less"; + + # - You can check the candidates in `locale -a` + # - pkgs.glibc installs many candidates, but it does not support darwin + LANG = "en_US.UTF-8"; + + # NOTE: Original comments in zsh + # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). + # Remove -X and -F (exit if the content fits on one screen) to enable it. + LESS = "-F -g -i -M -R -S -w -X -z-4"; + + # https://github.com/coreos/bugs/issues/365#issuecomment-105638617 + LESSCHARSET = "utf-8"; + }; + + sessionPath = [ + "${config.xdg.dataHome}/homemade/bin" + ]; + }; + + # This also changes xdg? Official manual sed this config is better for non NixOS Linux + # https://github.com/nix-community/home-manager/blob/559856748982588a9eda6bfb668450ebcf006ccd/modules/targets/generic-linux.nix#L16 + targets.genericLinux.enable = if pkgs.stdenv.hostPlatform.isDarwin then false else true; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + nix = { + enable = true; + settings = { + experimental-features = [ "nix-command" "flakes" ]; + }; + + # Without this makes following errors + # + # error: + # Failed assertions: + # - A corresponding Nix package must be specified via `nix.package` for generating + package = pkgs.nix; + }; + + 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 + + # nix + if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" + fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" + end + + # home-manager + if test -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + end + + # starship + if status is-interactive + starship init fish | source + end + ''; + + plugins = [{ + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "3ee95536106c11073d6ff466c1681cde31001383"; + sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; + }; + }]; + }; + + programs.readline = { + enable = true; + variables = { + # https://unix.stackexchange.com/questions/73672/how-to-turn-off-the-beep-only-in-bash-tab-complete + # https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix + bell-style = "none"; + }; + }; + + programs.lesspipe.enable = true; + + programs.direnv = { + enable = true; + + # Replacement of `programs.direnv.enableNixDirenvIntegration = true;` + nix-direnv = { + enable = true; + }; + + enableZshIntegration = true; + enableNushellIntegration = true; + }; + + programs.zoxide = { + enable = true; + enableZshIntegration = true; + enableNushellIntegration = true; + }; + + # https://nixos.wiki/wiki/Home_Manager + # - Prefer XDG_* + # - If can't write the reason as a comment + + xdg.configFile."home-manager/home.nix".source = ./home.nix; + xdg.configFile."git/config".source = ../git/config; + xdg.configFile."fish/fish_variables".source = ../fish/fish_variables; + xdg.configFile."fish/functions/fish_prompt.fish".source = ../fish/functions/fish_prompt.fish; + xdg.configFile."alacritty/alacritty.yml".source = ../alacritty/alacritty.yml; + + # Not under "starship/starship.toml" + xdg.configFile."starship.toml".source = ../starship.toml; + + # basic shell dotfiles should be put in ~/ except part of zsh files + home.file.".bashrc".source = ../../../home/.bashrc; + home.file.".bash_logout".source = ../../../home/.bash_logout; + + # - stack manager can not found in https://github.com/nix-community/home-manager/tree/8d243f7da13d6ee32f722a3f1afeced150b6d4da/modules/programs + # - https://github.com/kachick/dotfiles/issues/142 + home.file.".stack/config.yaml".source = ../../../home/.stack/config.yaml; + + # 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".text = builtins.readFile ( + pkgs.fetchFromGitHub + { + owner = "kachick"; + repo = "anylang-template"; + rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; + sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; + } + + "/.editorconfig" + ); + + xdg.configFile."irb/irbrc".text = builtins.readFile ( + pkgs.fetchFromGitHub + { + owner = "kachick"; + repo = "irb-power_assert"; + rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; + sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; + } + + "/examples/.irbrc" + ); + + # https://github.com/rbenv/rbenv-default-gems/issues/17 + home.file.".default-gems".text = '' + irb-power_assert + ''; + + # https://nixos.wiki/wiki/Zsh + # https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix + programs.zsh = { + enable = true; + + # How about to point `xdg.configFile`? + dotDir = ".config/zsh"; + + history = { + # in memory + size = 100000; + + # in file + save = 4200000; + path = "${config.xdg.stateHome}/zsh/history"; + + ignoreDups = true; + ignoreSpace = true; + + extended = true; + share = true; + }; + + historySubstringSearch = { + enable = true; + }; + enableSyntaxHighlighting = true; + enableAutosuggestions = true; + enableCompletion = true; + + # home-manager path will set in `programs.home-manager.enable = true`; + envExtra = '' + # https://wiki.archlinux.jp/index.php/XDG_Base_Directory + # https://www.reddit.com/r/zsh/comments/tpwx9t/zcompcache_vs_zcompdump/ + zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" + + if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi # added by Nix installer + ''; + + initExtra = '' + typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='fg=blue,bold' + typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' + typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='true' + + setopt correct + unsetopt BEEP + + setopt hist_ignore_all_dups + setopt hist_reduce_blanks + setopt hist_save_no_dups + setopt hist_no_store + + eval "$($XDG_DATA_HOME/rtx/bin/rtx activate -s zsh)" + + case ''${OSTYPE} in + darwin*) + test -e "''${HOME}/.iterm2_shell_integration.zsh" && source "''${HOME}/.iterm2_shell_integration.zsh" + ;; + esac + + # 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; $(basename "$PWD") \007" + } + precmd_functions+=(set_win_title) + + zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 } + ''; + + # TODO: May move to sessionVariables + profileExtra = '' + if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' + fi + ''; + }; + + programs.nushell = { + enable = true; + + # Do not set `shell_integration: true for now` + # - window title requires `shell_integration: true` - https://github.com/nushell/nushell/issues/2527 + # - several terminal requires `shell_integration: false` - https://github.com/nushell/nushell/issues/6214 + extraConfig = '' + let-env config = { + show_banner: false + + keybindings: [ + # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 + { + name: fuzzy_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "commandline ( + history + | each { |it| $it.command } + | uniq + | reverse + | str join (char -i 0) + | fzf --read0 --layout=reverse --height=40% -q (commandline) + | decode utf-8 + | str trim + )" + } + ] + } + # Same as above for Up Arrow + { + name: fuzzy_history + modifier: control + keycode: Up + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "commandline ( + history + | each { |it| $it.command } + | uniq + | reverse + | str join (char -i 0) + | fzf --read0 --layout=reverse --height=40% -q (commandline) + | decode utf-8 + | str trim + )" + } + ] + } + ] + } + ''; + }; + + programs.fzf = { + enable = true; + + # enableShellIntegration = true; + + enableZshIntegration = true; + + # enableFishIntegration = true; + + # fzf manager does not have nushell integration yet. + # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 may help you. + }; + + programs.starship = { + enable = true; + + # enableShellIntegration = true; + enableZshIntegration = true; + # enableFishIntegration = true; + enableNushellIntegration = true; + }; + + # - Tiny tools by me, they may be rewritten with another language. + # - Keep *.bash in shellscript naming in this repo for maintainability, the extname should be trimmed in the symlinks + xdg.dataFile."homemade/bin/bench_shells".source = ../../../home/.local/share/homemade/bin/bench_shells.bash; + xdg.dataFile."homemade/bin/updeps".source = ../../../home/.local/share/homemade/bin/updeps.bash; + xdg.dataFile."homemade/bin/la".source = ../../../home/.local/share/homemade/bin/la.bash; + xdg.dataFile."homemade/bin/zj".source = ../../../home/.local/share/homemade/bin/zj.bash; + + home.packages = [ + pkgs.dprint + pkgs.gitleaks + pkgs.shellcheck + pkgs.shfmt + pkgs.git + pkgs.coreutils + pkgs.tig + pkgs.tree + pkgs.curl + pkgs.wget + pkgs.zsh + # Don't include bash - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 + # pkgs.bash + pkgs.fish + pkgs.nushell + pkgs.starship + pkgs.jq + pkgs.gh + pkgs.direnv + pkgs.ripgrep + pkgs.fzf + pkgs.exa + pkgs.bat + pkgs.duf + pkgs.fd + pkgs.du-dust + pkgs.procs + pkgs.bottom + pkgs.tig + pkgs.zellij + pkgs.nixpkgs-fmt + pkgs.nil + pkgs.typos + pkgs.hyperfine + pkgs.zoxide + pkgs.difftastic + + # Required in many asdf(rtx) plugins + pkgs.unzip + + # Includes follows in each repository if needed, not in global + # pkgs.deno + # pkgs.rustup + # pkgs.go + # pkgs.crystal + # pkgs.elmPackages.elm + # pkgs.gcc + # pkgs.sqlite + # pkgs.postgresql + # pkgs.gnumake + # pkgs.cargo-make + + # This section is just a note for my strggle + # Often failed to build ruby even if I enabled following dependencies + # pkgs.zlib + # pkgs.libyaml + # pkgs.openssl + # + # Don't include nixpkgs ruby, because of installing into .nix-profile hides + # adhoc use of https://github.com/bobvanderlinden/nixpkgs-ruby + # pkgs.ruby + + # As a boardgamer + # pkgs.tesseract + # pkgs.imagemagick + # pkgs.pngquant + # pkgs.img2pdf + # pkgs.ocrmypdf + ] ++ ( + if pkgs.stdenv.hostPlatform.isDarwin then + [ ] + else + [ + # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` + pkgs.glibc + ] + ); +} diff --git a/home/.config/home-manager/github-actions.nix b/home/.config/home-manager/github-actions.nix new file mode 100644 index 00000000..f15ccc77 --- /dev/null +++ b/home/.config/home-manager/github-actions.nix @@ -0,0 +1,6 @@ +{ ... }: + +{ + imports = [ ./common.nix ]; + home.username = "runner"; +} diff --git a/home/.config/home-manager/kachick.nix b/home/.config/home-manager/kachick.nix new file mode 100644 index 00000000..da83ebec --- /dev/null +++ b/home/.config/home-manager/kachick.nix @@ -0,0 +1,6 @@ +{ ... }: + +{ + imports = [ ./common.nix ]; + home.username = "kachick"; +} From a8f4709a740229b524ae4a4db3e0b2a961585fe7 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:16:49 +0900 Subject: [PATCH 04/17] After removing, steps will work...? --- .github/workflows/ci-home.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 29da2ecb..b2126d4d 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -30,6 +30,12 @@ jobs: nix-channel --update nix-channel --list - run: nix-shell '' -A install + - name: Clean up conflict files with applying by home-manager + run: | + rm '/home/runner/.config/nix/nix.conf' + rm '/home/runner/.config/home-manager/home.nix' + rm '/home/runner/.bashrc' + rm '/home/runner/.bash_logout' - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - run: nix-shell --run 'makers ci-home-apply' From b71d1824dd6382fbdd360c3845daa1a4a6020e75 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:25:23 +0900 Subject: [PATCH 05/17] Matrix run --- .github/workflows/ci-home.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index b2126d4d..6968aa86 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -18,15 +18,24 @@ on: workflow_dispatch: jobs: - tasks: - runs-on: ubuntu-22.04 - timeout-minutes: 60 + home-manager: + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + - macos-13 + home-manager-channel: + - https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz + - https://github.com/nix-community/home-manager/archive/master.tar.gz # unstable + runs-on: ${{ matrix.os }} steps: - uses: DeterminateSystems/nix-installer-action@v4 - uses: DeterminateSystems/magic-nix-cache-action@v2 - name: Register Nix Channels run: | - nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager + nix-channel --add ${{ matrix.home-manager-channel }} home-manager nix-channel --update nix-channel --list - run: nix-shell '' -A install From 740117b1ba1ba1bfbf6d8d4e1fd094f76211db42 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:26:55 +0900 Subject: [PATCH 06/17] Remove backuped files --- Makefile.toml | 2 +- ...ub-actions.nix => home-github-actions.nix} | 0 home/.config/home-manager/home.nix | 440 +----------------- home/.config/home-manager/kachick.nix | 6 - 4 files changed, 3 insertions(+), 445 deletions(-) rename home/.config/home-manager/{github-actions.nix => home-github-actions.nix} (100%) delete mode 100644 home/.config/home-manager/kachick.nix diff --git a/Makefile.toml b/Makefile.toml index ccf7ff3b..36cca74f 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -73,7 +73,7 @@ command = 'home-manager' args = [ 'switch', '-f', - './home/.config/home-manager/github-actions.nix', + './home/.config/home-manager/home-github-actions.nix', ] [tasks.enable_login_shells] diff --git a/home/.config/home-manager/github-actions.nix b/home/.config/home-manager/home-github-actions.nix similarity index 100% rename from home/.config/home-manager/github-actions.nix rename to home/.config/home-manager/home-github-actions.nix diff --git a/home/.config/home-manager/home.nix b/home/.config/home-manager/home.nix index d8781b0c..da83ebec 100644 --- a/home/.config/home-manager/home.nix +++ b/home/.config/home-manager/home.nix @@ -1,442 +1,6 @@ -{ config, pkgs, ... }: - -# FAQ -# - How to get sha256? => assume by `lib.fakeSha256` +{ ... }: { - # Home Manager needs a bit of information about you and the - # paths it should manage. + imports = [ ./common.nix ]; home.username = "kachick"; - # TODO: How to cover lima? The default is /home/kachick.local - home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; - - # https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix - xdg.enable = true; - - # 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. - home.stateVersion = "23.05"; - - home = { - sessionVariables = { - INPUTRC = "${config.home.sessionVariables.XDG_CONFIG_HOME}/readline/inputrc"; - EDITOR = "code -w"; - VISUAL = "nano"; - PAGER = "less"; - - # - You can check the candidates in `locale -a` - # - pkgs.glibc installs many candidates, but it does not support darwin - LANG = "en_US.UTF-8"; - - # NOTE: Original comments in zsh - # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). - # Remove -X and -F (exit if the content fits on one screen) to enable it. - LESS = "-F -g -i -M -R -S -w -X -z-4"; - - # https://github.com/coreos/bugs/issues/365#issuecomment-105638617 - LESSCHARSET = "utf-8"; - }; - - sessionPath = [ - "${config.xdg.dataHome}/homemade/bin" - ]; - }; - - # This also changes xdg? Official manual sed this config is better for non NixOS Linux - # https://github.com/nix-community/home-manager/blob/559856748982588a9eda6bfb668450ebcf006ccd/modules/targets/generic-linux.nix#L16 - targets.genericLinux.enable = if pkgs.stdenv.hostPlatform.isDarwin then false else true; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - - nix = { - enable = true; - settings = { - experimental-features = [ "nix-command" "flakes" ]; - }; - - # Without this makes following errors - # - # error: - # Failed assertions: - # - A corresponding Nix package must be specified via `nix.package` for generating - package = pkgs.nix; - }; - - 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 - - # nix - if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" - fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" - end - - # home-manager - if test -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - end - - # starship - if status is-interactive - starship init fish | source - end - ''; - - plugins = [{ - name = "foreign-env"; - src = pkgs.fetchFromGitHub { - owner = "oh-my-fish"; - repo = "plugin-foreign-env"; - rev = "3ee95536106c11073d6ff466c1681cde31001383"; - sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; - }; - }]; - }; - - programs.readline = { - enable = true; - variables = { - # https://unix.stackexchange.com/questions/73672/how-to-turn-off-the-beep-only-in-bash-tab-complete - # https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix - bell-style = "none"; - }; - }; - - programs.lesspipe.enable = true; - - programs.direnv = { - enable = true; - - # Replacement of `programs.direnv.enableNixDirenvIntegration = true;` - nix-direnv = { - enable = true; - }; - - enableZshIntegration = true; - enableNushellIntegration = true; - }; - - programs.zoxide = { - enable = true; - enableZshIntegration = true; - enableNushellIntegration = true; - }; - - # https://nixos.wiki/wiki/Home_Manager - # - Prefer XDG_* - # - If can't write the reason as a comment - - xdg.configFile."home-manager/home.nix".source = ./home.nix; - xdg.configFile."git/config".source = ../git/config; - xdg.configFile."fish/fish_variables".source = ../fish/fish_variables; - xdg.configFile."fish/functions/fish_prompt.fish".source = ../fish/functions/fish_prompt.fish; - xdg.configFile."alacritty/alacritty.yml".source = ../alacritty/alacritty.yml; - - # Not under "starship/starship.toml" - xdg.configFile."starship.toml".source = ../starship.toml; - - # basic shell dotfiles should be put in ~/ except part of zsh files - home.file.".bashrc".source = ../../../home/.bashrc; - home.file.".bash_logout".source = ../../../home/.bash_logout; - - # - stack manager can not found in https://github.com/nix-community/home-manager/tree/8d243f7da13d6ee32f722a3f1afeced150b6d4da/modules/programs - # - https://github.com/kachick/dotfiles/issues/142 - home.file.".stack/config.yaml".source = ../../../home/.stack/config.yaml; - - # 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".text = builtins.readFile ( - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "anylang-template"; - rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; - sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; - } - + "/.editorconfig" - ); - - xdg.configFile."irb/irbrc".text = builtins.readFile ( - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "irb-power_assert"; - rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; - sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; - } - + "/examples/.irbrc" - ); - - # https://github.com/rbenv/rbenv-default-gems/issues/17 - home.file.".default-gems".text = '' - irb-power_assert - ''; - - # https://nixos.wiki/wiki/Zsh - # https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix - programs.zsh = { - enable = true; - - # How about to point `xdg.configFile`? - dotDir = ".config/zsh"; - - history = { - # in memory - size = 100000; - - # in file - save = 4200000; - path = "${config.xdg.stateHome}/zsh/history"; - - ignoreDups = true; - ignoreSpace = true; - - extended = true; - share = true; - }; - - historySubstringSearch = { - enable = true; - }; - enableSyntaxHighlighting = true; - enableAutosuggestions = true; - enableCompletion = true; - - # home-manager path will set in `programs.home-manager.enable = true`; - envExtra = '' - # https://wiki.archlinux.jp/index.php/XDG_Base_Directory - # https://www.reddit.com/r/zsh/comments/tpwx9t/zcompcache_vs_zcompdump/ - zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" - - if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi # added by Nix installer - ''; - - initExtra = '' - typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='fg=blue,bold' - typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' - typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='true' - - setopt correct - unsetopt BEEP - - setopt hist_ignore_all_dups - setopt hist_reduce_blanks - setopt hist_save_no_dups - setopt hist_no_store - - eval "$($XDG_DATA_HOME/rtx/bin/rtx activate -s zsh)" - - case ''${OSTYPE} in - darwin*) - test -e "''${HOME}/.iterm2_shell_integration.zsh" && source "''${HOME}/.iterm2_shell_integration.zsh" - ;; - esac - - # 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; $(basename "$PWD") \007" - } - precmd_functions+=(set_win_title) - - zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 } - ''; - - # TODO: May move to sessionVariables - profileExtra = '' - if [[ "$OSTYPE" == darwin* ]]; then - export BROWSER='open' - fi - ''; - }; - - programs.nushell = { - enable = true; - - # Do not set `shell_integration: true for now` - # - window title requires `shell_integration: true` - https://github.com/nushell/nushell/issues/2527 - # - several terminal requires `shell_integration: false` - https://github.com/nushell/nushell/issues/6214 - extraConfig = '' - let-env config = { - show_banner: false - - keybindings: [ - # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 - { - name: fuzzy_history - modifier: control - keycode: char_r - mode: [emacs, vi_normal, vi_insert] - event: [ - { - send: ExecuteHostCommand - cmd: "commandline ( - history - | each { |it| $it.command } - | uniq - | reverse - | str join (char -i 0) - | fzf --read0 --layout=reverse --height=40% -q (commandline) - | decode utf-8 - | str trim - )" - } - ] - } - # Same as above for Up Arrow - { - name: fuzzy_history - modifier: control - keycode: Up - mode: [emacs, vi_normal, vi_insert] - event: [ - { - send: ExecuteHostCommand - cmd: "commandline ( - history - | each { |it| $it.command } - | uniq - | reverse - | str join (char -i 0) - | fzf --read0 --layout=reverse --height=40% -q (commandline) - | decode utf-8 - | str trim - )" - } - ] - } - ] - } - ''; - }; - - programs.fzf = { - enable = true; - - # enableShellIntegration = true; - - enableZshIntegration = true; - - # enableFishIntegration = true; - - # fzf manager does not have nushell integration yet. - # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 may help you. - }; - - programs.starship = { - enable = true; - - # enableShellIntegration = true; - enableZshIntegration = true; - # enableFishIntegration = true; - enableNushellIntegration = true; - }; - - # - Tiny tools by me, they may be rewritten with another language. - # - Keep *.bash in shellscript naming in this repo for maintainability, the extname should be trimmed in the symlinks - xdg.dataFile."homemade/bin/bench_shells".source = ../../../home/.local/share/homemade/bin/bench_shells.bash; - xdg.dataFile."homemade/bin/updeps".source = ../../../home/.local/share/homemade/bin/updeps.bash; - xdg.dataFile."homemade/bin/la".source = ../../../home/.local/share/homemade/bin/la.bash; - xdg.dataFile."homemade/bin/zj".source = ../../../home/.local/share/homemade/bin/zj.bash; - - home.packages = [ - pkgs.dprint - pkgs.gitleaks - pkgs.shellcheck - pkgs.shfmt - pkgs.git - pkgs.coreutils - pkgs.tig - pkgs.tree - pkgs.curl - pkgs.wget - pkgs.zsh - # Don't include bash - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 - # pkgs.bash - pkgs.fish - pkgs.nushell - pkgs.starship - pkgs.jq - pkgs.gh - pkgs.direnv - pkgs.ripgrep - pkgs.fzf - pkgs.exa - pkgs.bat - pkgs.duf - pkgs.fd - pkgs.du-dust - pkgs.procs - pkgs.bottom - pkgs.tig - pkgs.zellij - pkgs.nixpkgs-fmt - pkgs.nil - pkgs.typos - pkgs.hyperfine - pkgs.zoxide - pkgs.difftastic - - # Required in many asdf(rtx) plugins - pkgs.unzip - - # Includes follows in each repository if needed, not in global - # pkgs.deno - # pkgs.rustup - # pkgs.go - # pkgs.crystal - # pkgs.elmPackages.elm - # pkgs.gcc - # pkgs.sqlite - # pkgs.postgresql - # pkgs.gnumake - # pkgs.cargo-make - - # This section is just a note for my strggle - # Often failed to build ruby even if I enabled following dependencies - # pkgs.zlib - # pkgs.libyaml - # pkgs.openssl - # - # Don't include nixpkgs ruby, because of installing into .nix-profile hides - # adhoc use of https://github.com/bobvanderlinden/nixpkgs-ruby - # pkgs.ruby - - # As a boardgamer - # pkgs.tesseract - # pkgs.imagemagick - # pkgs.pngquant - # pkgs.img2pdf - # pkgs.ocrmypdf - ] ++ ( - if pkgs.stdenv.hostPlatform.isDarwin then - [ ] - else - [ - # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` - pkgs.glibc - ] - ); } diff --git a/home/.config/home-manager/kachick.nix b/home/.config/home-manager/kachick.nix deleted file mode 100644 index da83ebec..00000000 --- a/home/.config/home-manager/kachick.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: - -{ - imports = [ ./common.nix ]; - home.username = "kachick"; -} From a5a5643416d93325a0794d4bbd72b6079179301b Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:28:25 +0900 Subject: [PATCH 07/17] Update badges in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23e5c9e8..4f9204e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dotfiles -[![Linter Status](https://github.com/kachick/dotfiles/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/lint.yml?query=branch%3Amain+) +[![Home Status](https://github.com/kachick/dotfiles/actions/workflows/ci-home.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-home.yml?query=branch%3Amain+) [![Nix Status](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml/badge.svg?branch=main)](https://github.com/kachick/dotfiles/actions/workflows/ci-nix.yml?query=branch%3Amain+) Personal dotfiles that can be placed in the public repository From 4df174c24f6b1ce34d27353c9de82fc4bde6b523 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:29:55 +0900 Subject: [PATCH 08/17] Update triggers --- .github/workflows/ci-home.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 6968aa86..810b0fc2 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -4,12 +4,12 @@ on: branches: [main] paths: - '.github/workflows/ci-home.yml' - - '**home.nix' + - '**/home-manager/**.nix' - 'Makefile.toml' pull_request: paths: - '.github/workflows/ci-home.yml' - - '**home.nix' + - '**/home-manager/**.nix' - 'Makefile.toml' schedule: # Every 10:42 JST From 5acb73ec1e94adc55bd7e81a94d8fbe3b9125512 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:35:35 +0900 Subject: [PATCH 09/17] Shorter matrix variable for overview --- .github/workflows/ci-home.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 810b0fc2..ea91ddc5 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -27,15 +27,15 @@ jobs: - ubuntu-22.04 - macos-13 home-manager-channel: - - https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz - - https://github.com/nix-community/home-manager/archive/master.tar.gz # unstable + - release-23.05 + - master # unstable nixpkgs runs-on: ${{ matrix.os }} steps: - uses: DeterminateSystems/nix-installer-action@v4 - uses: DeterminateSystems/magic-nix-cache-action@v2 - name: Register Nix Channels run: | - nix-channel --add ${{ matrix.home-manager-channel }} home-manager + nix-channel --add https://github.com/nix-community/home-manager/archive/${{ matrix.home-manager-channel }}.tar.gz home-manager nix-channel --update nix-channel --list - run: nix-shell '' -A install From 24f6d59e5b4632bf3fb913a99b84e8d31656e751 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:43:45 +0900 Subject: [PATCH 10/17] Fix matrix for macos --- .github/workflows/ci-home.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index ea91ddc5..920d5b22 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -29,6 +29,11 @@ jobs: home-manager-channel: - release-23.05 - master # unstable nixpkgs + include: + - home-dir: /home + os: ubuntu-22.04 + - home-dir: /Users + os: macos-13 runs-on: ${{ matrix.os }} steps: - uses: DeterminateSystems/nix-installer-action@v4 @@ -41,10 +46,10 @@ jobs: - run: nix-shell '' -A install - name: Clean up conflict files with applying by home-manager run: | - rm '/home/runner/.config/nix/nix.conf' - rm '/home/runner/.config/home-manager/home.nix' - rm '/home/runner/.bashrc' - rm '/home/runner/.bash_logout' + rm '${{ matrix.home-dir }}/runner/.config/nix/nix.conf' + rm '${{ matrix.home-dir }}/runner/.config/home-manager/home.nix' + rm '${{ matrix.home-dir }}/runner/.bashrc' + rm '${{ matrix.home-dir }}/runner/.bash_logout' - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - run: nix-shell --run 'makers ci-home-apply' From b9599f1bcef84dfd42a47b0a06dd3e5ae4ce0eec Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 12:53:50 +0900 Subject: [PATCH 11/17] Fix matrix for macos with the bash and zsh difference --- .github/workflows/ci-home.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 920d5b22..69bfaed7 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -30,10 +30,18 @@ jobs: - release-23.05 - master # unstable nixpkgs include: - - home-dir: /home - os: ubuntu-22.04 - - home-dir: /Users - os: macos-13 + - os: ubuntu-22.04 + cleanup-script: | + rm '/home/runner/.config/nix/nix.conf' + rm '/home/runner/.config/home-manager/home.nix' + rm '/home/runner/.bashrc' + rm '/home/runner/.bash_logout' + # Latest macOS sets default shell as zsh + - os: macos-13 + cleanup-script: | + rm '/Users/runner/.config/nix/nix.conf' + rm '/Users/runner/.config/home-manager/home.nix' + runs-on: ${{ matrix.os }} steps: - uses: DeterminateSystems/nix-installer-action@v4 @@ -46,10 +54,7 @@ jobs: - run: nix-shell '' -A install - name: Clean up conflict files with applying by home-manager run: | - rm '${{ matrix.home-dir }}/runner/.config/nix/nix.conf' - rm '${{ matrix.home-dir }}/runner/.config/home-manager/home.nix' - rm '${{ matrix.home-dir }}/runner/.bashrc' - rm '${{ matrix.home-dir }}/runner/.bash_logout' + ${{ matrix.cleanup-script }} - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - run: nix-shell --run 'makers ci-home-apply' From ec949a19504c71fbf57e47b34901063c4d6210d4 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 13:02:53 +0900 Subject: [PATCH 12/17] Fix matrix for macos that has .bashrc :< --- .github/workflows/ci-home.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 69bfaed7..480863d7 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -36,11 +36,12 @@ jobs: rm '/home/runner/.config/home-manager/home.nix' rm '/home/runner/.bashrc' rm '/home/runner/.bash_logout' - # Latest macOS sets default shell as zsh - os: macos-13 + # Latest macOS sets default shell as zsh, but having .bashrc except .bash_logout cleanup-script: | rm '/Users/runner/.config/nix/nix.conf' rm '/Users/runner/.config/home-manager/home.nix' + rm '/Users/runner/.bashrc' runs-on: ${{ matrix.os }} steps: From 33134aafab989e317274bab7ac43b646464bdabc Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 16:05:03 +0900 Subject: [PATCH 13/17] Refactor file paths --- Makefile.toml | 18 +- home/.config/home-manager/common.nix | 439 ------------------ home/.config/home-manager/home.nix | 439 +++++++++++++++++- ...ub-actions.nix => user-github-actions.nix} | 2 +- home/.config/home-manager/user-kachick.nix | 6 + 5 files changed, 457 insertions(+), 447 deletions(-) delete mode 100644 home/.config/home-manager/common.nix rename home/.config/home-manager/{home-github-actions.nix => user-github-actions.nix} (58%) create mode 100644 home/.config/home-manager/user-kachick.nix diff --git a/Makefile.toml b/Makefile.toml index 36cca74f..21183446 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -35,7 +35,7 @@ command = 'dist/deps' [tasks.prepare-build] command = 'mkdir' -args = ['-p', 'dist'] +args = ['-p', 'dist/race'] [tasks.build] dependencies = ['prepare-build'] @@ -56,16 +56,26 @@ args = [ '-v', '-race', '-o', - 'dist', + 'dist/race', './...', ] +[tasks.test] +dependencies = ['test-race'] +command = 'home-manager' +args = [ + 'switch', + '-n', # dry-run + '-f', + './home/.config/home-manager/user-kachick.nix', +] + [tasks.apply] command = 'home-manager' args = [ 'switch', '-f', - './home/.config/home-manager/home.nix', + './home/.config/home-manager/user-kachick.nix', ] [tasks.ci-home-apply] @@ -73,7 +83,7 @@ command = 'home-manager' args = [ 'switch', '-f', - './home/.config/home-manager/home-github-actions.nix', + './home/.config/home-manager/user-github-actions.nix', ] [tasks.enable_login_shells] diff --git a/home/.config/home-manager/common.nix b/home/.config/home-manager/common.nix deleted file mode 100644 index 5987d14e..00000000 --- a/home/.config/home-manager/common.nix +++ /dev/null @@ -1,439 +0,0 @@ -{ config, pkgs, ... }: - -# FAQ -# - How to get sha256? => assume by `lib.fakeSha256` - -{ - # TODO: How to cover lima? The default is /home/kachick.local - home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; - - # https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix - xdg.enable = true; - - # 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. - home.stateVersion = "23.05"; - - home = { - sessionVariables = { - INPUTRC = "${config.home.sessionVariables.XDG_CONFIG_HOME}/readline/inputrc"; - EDITOR = "code -w"; - VISUAL = "nano"; - PAGER = "less"; - - # - You can check the candidates in `locale -a` - # - pkgs.glibc installs many candidates, but it does not support darwin - LANG = "en_US.UTF-8"; - - # NOTE: Original comments in zsh - # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). - # Remove -X and -F (exit if the content fits on one screen) to enable it. - LESS = "-F -g -i -M -R -S -w -X -z-4"; - - # https://github.com/coreos/bugs/issues/365#issuecomment-105638617 - LESSCHARSET = "utf-8"; - }; - - sessionPath = [ - "${config.xdg.dataHome}/homemade/bin" - ]; - }; - - # This also changes xdg? Official manual sed this config is better for non NixOS Linux - # https://github.com/nix-community/home-manager/blob/559856748982588a9eda6bfb668450ebcf006ccd/modules/targets/generic-linux.nix#L16 - targets.genericLinux.enable = if pkgs.stdenv.hostPlatform.isDarwin then false else true; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - - nix = { - enable = true; - settings = { - experimental-features = [ "nix-command" "flakes" ]; - }; - - # Without this makes following errors - # - # error: - # Failed assertions: - # - A corresponding Nix package must be specified via `nix.package` for generating - package = pkgs.nix; - }; - - 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 - - # nix - if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" - fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" - end - - # home-manager - if test -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" - end - - # starship - if status is-interactive - starship init fish | source - end - ''; - - plugins = [{ - name = "foreign-env"; - src = pkgs.fetchFromGitHub { - owner = "oh-my-fish"; - repo = "plugin-foreign-env"; - rev = "3ee95536106c11073d6ff466c1681cde31001383"; - sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; - }; - }]; - }; - - programs.readline = { - enable = true; - variables = { - # https://unix.stackexchange.com/questions/73672/how-to-turn-off-the-beep-only-in-bash-tab-complete - # https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix - bell-style = "none"; - }; - }; - - programs.lesspipe.enable = true; - - programs.direnv = { - enable = true; - - # Replacement of `programs.direnv.enableNixDirenvIntegration = true;` - nix-direnv = { - enable = true; - }; - - enableZshIntegration = true; - enableNushellIntegration = true; - }; - - programs.zoxide = { - enable = true; - enableZshIntegration = true; - enableNushellIntegration = true; - }; - - # https://nixos.wiki/wiki/Home_Manager - # - Prefer XDG_* - # - If can't write the reason as a comment - - xdg.configFile."home-manager/home.nix".source = ./home.nix; - xdg.configFile."git/config".source = ../git/config; - xdg.configFile."fish/fish_variables".source = ../fish/fish_variables; - xdg.configFile."fish/functions/fish_prompt.fish".source = ../fish/functions/fish_prompt.fish; - xdg.configFile."alacritty/alacritty.yml".source = ../alacritty/alacritty.yml; - - # Not under "starship/starship.toml" - xdg.configFile."starship.toml".source = ../starship.toml; - - # basic shell dotfiles should be put in ~/ except part of zsh files - home.file.".bashrc".source = ../../../home/.bashrc; - home.file.".bash_logout".source = ../../../home/.bash_logout; - - # - stack manager can not found in https://github.com/nix-community/home-manager/tree/8d243f7da13d6ee32f722a3f1afeced150b6d4da/modules/programs - # - https://github.com/kachick/dotfiles/issues/142 - home.file.".stack/config.yaml".source = ../../../home/.stack/config.yaml; - - # 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".text = builtins.readFile ( - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "anylang-template"; - rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; - sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; - } - + "/.editorconfig" - ); - - xdg.configFile."irb/irbrc".text = builtins.readFile ( - pkgs.fetchFromGitHub - { - owner = "kachick"; - repo = "irb-power_assert"; - rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; - sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; - } - + "/examples/.irbrc" - ); - - # https://github.com/rbenv/rbenv-default-gems/issues/17 - home.file.".default-gems".text = '' - irb-power_assert - ''; - - # https://nixos.wiki/wiki/Zsh - # https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix - programs.zsh = { - enable = true; - - # How about to point `xdg.configFile`? - dotDir = ".config/zsh"; - - history = { - # in memory - size = 100000; - - # in file - save = 4200000; - path = "${config.xdg.stateHome}/zsh/history"; - - ignoreDups = true; - ignoreSpace = true; - - extended = true; - share = true; - }; - - historySubstringSearch = { - enable = true; - }; - enableSyntaxHighlighting = true; - enableAutosuggestions = true; - enableCompletion = true; - - # home-manager path will set in `programs.home-manager.enable = true`; - envExtra = '' - # https://wiki.archlinux.jp/index.php/XDG_Base_Directory - # https://www.reddit.com/r/zsh/comments/tpwx9t/zcompcache_vs_zcompdump/ - zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" - - if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi # added by Nix installer - ''; - - initExtra = '' - typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='fg=blue,bold' - typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' - typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='true' - - setopt correct - unsetopt BEEP - - setopt hist_ignore_all_dups - setopt hist_reduce_blanks - setopt hist_save_no_dups - setopt hist_no_store - - eval "$($XDG_DATA_HOME/rtx/bin/rtx activate -s zsh)" - - case ''${OSTYPE} in - darwin*) - test -e "''${HOME}/.iterm2_shell_integration.zsh" && source "''${HOME}/.iterm2_shell_integration.zsh" - ;; - esac - - # 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; $(basename "$PWD") \007" - } - precmd_functions+=(set_win_title) - - zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 } - ''; - - # TODO: May move to sessionVariables - profileExtra = '' - if [[ "$OSTYPE" == darwin* ]]; then - export BROWSER='open' - fi - ''; - }; - - programs.nushell = { - enable = true; - - # Do not set `shell_integration: true for now` - # - window title requires `shell_integration: true` - https://github.com/nushell/nushell/issues/2527 - # - several terminal requires `shell_integration: false` - https://github.com/nushell/nushell/issues/6214 - extraConfig = '' - let-env config = { - show_banner: false - - keybindings: [ - # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 - { - name: fuzzy_history - modifier: control - keycode: char_r - mode: [emacs, vi_normal, vi_insert] - event: [ - { - send: ExecuteHostCommand - cmd: "commandline ( - history - | each { |it| $it.command } - | uniq - | reverse - | str join (char -i 0) - | fzf --read0 --layout=reverse --height=40% -q (commandline) - | decode utf-8 - | str trim - )" - } - ] - } - # Same as above for Up Arrow - { - name: fuzzy_history - modifier: control - keycode: Up - mode: [emacs, vi_normal, vi_insert] - event: [ - { - send: ExecuteHostCommand - cmd: "commandline ( - history - | each { |it| $it.command } - | uniq - | reverse - | str join (char -i 0) - | fzf --read0 --layout=reverse --height=40% -q (commandline) - | decode utf-8 - | str trim - )" - } - ] - } - ] - } - ''; - }; - - programs.fzf = { - enable = true; - - # enableShellIntegration = true; - - enableZshIntegration = true; - - # enableFishIntegration = true; - - # fzf manager does not have nushell integration yet. - # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 may help you. - }; - - programs.starship = { - enable = true; - - # enableShellIntegration = true; - enableZshIntegration = true; - # enableFishIntegration = true; - enableNushellIntegration = true; - }; - - # - Tiny tools by me, they may be rewritten with another language. - # - Keep *.bash in shellscript naming in this repo for maintainability, the extname should be trimmed in the symlinks - xdg.dataFile."homemade/bin/bench_shells".source = ../../../home/.local/share/homemade/bin/bench_shells.bash; - xdg.dataFile."homemade/bin/updeps".source = ../../../home/.local/share/homemade/bin/updeps.bash; - xdg.dataFile."homemade/bin/la".source = ../../../home/.local/share/homemade/bin/la.bash; - xdg.dataFile."homemade/bin/zj".source = ../../../home/.local/share/homemade/bin/zj.bash; - - home.packages = [ - pkgs.dprint - pkgs.gitleaks - pkgs.shellcheck - pkgs.shfmt - pkgs.git - pkgs.coreutils - pkgs.tig - pkgs.tree - pkgs.curl - pkgs.wget - pkgs.zsh - # Don't include bash - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 - # pkgs.bash - pkgs.fish - pkgs.nushell - pkgs.starship - pkgs.jq - pkgs.gh - pkgs.direnv - pkgs.ripgrep - pkgs.fzf - pkgs.exa - pkgs.bat - pkgs.duf - pkgs.fd - pkgs.du-dust - pkgs.procs - pkgs.bottom - pkgs.tig - pkgs.zellij - pkgs.nixpkgs-fmt - pkgs.nil - pkgs.typos - pkgs.hyperfine - pkgs.zoxide - pkgs.difftastic - - # Required in many asdf(rtx) plugins - pkgs.unzip - - # Includes follows in each repository if needed, not in global - # pkgs.deno - # pkgs.rustup - # pkgs.go - # pkgs.crystal - # pkgs.elmPackages.elm - # pkgs.gcc - # pkgs.sqlite - # pkgs.postgresql - # pkgs.gnumake - # pkgs.cargo-make - - # This section is just a note for my strggle - # Often failed to build ruby even if I enabled following dependencies - # pkgs.zlib - # pkgs.libyaml - # pkgs.openssl - # - # Don't include nixpkgs ruby, because of installing into .nix-profile hides - # adhoc use of https://github.com/bobvanderlinden/nixpkgs-ruby - # pkgs.ruby - - # As a boardgamer - # pkgs.tesseract - # pkgs.imagemagick - # pkgs.pngquant - # pkgs.img2pdf - # pkgs.ocrmypdf - ] ++ ( - if pkgs.stdenv.hostPlatform.isDarwin then - [ ] - else - [ - # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` - pkgs.glibc - ] - ); -} diff --git a/home/.config/home-manager/home.nix b/home/.config/home-manager/home.nix index da83ebec..5987d14e 100644 --- a/home/.config/home-manager/home.nix +++ b/home/.config/home-manager/home.nix @@ -1,6 +1,439 @@ -{ ... }: +{ config, pkgs, ... }: + +# FAQ +# - How to get sha256? => assume by `lib.fakeSha256` { - imports = [ ./common.nix ]; - home.username = "kachick"; + # TODO: How to cover lima? The default is /home/kachick.local + home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; + + # https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix + xdg.enable = true; + + # 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. + home.stateVersion = "23.05"; + + home = { + sessionVariables = { + INPUTRC = "${config.home.sessionVariables.XDG_CONFIG_HOME}/readline/inputrc"; + EDITOR = "code -w"; + VISUAL = "nano"; + PAGER = "less"; + + # - You can check the candidates in `locale -a` + # - pkgs.glibc installs many candidates, but it does not support darwin + LANG = "en_US.UTF-8"; + + # NOTE: Original comments in zsh + # Mouse-wheel scrolling has been disabled by -X (disable screen clearing). + # Remove -X and -F (exit if the content fits on one screen) to enable it. + LESS = "-F -g -i -M -R -S -w -X -z-4"; + + # https://github.com/coreos/bugs/issues/365#issuecomment-105638617 + LESSCHARSET = "utf-8"; + }; + + sessionPath = [ + "${config.xdg.dataHome}/homemade/bin" + ]; + }; + + # This also changes xdg? Official manual sed this config is better for non NixOS Linux + # https://github.com/nix-community/home-manager/blob/559856748982588a9eda6bfb668450ebcf006ccd/modules/targets/generic-linux.nix#L16 + targets.genericLinux.enable = if pkgs.stdenv.hostPlatform.isDarwin then false else true; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + nix = { + enable = true; + settings = { + experimental-features = [ "nix-command" "flakes" ]; + }; + + # Without this makes following errors + # + # error: + # Failed assertions: + # - A corresponding Nix package must be specified via `nix.package` for generating + package = pkgs.nix; + }; + + 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 + + # nix + if test -e "$HOME/.nix-profile/etc/profile.d/nix.sh" + fenv source "$HOME/.nix-profile/etc/profile.d/nix.sh" + end + + # home-manager + if test -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" + end + + # starship + if status is-interactive + starship init fish | source + end + ''; + + plugins = [{ + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "3ee95536106c11073d6ff466c1681cde31001383"; + sha256 = "sha256-vyW/X2lLjsieMpP9Wi2bZPjReaZBkqUbkh15zOi8T4Y="; + }; + }]; + }; + + programs.readline = { + enable = true; + variables = { + # https://unix.stackexchange.com/questions/73672/how-to-turn-off-the-beep-only-in-bash-tab-complete + # https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix + bell-style = "none"; + }; + }; + + programs.lesspipe.enable = true; + + programs.direnv = { + enable = true; + + # Replacement of `programs.direnv.enableNixDirenvIntegration = true;` + nix-direnv = { + enable = true; + }; + + enableZshIntegration = true; + enableNushellIntegration = true; + }; + + programs.zoxide = { + enable = true; + enableZshIntegration = true; + enableNushellIntegration = true; + }; + + # https://nixos.wiki/wiki/Home_Manager + # - Prefer XDG_* + # - If can't write the reason as a comment + + xdg.configFile."home-manager/home.nix".source = ./home.nix; + xdg.configFile."git/config".source = ../git/config; + xdg.configFile."fish/fish_variables".source = ../fish/fish_variables; + xdg.configFile."fish/functions/fish_prompt.fish".source = ../fish/functions/fish_prompt.fish; + xdg.configFile."alacritty/alacritty.yml".source = ../alacritty/alacritty.yml; + + # Not under "starship/starship.toml" + xdg.configFile."starship.toml".source = ../starship.toml; + + # basic shell dotfiles should be put in ~/ except part of zsh files + home.file.".bashrc".source = ../../../home/.bashrc; + home.file.".bash_logout".source = ../../../home/.bash_logout; + + # - stack manager can not found in https://github.com/nix-community/home-manager/tree/8d243f7da13d6ee32f722a3f1afeced150b6d4da/modules/programs + # - https://github.com/kachick/dotfiles/issues/142 + home.file.".stack/config.yaml".source = ../../../home/.stack/config.yaml; + + # 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".text = builtins.readFile ( + pkgs.fetchFromGitHub + { + owner = "kachick"; + repo = "anylang-template"; + rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; + sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; + } + + "/.editorconfig" + ); + + xdg.configFile."irb/irbrc".text = builtins.readFile ( + pkgs.fetchFromGitHub + { + owner = "kachick"; + repo = "irb-power_assert"; + rev = "98ad68b4c391bb30adee1ba119cb6c6ed5bd0bfc"; + sha256 = "sha256-Su3jaPELaBKa+CJpNp6OzOb/6/wwGk7JDxP/w9wVBtM="; + } + + "/examples/.irbrc" + ); + + # https://github.com/rbenv/rbenv-default-gems/issues/17 + home.file.".default-gems".text = '' + irb-power_assert + ''; + + # https://nixos.wiki/wiki/Zsh + # https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix + programs.zsh = { + enable = true; + + # How about to point `xdg.configFile`? + dotDir = ".config/zsh"; + + history = { + # in memory + size = 100000; + + # in file + save = 4200000; + path = "${config.xdg.stateHome}/zsh/history"; + + ignoreDups = true; + ignoreSpace = true; + + extended = true; + share = true; + }; + + historySubstringSearch = { + enable = true; + }; + enableSyntaxHighlighting = true; + enableAutosuggestions = true; + enableCompletion = true; + + # home-manager path will set in `programs.home-manager.enable = true`; + envExtra = '' + # https://wiki.archlinux.jp/index.php/XDG_Base_Directory + # https://www.reddit.com/r/zsh/comments/tpwx9t/zcompcache_vs_zcompdump/ + zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache" + + if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi # added by Nix installer + ''; + + initExtra = '' + typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='fg=blue,bold' + typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' + typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='true' + + setopt correct + unsetopt BEEP + + setopt hist_ignore_all_dups + setopt hist_reduce_blanks + setopt hist_save_no_dups + setopt hist_no_store + + eval "$($XDG_DATA_HOME/rtx/bin/rtx activate -s zsh)" + + case ''${OSTYPE} in + darwin*) + test -e "''${HOME}/.iterm2_shell_integration.zsh" && source "''${HOME}/.iterm2_shell_integration.zsh" + ;; + esac + + # 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; $(basename "$PWD") \007" + } + precmd_functions+=(set_win_title) + + zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 } + ''; + + # TODO: May move to sessionVariables + profileExtra = '' + if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' + fi + ''; + }; + + programs.nushell = { + enable = true; + + # Do not set `shell_integration: true for now` + # - window title requires `shell_integration: true` - https://github.com/nushell/nushell/issues/2527 + # - several terminal requires `shell_integration: false` - https://github.com/nushell/nushell/issues/6214 + extraConfig = '' + let-env config = { + show_banner: false + + keybindings: [ + # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 + { + name: fuzzy_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "commandline ( + history + | each { |it| $it.command } + | uniq + | reverse + | str join (char -i 0) + | fzf --read0 --layout=reverse --height=40% -q (commandline) + | decode utf-8 + | str trim + )" + } + ] + } + # Same as above for Up Arrow + { + name: fuzzy_history + modifier: control + keycode: Up + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "commandline ( + history + | each { |it| $it.command } + | uniq + | reverse + | str join (char -i 0) + | fzf --read0 --layout=reverse --height=40% -q (commandline) + | decode utf-8 + | str trim + )" + } + ] + } + ] + } + ''; + }; + + programs.fzf = { + enable = true; + + # enableShellIntegration = true; + + enableZshIntegration = true; + + # enableFishIntegration = true; + + # fzf manager does not have nushell integration yet. + # https://github.com/nushell/nushell/issues/1616#issuecomment-1386714173 may help you. + }; + + programs.starship = { + enable = true; + + # enableShellIntegration = true; + enableZshIntegration = true; + # enableFishIntegration = true; + enableNushellIntegration = true; + }; + + # - Tiny tools by me, they may be rewritten with another language. + # - Keep *.bash in shellscript naming in this repo for maintainability, the extname should be trimmed in the symlinks + xdg.dataFile."homemade/bin/bench_shells".source = ../../../home/.local/share/homemade/bin/bench_shells.bash; + xdg.dataFile."homemade/bin/updeps".source = ../../../home/.local/share/homemade/bin/updeps.bash; + xdg.dataFile."homemade/bin/la".source = ../../../home/.local/share/homemade/bin/la.bash; + xdg.dataFile."homemade/bin/zj".source = ../../../home/.local/share/homemade/bin/zj.bash; + + home.packages = [ + pkgs.dprint + pkgs.gitleaks + pkgs.shellcheck + pkgs.shfmt + pkgs.git + pkgs.coreutils + pkgs.tig + pkgs.tree + pkgs.curl + pkgs.wget + pkgs.zsh + # Don't include bash - https://github.com/NixOS/nixpkgs/issues/29960, https://github.com/NixOS/nix/issues/730 + # pkgs.bash + pkgs.fish + pkgs.nushell + pkgs.starship + pkgs.jq + pkgs.gh + pkgs.direnv + pkgs.ripgrep + pkgs.fzf + pkgs.exa + pkgs.bat + pkgs.duf + pkgs.fd + pkgs.du-dust + pkgs.procs + pkgs.bottom + pkgs.tig + pkgs.zellij + pkgs.nixpkgs-fmt + pkgs.nil + pkgs.typos + pkgs.hyperfine + pkgs.zoxide + pkgs.difftastic + + # Required in many asdf(rtx) plugins + pkgs.unzip + + # Includes follows in each repository if needed, not in global + # pkgs.deno + # pkgs.rustup + # pkgs.go + # pkgs.crystal + # pkgs.elmPackages.elm + # pkgs.gcc + # pkgs.sqlite + # pkgs.postgresql + # pkgs.gnumake + # pkgs.cargo-make + + # This section is just a note for my strggle + # Often failed to build ruby even if I enabled following dependencies + # pkgs.zlib + # pkgs.libyaml + # pkgs.openssl + # + # Don't include nixpkgs ruby, because of installing into .nix-profile hides + # adhoc use of https://github.com/bobvanderlinden/nixpkgs-ruby + # pkgs.ruby + + # As a boardgamer + # pkgs.tesseract + # pkgs.imagemagick + # pkgs.pngquant + # pkgs.img2pdf + # pkgs.ocrmypdf + ] ++ ( + if pkgs.stdenv.hostPlatform.isDarwin then + [ ] + else + [ + # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` + pkgs.glibc + ] + ); } diff --git a/home/.config/home-manager/home-github-actions.nix b/home/.config/home-manager/user-github-actions.nix similarity index 58% rename from home/.config/home-manager/home-github-actions.nix rename to home/.config/home-manager/user-github-actions.nix index f15ccc77..77f8b429 100644 --- a/home/.config/home-manager/home-github-actions.nix +++ b/home/.config/home-manager/user-github-actions.nix @@ -1,6 +1,6 @@ { ... }: { - imports = [ ./common.nix ]; + imports = [ ./home.nix ]; home.username = "runner"; } diff --git a/home/.config/home-manager/user-kachick.nix b/home/.config/home-manager/user-kachick.nix new file mode 100644 index 00000000..5c829767 --- /dev/null +++ b/home/.config/home-manager/user-kachick.nix @@ -0,0 +1,6 @@ +{ ... }: + +{ + imports = [ ./home.nix ]; + home.username = "kachick"; +} From 39e4bc4f53ff5d36a4d3ab6fc2a43ecade695599 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 16:09:27 +0900 Subject: [PATCH 14/17] Add test steps --- .github/workflows/ci-home.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 480863d7..ccd0e468 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -59,5 +59,13 @@ jobs: - uses: actions/checkout@v3 - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - run: nix-shell --run 'makers ci-home-apply' - - run: | + - name: Print shell paths + run: | + which fish + which zsh + which bash + - name: Run customized dependencies + run: | fish --command 'starship --version' + zsh -c 'bench_shells' + bash -c 'la' From 32221ab41bfa6986db3f8ca47cf87faa3f13ca9f Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 16:14:29 +0900 Subject: [PATCH 15/17] I forgot the bash handling --- .github/workflows/ci-home.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index ccd0e468..3ded7ae3 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -63,9 +63,8 @@ jobs: run: | which fish which zsh - which bash + which bash # Be non nix shell - name: Run customized dependencies run: | fish --command 'starship --version' zsh -c 'bench_shells' - bash -c 'la' From 52b07b7ea21a514a9543544ff0e69e5b8d3929e6 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 16:19:17 +0900 Subject: [PATCH 16/17] I should be anywhere --- Makefile.toml | 4 ++-- home/.config/home-manager/home.nix | 3 ++- home/.config/home-manager/user-kachick.nix | 6 ------ 3 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 home/.config/home-manager/user-kachick.nix diff --git a/Makefile.toml b/Makefile.toml index 21183446..81c9a8d5 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -67,7 +67,7 @@ args = [ 'switch', '-n', # dry-run '-f', - './home/.config/home-manager/user-kachick.nix', + './home/.config/home-manager/home.nix', ] [tasks.apply] @@ -75,7 +75,7 @@ command = 'home-manager' args = [ 'switch', '-f', - './home/.config/home-manager/user-kachick.nix', + './home/.config/home-manager/home.nix', ] [tasks.ci-home-apply] diff --git a/home/.config/home-manager/home.nix b/home/.config/home-manager/home.nix index 5987d14e..944d6cef 100644 --- a/home/.config/home-manager/home.nix +++ b/home/.config/home-manager/home.nix @@ -1,9 +1,10 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: # FAQ # - How to get sha256? => assume by `lib.fakeSha256` { + home.username = lib.mkDefault "kachick"; # TODO: How to cover lima? The default is /home/kachick.local home.homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}"; diff --git a/home/.config/home-manager/user-kachick.nix b/home/.config/home-manager/user-kachick.nix deleted file mode 100644 index 5c829767..00000000 --- a/home/.config/home-manager/user-kachick.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: - -{ - imports = [ ./home.nix ]; - home.username = "kachick"; -} From 40118dd460234c7b36afd6ea146a3e4fa3e182c1 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 31 Jul 2023 16:29:15 +0900 Subject: [PATCH 17/17] Remove duplicated and longtime devenv steps from home-manager CI --- .github/workflows/ci-home.yml | 3 +-- Makefile.toml | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 3ded7ae3..19732efe 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -57,8 +57,7 @@ jobs: run: | ${{ matrix.cleanup-script }} - uses: actions/checkout@v3 - - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - - run: nix-shell --run 'makers ci-home-apply' + - run: home-manager switch -f ./home/.config/home-manager/user-github-actions.nix - name: Print shell paths run: | which fish diff --git a/Makefile.toml b/Makefile.toml index 81c9a8d5..738ea1a4 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -78,14 +78,6 @@ args = [ './home/.config/home-manager/home.nix', ] -[tasks.ci-home-apply] -command = 'home-manager' -args = [ - 'switch', - '-f', - './home/.config/home-manager/user-github-actions.nix', -] - [tasks.enable_login_shells] command = 'sudo' args = [