diff --git a/.editorconfig b/.editorconfig index 322bfa4e..36bb8470 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -[{Makefile,*.mk,*.go,.gitmodules,*.*sh,.*shrc,*shenv,.bash_*}] +[{Makefile,*.mk,*.go,.gitmodules,*.*sh,.*shrc,*shenv,.bash_*,*.envrc}] indent_style = tab indent_size = 4 diff --git a/.envrc b/.envrc index 8f51a982..e5eb66d0 100644 --- a/.envrc +++ b/.envrc @@ -1,7 +1,3 @@ #!/usr/bin/env -S bash use flake - -# To avoid absolute path for Nix and typos-lsp in vscode settings -TYPOS_LSP_PATH="$(command -v typos-lsp)" -export TYPOS_LSP_PATH diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d7987645..41a3af61 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,6 +15,6 @@ updates: schedule: interval: 'weekly' - package-ecosystem: 'gomod' - directory: '/pkgs/trim-github-user-prefix-for-reponame' + directory: '/pkgs/reponame' schedule: interval: 'weekly' diff --git a/.github/renovate.json b/.github/renovate.json index d017effa..c4efd073 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -2,11 +2,12 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "dependencyDashboard": true, "extends": [ + "config:recommended", "github>kachick/renovate-config-dprint#1.3.0", "github>kachick/renovate-config-dprint:self" ], "labels": ["dependencies", "renovate"], - "enabledManagers": ["nix", "regex"], + "enabledManagers": ["nix", "regex", "dockerfile"], "nix": { "enabled": true }, diff --git a/.github/workflows/ci-go.yml b/.github/workflows/ci-go.yml index c8cf6e93..255d62cd 100644 --- a/.github/workflows/ci-go.yml +++ b/.github/workflows/ci-go.yml @@ -27,7 +27,7 @@ jobs: matrix: os: - ubuntu-24.04 - - macos-14 # M1. Doesn't match for my Intel Mac, but preferring with the speed. + - macos-15 # Apple Silicon. Doesn't match for my Intel Mac, but preferring with the speed. - windows-latest runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 7667f7a1..8995d84e 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -4,14 +4,14 @@ on: branches: [main] paths: - '.github/workflows/ci-home.yml' - - '**/home-manager/**.nix' + - 'home-manager/**.nix' - '**.nix' - 'flake.*' - 'Makefile.toml' pull_request: paths: - '.github/workflows/ci-home.yml' - - '**/home-manager/**.nix' + - 'home-manager/**.nix' - '**.nix' - 'flake.*' - 'Makefile.toml' @@ -28,18 +28,23 @@ jobs: outputs: matrix: ${{ steps.generator.outputs.matrix }} steps: + - name: Install gh-action-escape + run: curl -fsSL https://raw.githubusercontent.com/kachick/gh-action-escape/main/scripts/install-in-github-action.sh | sh -s v0.2.0 - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get changed paths + run: | + git diff origin/main --name-only | gh-action-escape -name=CHANGED_PATHS | tee --append "$GITHUB_ENV" - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache-dependency-path: 'go.sum' - - name: Install gh-action-escape - run: curl -fsSL https://raw.githubusercontent.com/kachick/gh-action-escape/main/scripts/install-in-github-action.sh | sh -s v0.2.0 - name: Generate Matrix id: generator run: | - go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT" + go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' -paths "$CHANGED_PATHS" | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT" home-manager: needs: [generate_matrix] if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft) @@ -50,7 +55,8 @@ jobs: runs-on: ${{ matrix.os }} steps: # Do not use DeterminateSystems/magic-nix-cache-action for home workflow, it always faced to GitHub rate limit because of home depends on many packages - - uses: DeterminateSystems/nix-installer-action@v13 + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 - name: Print some dotfiles overviews run: | KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto + } + + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default) + vi_insert: block # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default) + vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default) + } + + color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + footer_mode: 25 # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + buffer_editor: null # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: emacs # emacs, vi + shell_integration: { + # osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title + osc2: true + # osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory + osc7: true + # osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it. show_clickable_links is deprecated in favor of osc8 + osc8: true + # osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal + osc9_9: false + # osc133 is several escapes invented by Final Term which include the supported ones below. + # 133;A - Mark prompt start + # 133;B - Mark prompt end + # 133;C - Mark pre-execution + # 133;D;exit - Mark execution finished with exit code + # This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is + osc133: true + # osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features + # 633;A - Mark prompt start + # 633;B - Mark prompt end + # 633;C - Mark pre-execution + # 633;D;exit - Mark execution finished with exit code + # 633;E - Explicitly set the command line with an optional nonce + # 633;P;Cwd= - Mark the current working directory and communicate it to the terminal + # and also helps with the run recent menu in vscode + osc633: true + # reset_application_mode is escape \x1b[?1l and was added to help ssh work better + reset_application_mode: true + } + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. + highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which. + recursion_limit: 50 # the maximum number of times nushell allows recursion before stopping it + + plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration. + + plugin_gc: { + # Configuration for plugin garbage collection + default: { + enabled: true # true to enable stopping of inactive plugins + stop_after: 10sec # how long to wait after a plugin is inactive to stop it + } + plugins: { + # alternate configuration for specific plugins, by name, for example: + # + # gstat: { + # enabled: false + # } + } + } + + hooks: { + pre_prompt: [{ null }] # run before the prompt is shown + pre_execution: [{ null }] # run before the repl input is run + env_change: { + PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input + } + display_output: "if (term size).columns >= 100 { table -e } else { table }" # run to display the output of a pipeline + command_not_found: { null } # return an error message when a command is not found + } + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: ide_completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: ide + min_completion_width: 0, + max_completion_width: 50, + max_completion_height: 10, # will be limited by the available lines in the terminal + padding: 0, + border: true, + cursor_offset: 0, + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + # If true, the cursor pos will be corrected, so the suggestions match up with the typed text + # + # C:\> str + # str join + # str trim + # str split + correct_cursor_pos: false + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: ide_completion_menu + modifier: control + keycode: char_n + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: ide_completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: history_menu + modifier: control_shift # Changed from original ctrol to avoid conflict with fzf integration + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: history_menu } + } + # https://github.com/nushell/nushell/issues/1616#issuecomment-2120164422 + { + name: fuzzy_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "commandline edit --insert ( + history + | get command + | reverse + | uniq + | str join (char -i 0) + | fzf + --preview '{}' + --preview-window 'right:30%' + --scheme history + --read0 + --layout reverse + --height 40% + --query (commandline) + | decode utf-8 + | str trim + )" + } + ] + } + { + name: help_menu + modifier: none + keycode: f1 + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: next_page_menu + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page_menu + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: escape + modifier: none + keycode: escape + mode: [emacs, vi_normal, vi_insert] + event: { send: esc } # NOTE: does not appear to work + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [emacs, vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_q + mode: [emacs, vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuleft } + { send: left } + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { send: menuright } + { send: right } + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolineend } + } + { + name: move_up + modifier: control + keycode: char_p + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: move_down + modifier: control + keycode: char_t + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [emacs, vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [emacs, vi_insert] + event: { edit: backspaceword } + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [emacs, vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [emacs, vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_backward + modifier: control + keycode: char_h + mode: [emacs, vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [emacs, vi_insert] + event: { edit: backspaceword } + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: { edit: moveleft } + } + { + name: newline_or_run_command + modifier: none + keycode: enter + mode: emacs + event: { send: enter } + } + { + name: move_left + modifier: control + keycode: char_b + mode: emacs + event: { + until: [ + { send: menuleft } + { send: left } + ] + } + } + { + name: move_right_or_take_history_hint + modifier: control + keycode: char_f + mode: emacs + event: { + until: [ + { send: historyhintcomplete } + { send: menuright } + { send: right } + ] + } + } + { + name: redo_change + modifier: control + keycode: char_g + mode: emacs + event: { edit: redo } + } + { + name: undo_change + modifier: control + keycode: char_z + mode: emacs + event: { edit: undo } + } + { + name: paste_before + modifier: control + keycode: char_y + mode: emacs + event: { edit: pastecutbufferbefore } + } + { + name: cut_word_left + modifier: control + keycode: char_w + mode: emacs + event: { edit: cutwordleft } + } + { + name: cut_line_to_end + modifier: control + keycode: char_k + mode: emacs + event: { edit: cuttolineend } + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: emacs + event: { edit: cutfromstart } + } + { + name: swap_graphemes + modifier: control + keycode: char_t + mode: emacs + event: { edit: swapgraphemes } + } + { + name: move_one_word_left + modifier: alt + keycode: left + mode: emacs + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: right + mode: emacs + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: move_one_word_left + modifier: alt + keycode: char_b + mode: emacs + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: char_f + mode: emacs + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: delete_one_word_forward + modifier: alt + keycode: delete + mode: emacs + event: { edit: deleteword } + } + { + name: delete_one_word_backward + modifier: alt + keycode: backspace + mode: emacs + event: { edit: backspaceword } + } + { + name: delete_one_word_backward + modifier: alt + keycode: char_m + mode: emacs + event: { edit: backspaceword } + } + { + name: cut_word_to_right + modifier: alt + keycode: char_d + mode: emacs + event: { edit: cutwordright } + } + { + name: upper_case_word + modifier: alt + keycode: char_u + mode: emacs + event: { edit: uppercaseword } + } + { + name: lower_case_word + modifier: alt + keycode: char_l + mode: emacs + event: { edit: lowercaseword } + } + { + name: capitalize_char + modifier: alt + keycode: char_c + mode: emacs + event: { edit: capitalizechar } + } + # The following bindings with `*system` events require that Nushell has + # been compiled with the `system-clipboard` feature. + # If you want to use the system clipboard for visual selection or to + # paste directly, uncomment the respective lines and replace the version + # using the internal clipboard. + { + name: copy_selection + modifier: control_shift + keycode: char_c + mode: emacs + event: { edit: copyselection } + # event: { edit: copyselectionsystem } + } + { + name: cut_selection + modifier: control_shift + keycode: char_x + mode: emacs + event: { edit: cutselection } + # event: { edit: cutselectionsystem } + } + # { + # name: paste_system + # modifier: control_shift + # keycode: char_v + # mode: emacs + # event: { edit: pastesystem } + # } + { + name: select_all + modifier: control_shift + keycode: char_a + mode: emacs + event: { edit: selectall } + } + ] +} + +use ~/.cache/starship/init.nu + +source ~/.zoxide.nu + +def la [] { ls --all | sort-by type modified } diff --git a/config/nushell/env.nu b/config/nushell/env.nu new file mode 100755 index 00000000..03a6e276 --- /dev/null +++ b/config/nushell/env.nu @@ -0,0 +1,106 @@ +# Nushell Environment Config File +# +# version = "0.98.0" + +def create_left_prompt [] { + let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { + null => $env.PWD + '' => '~' + $relative_pwd => ([~ $relative_pwd] | path join) + } + + let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) + let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) + let path_segment = $"($path_color)($dir)(ansi reset)" + + $path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)" +} + +def create_right_prompt [] { + # create a right prompt in magenta with green separators and am/pm underlined + let time_segment = ([ + (ansi reset) + (ansi magenta) + (date now | format date '%x %X') # try to respect user's locale + ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | + str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") + + let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + (ansi rb) + ($env.LAST_EXIT_CODE) + ] | str join) + } else { "" } + + ([$last_exit_code, (char space), $time_segment] | str join) +} + +# Use nushell functions to define your right and left prompt +$env.PROMPT_COMMAND = {|| create_left_prompt } +# FIXME: This default is not implemented in rust code as of 2023-09-08. +$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } + +# The prompt indicators are environmental variables that represent +# the state of the prompt +$env.PROMPT_INDICATOR = {|| "> " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } + +# If you want previously entered commands to have a different prompt from the usual one, +# you can uncomment one or more of the following lines. +# This can be useful if you have a 2-line prompt and it's taking up a lot of space +# because every command entered takes up 2 lines instead of 1. You can then uncomment +# the line below so that previously entered commands show with a single `🚀`. +# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " } +# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" } +# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" } + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +$env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# The default for this is $nu.default-config-dir/scripts +$env.NU_LIB_DIRS = [ + ($nu.default-config-dir | path join 'scripts') # add /scripts + ($nu.data-dir | path join 'completions') # default home for nushell completions +] + +# Directories to search for plugin binaries when calling register +# The default for this is $nu.default-config-dir/plugins +$env.NU_PLUGIN_DIRS = [ + ($nu.default-config-dir | path join 'plugins') # add /plugins +] + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') +# An alternate way to add entries to $env.PATH is to use the custom command `path add` +# which is built into the nushell stdlib: +# use std "path add" +# $env.PATH = ($env.PATH | split row (char esep)) +# path add /some/path +# path add ($env.CARGO_HOME | path join "bin") +# path add ($env.HOME | path join ".local" "bin") +# $env.PATH = ($env.PATH | uniq) + +# To load from a custom file you can use: +# source ($nu.default-config-dir | path join 'custom.nu') + +mkdir ~/.cache/starship +starship init nu | save -f ~/.cache/starship/init.nu + +zoxide init nushell | save -f ~/.zoxide.nu diff --git a/config/powershell/Profile.ps1 b/config/powershell/Profile.ps1 index 87458ee4..b0ae7bf2 100644 --- a/config/powershell/Profile.ps1 +++ b/config/powershell/Profile.ps1 @@ -20,6 +20,8 @@ function la { # https://github.com/microsoft/winget-cli/issues/2498#issuecomment-1553863082 $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") +# Specify `bash -i` to run the bash as interactive mode +[Environment]::SetEnvironmentVariable("RCLONE_PASSWORD_COMMAND", 'wsl.exe --exec bash -ic "gopass show rclone"') Invoke-Expression (&starship init powershell) Invoke-Expression (& { (zoxide init powershell | Out-String) }) diff --git a/config/pwa/amazon_music.desktop b/config/pwa/amazon_music.desktop new file mode 100644 index 00000000..1855281c --- /dev/null +++ b/config/pwa/amazon_music.desktop @@ -0,0 +1,9 @@ +#!/usr/bin/env xdg-open +[Desktop Entry] +Version=1.0 +Terminal=false +Type=Application +Name=Amazon Music +Exec=google-chrome-stable "--profile-directory=Profile 1" --app-id=dojpeppajphepagdhclblkkjnoaeamee +Icon=chrome-dojpeppajphepagdhclblkkjnoaeamee-Profile_1 +StartupWMClass=crx_dojpeppajphepagdhclblkkjnoaeamee diff --git a/config/rclone.md b/config/rclone.md index f4411d8a..4b584cb8 100644 --- a/config/rclone.md +++ b/config/rclone.md @@ -26,25 +26,12 @@ See [rclone with Google Drive](https://rclone.org/drive) for detail. ## Restore Config -Assume you encrypted the config +Don't save the file in this repository even if it is encrypted with agenix or sops-nix.\ +See for the detail. -```bash -rclone config touch -hx "$(rclone config file | tail -1)" -``` - -Don't save the file in this repository even if it is encrypted with agenix or sops-nix. - -## Persist the token in a session +## Decrypt the config in a session -Always need the token when modifying config is too annoy.\ -Now it reads from `RCLONE_PASSWORD_COMMAND`.\ -Or directly set `RCLONE_CONFIG_PASS` as this.\ -(`read -s` does not work in zsh) - -```bash -export RCLONE_CONFIG_PASS="$(hx)" -``` +The token should be injected with `RCLONE_PASSWORD_COMMAND`. ## Mount diff --git a/config/starship/starship.toml b/config/starship/starship.toml index 58a87ed4..8552a572 100644 --- a/config/starship/starship.toml +++ b/config/starship/starship.toml @@ -3,13 +3,14 @@ format = """ $username\ $hostname\ +$os\ +$container\ $shlvl\ $directory\ $git_branch\ $git_commit\ $git_state\ $git_status\ -$direnv\ $crystal\ $elm\ $haskell\ @@ -19,13 +20,14 @@ $ruby\ $python\ $deno\ $nodejs\ -$cmd_duration\ -$container\ +$direnv\ $nix_shell\ $shell\ -$line_break\ +$jobs\ $time\ +$cmd_duration\ $status\ +$line_break\ $character""" # https://www.reddit.com/r/NixOS/comments/17eb1ym/comment/k62nxo4/?utm_source=reddit&utm_medium=web2x&context=3 @@ -36,21 +38,26 @@ disabled = false style = "blue" [direnv] -# Do not enable until https://github.com/starship/starship/pull/5657 is released -disabled = true +disabled = false +# https://github.com/direnv/direnv-logo/blob/0949c12bafa532da0b23482a1bb042cf41b654fc/direnv-logo.png +symbol = '📁' +loaded_msg = '🍃' +unloaded_msg = '🍂' +format = '[$symbol$loaded]($style) ' [character] success_symbol = "[>](bold green)" -error_symbol = "[!](italic purple)" +error_symbol = "[>](bold red)" [status] disabled = false # Displays as a part of character module -style = "italic purple" +style = "bold red" format = "[$status]($style)" [git_commit] only_detached = false +tag_disabled = false [git_branch] format = "[$branch]($style)" @@ -59,31 +66,26 @@ format = "[$branch]($style)" style = "242" [git_status] -format = "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)" -style = "cyan" -conflicted = "​" -untracked = "​" -modified = "​" -staged = "​" -renamed = "​" -deleted = "​" -stashed = "≡" +style = "purple" [git_state] -format = '\([$state( $progress_current/$progress_total)]($style)\) ' style = "bright-black" [cmd_duration] format = "[$duration]($style) " style = "yellow" -[python] -format = "[$virtualenv]($style) " -style = "bright-black" - [shell] disabled = false bash_indicator = 'bash' [container] disabled = false + +[os] +disabled = false + +[nix_shell] +# Set another character with NixOS and keep short +symbol = '☃️ ' +format = '[$symbol]($style) ' diff --git a/config/vscode/settings.json b/config/vscode/settings.json index febc7e28..00b80af4 100644 --- a/config/vscode/settings.json +++ b/config/vscode/settings.json @@ -102,5 +102,6 @@ "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?", "workbench.colorTheme": "Blueberry Brackets dark theme", "stylua.searchBinaryInPATH": true, + "shellformat.useEditorConfig": true, "editor.cursorSurroundingLines": 5 } diff --git a/config/zed/settings.json b/config/zed/settings.json index 95b2e9f2..64d8dab3 100644 --- a/config/zed/settings.json +++ b/config/zed/settings.json @@ -7,21 +7,75 @@ // custom settings, run the `open default settings` command // from the command palette or from `Zed` application menu. { - "theme": "Base16 Oxocarbon Dark", + "theme": "Base16 iA Dark", "telemetry": { "metrics": false }, "auto_update": false, "soft_wrap": "editor_width", "ui_font_family": "PlemolJP Console NF", - "ui_font_size": 16, + "ui_font_size": 14, "buffer_font_family": "PlemolJP Console NF", - "buffer_font_size": 16, + "buffer_font_size": 14, + "tabs": { + "file_icons": true + }, + // FIXME: Actually not working... + "lsp": { + "vscode-json-language-server": { + "binary": { + "path": "/run/current-system/sw/bin/vscode-json-language-server", + "arguments": ["--stdio"] + } + }, + "json-language-server": { + "binary": { + "path": "/run/current-system/sw/bin/vscode-json-language-server", + "arguments": ["--stdio"] + } + }, + "bash-language-server": { + "binary": { + "path": "/run/current-system/sw/bin/bash-language-server", + "arguments": ["start"] + } + } + }, + "languages": { + "JSON": { + // "enable_language_server": false, // Didn't disable with this option + "language_servers": ["vscode-json-language-server", "!json-language-server"] + }, + "JSONC": { + // "enable_language_server": false, // Didn't disable with this option + "language_servers": ["vscode-json-language-server", "!json-language-server"] + }, + "YAML": { + "enable_language_server": false + }, + "Shell Script": { + "enable_language_server": false + } + }, + "terminal": { + "shell": { + "program": "zsh" + }, + "copy_on_select": true // Looks not working. + // TODO: Track https://github.com/zed-industries/zed/issues/18507 + // "cursor_shape": "bar" + }, "auto_install_extensions": { "nix": true, "toml": true, + "typos": true, + "ruby": true, "lua": true, + "kdl": true, "basher": true, - "base16": true + "powershell": true, + "fish": true, + "base16": true, + "iceberg": true } } diff --git a/config/zellij/layouts/dotfiles.kdl b/config/zellij/layouts/dotfiles.kdl index 66456077..576334cd 100644 --- a/config/zellij/layouts/dotfiles.kdl +++ b/config/zellij/layouts/dotfiles.kdl @@ -1,13 +1,10 @@ layout { tab focus=true name="Filer" { - pane size=2 borderless=true { - plugin location="zellij:status-bar" - } pane size=1 borderless=true { - plugin location="zellij:tab-bar" + plugin location="zellij:compact-bar" } pane split_direction="horizontal" { - pane size="80%" command="yazi" { + pane size="80%" command="yazi" close_on_exit=false { } pane size="20%" { @@ -16,11 +13,8 @@ layout { } } tab name="BPS" { - pane size=2 borderless=true { - plugin location="zellij:status-bar" - } pane size=1 borderless=true { - plugin location="zellij:tab-bar" + plugin location="zellij:compact-bar" } pane split_direction="vertical" { pane size="70%" { @@ -33,19 +27,28 @@ layout { } } tab name="dconf" { - pane size=2 borderless=true { - plugin location="zellij:status-bar" - } pane size=1 borderless=true { - plugin location="zellij:tab-bar" + plugin location="zellij:compact-bar" + } + // Don't use edit pane. close_on_exit is only available in command panes + pane name="edit" command="hx" size="70%" close_on_exit=false { + args "home-manager/gnome.nix" } - pane name="edit" edit="home-manager/gnome.nix" size="70%" pane split_direction="vertical" size="30%" { - pane name="watch" start_suspended=true command="dconf" { + pane name="watch" start_suspended=true command="dconf" close_on_exit=false { args "watch" "/" start_suspended true } - pane name="blank" + pane name="blank" command="zsh" close_on_exit=false + } + } + tab name="Help" { + pane size=1 borderless=true { + plugin location="zellij:compact-bar" + } + pane + pane size=2 borderless=true { + plugin location="zellij:status-bar" } } } diff --git a/config/zellij/layouts/regular.kdl b/config/zellij/layouts/regular.kdl index 9333ecba..b1af49e0 100644 --- a/config/zellij/layouts/regular.kdl +++ b/config/zellij/layouts/regular.kdl @@ -10,7 +10,7 @@ layout { plugin location="zellij:compact-bar" } pane split_direction="horizontal" { - pane size="80%" command="yazi" { + pane size="80%" command="yazi" close_on_exit=false { } pane size="20%" { @@ -55,7 +55,7 @@ layout { // plugin location="zellij:compact-bar" // } pane size=1 borderless=true { - plugin location="zellij:tab-bar" + plugin location="zellij:compact-bar" } pane pane size=2 borderless=true { diff --git a/containers/Containerfile b/containers/Containerfile index 9f1805c4..ceebf7c3 100644 --- a/containers/Containerfile +++ b/containers/Containerfile @@ -1,5 +1,5 @@ # https://github.com/kachick/containers -FROM ghcr.io/kachick/ubuntu-24.04-nix-systemd:20240515-154517-utc +FROM ghcr.io/kachick/ubuntu-24.04-nix-systemd:latest@sha256:add9000002243eb614237536ad2b32938230904cd7567fcf46eb49efc68cb4c9 LABEL org.opencontainers.image.source=https://github.com/kachick/dotfiles LABEL org.opencontainers.image.description="Example by kachick/dotfiles" diff --git a/containers/README.md b/containers/README.md index f7a9ab32..6f4a9df4 100644 --- a/containers/README.md +++ b/containers/README.md @@ -1,5 +1,7 @@ # Containers +Base images are maintained in [another repository](https://github.com/kachick/containers) + ## How to build and test in local ```bash diff --git a/darwin/README.md b/darwin/README.md index 520dff31..5bd92e5a 100644 --- a/darwin/README.md +++ b/darwin/README.md @@ -1,15 +1,3 @@ # macOS - darwin -## Missing parts in Nix and home-manager - -Several packages are missing or broken for darwin. Or the x86-64 darwin.\ -So you should manually install followings. - -- [vscode](https://code.visualstudio.com/download) -- [zed-editor](https://zed.dev/download) -- [podman-desktop](https://podman-desktop.io/downloads) - -## Limitations - -- I only have x86-64 macbook pro, it is much slow in GitHub action macos-13 runner.\ - So preferring macos-14 runner in several place... +Extracted to [wiki](https://github.com/kachick/dotfiles/wiki/macOS) diff --git a/dependencies/goldwarden/completions.bash b/dependencies/goldwarden/completions.bash deleted file mode 100644 index 559572f5..00000000 --- a/dependencies/goldwarden/completions.bash +++ /dev/null @@ -1,338 +0,0 @@ -# bash completion V2 for goldwarden -*- shell-script -*- - -__goldwarden_debug() -{ - if [[ -n ${BASH_COMP_DEBUG_FILE-} ]]; then - echo "$*" >> "${BASH_COMP_DEBUG_FILE}" - fi -} - -# Macs have bash3 for which the bash-completion package doesn't include -# _init_completion. This is a minimal version of that function. -__goldwarden_init_completion() -{ - COMPREPLY=() - _get_comp_words_by_ref "$@" cur prev words cword -} - -# This function calls the goldwarden program to obtain the completion -# results and the directive. It fills the 'out' and 'directive' vars. -__goldwarden_get_completion_results() { - local requestComp lastParam lastChar args - - # Prepare the command to request completions for the program. - # Calling ${words[0]} instead of directly goldwarden allows handling aliases - args=("${words[@]:1}") - requestComp="${words[0]} __complete ${args[*]}" - - lastParam=${words[$((${#words[@]}-1))]} - lastChar=${lastParam:$((${#lastParam}-1)):1} - __goldwarden_debug "lastParam ${lastParam}, lastChar ${lastChar}" - - if [[ -z ${cur} && ${lastChar} != = ]]; then - # If the last parameter is complete (there is a space following it) - # We add an extra empty parameter so we can indicate this to the go method. - __goldwarden_debug "Adding extra empty parameter" - requestComp="${requestComp} ''" - fi - - # When completing a flag with an = (e.g., goldwarden -n=) - # bash focuses on the part after the =, so we need to remove - # the flag part from $cur - if [[ ${cur} == -*=* ]]; then - cur="${cur#*=}" - fi - - __goldwarden_debug "Calling ${requestComp}" - # Use eval to handle any environment variables and such - out=$(eval "${requestComp}" 2>/dev/null) - - # Extract the directive integer at the very end of the output following a colon (:) - directive=${out##*:} - # Remove the directive - out=${out%:*} - if [[ ${directive} == "${out}" ]]; then - # There is not directive specified - directive=0 - fi - __goldwarden_debug "The completion directive is: ${directive}" - __goldwarden_debug "The completions are: ${out}" -} - -__goldwarden_process_completion_results() { - local shellCompDirectiveError=1 - local shellCompDirectiveNoSpace=2 - local shellCompDirectiveNoFileComp=4 - local shellCompDirectiveFilterFileExt=8 - local shellCompDirectiveFilterDirs=16 - local shellCompDirectiveKeepOrder=32 - - if (((directive & shellCompDirectiveError) != 0)); then - # Error code. No completion. - __goldwarden_debug "Received error from custom completion go code" - return - else - if (((directive & shellCompDirectiveNoSpace) != 0)); then - if [[ $(type -t compopt) == builtin ]]; then - __goldwarden_debug "Activating no space" - compopt -o nospace - else - __goldwarden_debug "No space directive not supported in this version of bash" - fi - fi - if (((directive & shellCompDirectiveKeepOrder) != 0)); then - if [[ $(type -t compopt) == builtin ]]; then - # no sort isn't supported for bash less than < 4.4 - if [[ ${BASH_VERSINFO[0]} -lt 4 || ( ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 4 ) ]]; then - __goldwarden_debug "No sort directive not supported in this version of bash" - else - __goldwarden_debug "Activating keep order" - compopt -o nosort - fi - else - __goldwarden_debug "No sort directive not supported in this version of bash" - fi - fi - if (((directive & shellCompDirectiveNoFileComp) != 0)); then - if [[ $(type -t compopt) == builtin ]]; then - __goldwarden_debug "Activating no file completion" - compopt +o default - else - __goldwarden_debug "No file completion directive not supported in this version of bash" - fi - fi - fi - - # Separate activeHelp from normal completions - local completions=() - local activeHelp=() - __goldwarden_extract_activeHelp - - if (((directive & shellCompDirectiveFilterFileExt) != 0)); then - # File extension filtering - local fullFilter filter filteringCmd - - # Do not use quotes around the $completions variable or else newline - # characters will be kept. - for filter in ${completions[*]}; do - fullFilter+="$filter|" - done - - filteringCmd="_filedir $fullFilter" - __goldwarden_debug "File filtering command: $filteringCmd" - $filteringCmd - elif (((directive & shellCompDirectiveFilterDirs) != 0)); then - # File completion for directories only - - local subdir - subdir=${completions[0]} - if [[ -n $subdir ]]; then - __goldwarden_debug "Listing directories in $subdir" - pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return - else - __goldwarden_debug "Listing directories in ." - _filedir -d - fi - else - __goldwarden_handle_completion_types - fi - - __goldwarden_handle_special_char "$cur" : - __goldwarden_handle_special_char "$cur" = - - # Print the activeHelp statements before we finish - if ((${#activeHelp[*]} != 0)); then - printf "\n"; - printf "%s\n" "${activeHelp[@]}" - printf "\n" - - # The prompt format is only available from bash 4.4. - # We test if it is available before using it. - if (x=${PS1@P}) 2> /dev/null; then - printf "%s" "${PS1@P}${COMP_LINE[@]}" - else - # Can't print the prompt. Just print the - # text the user had typed, it is workable enough. - printf "%s" "${COMP_LINE[@]}" - fi - fi -} - -# Separate activeHelp lines from real completions. -# Fills the $activeHelp and $completions arrays. -__goldwarden_extract_activeHelp() { - local activeHelpMarker="_activeHelp_ " - local endIndex=${#activeHelpMarker} - - while IFS='' read -r comp; do - if [[ ${comp:0:endIndex} == $activeHelpMarker ]]; then - comp=${comp:endIndex} - __goldwarden_debug "ActiveHelp found: $comp" - if [[ -n $comp ]]; then - activeHelp+=("$comp") - fi - else - # Not an activeHelp line but a normal completion - completions+=("$comp") - fi - done <<<"${out}" -} - -__goldwarden_handle_completion_types() { - __goldwarden_debug "__goldwarden_handle_completion_types: COMP_TYPE is $COMP_TYPE" - - case $COMP_TYPE in - 37|42) - # Type: menu-complete/menu-complete-backward and insert-completions - # If the user requested inserting one completion at a time, or all - # completions at once on the command-line we must remove the descriptions. - # https://github.com/spf13/cobra/issues/1508 - local tab=$'\t' comp - while IFS='' read -r comp; do - [[ -z $comp ]] && continue - # Strip any description - comp=${comp%%$tab*} - # Only consider the completions that match - if [[ $comp == "$cur"* ]]; then - COMPREPLY+=("$comp") - fi - done < <(printf "%s\n" "${completions[@]}") - ;; - - *) - # Type: complete (normal completion) - __goldwarden_handle_standard_completion_case - ;; - esac -} - -__goldwarden_handle_standard_completion_case() { - local tab=$'\t' comp - - # Short circuit to optimize if we don't have descriptions - if [[ "${completions[*]}" != *$tab* ]]; then - IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${completions[*]}" -- "$cur") - return 0 - fi - - local longest=0 - local compline - # Look for the longest completion so that we can format things nicely - while IFS='' read -r compline; do - [[ -z $compline ]] && continue - # Strip any description before checking the length - comp=${compline%%$tab*} - # Only consider the completions that match - [[ $comp == "$cur"* ]] || continue - COMPREPLY+=("$compline") - if ((${#comp}>longest)); then - longest=${#comp} - fi - done < <(printf "%s\n" "${completions[@]}") - - # If there is a single completion left, remove the description text - if ((${#COMPREPLY[*]} == 1)); then - __goldwarden_debug "COMPREPLY[0]: ${COMPREPLY[0]}" - comp="${COMPREPLY[0]%%$tab*}" - __goldwarden_debug "Removed description from single completion, which is now: ${comp}" - COMPREPLY[0]=$comp - else # Format the descriptions - __goldwarden_format_comp_descriptions $longest - fi -} - -__goldwarden_handle_special_char() -{ - local comp="$1" - local char=$2 - if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then - local word=${comp%"${comp##*${char}}"} - local idx=${#COMPREPLY[*]} - while ((--idx >= 0)); do - COMPREPLY[idx]=${COMPREPLY[idx]#"$word"} - done - fi -} - -__goldwarden_format_comp_descriptions() -{ - local tab=$'\t' - local comp desc maxdesclength - local longest=$1 - - local i ci - for ci in ${!COMPREPLY[*]}; do - comp=${COMPREPLY[ci]} - # Properly format the description string which follows a tab character if there is one - if [[ "$comp" == *$tab* ]]; then - __goldwarden_debug "Original comp: $comp" - desc=${comp#*$tab} - comp=${comp%%$tab*} - - # $COLUMNS stores the current shell width. - # Remove an extra 4 because we add 2 spaces and 2 parentheses. - maxdesclength=$(( COLUMNS - longest - 4 )) - - # Make sure we can fit a description of at least 8 characters - # if we are to align the descriptions. - if ((maxdesclength > 8)); then - # Add the proper number of spaces to align the descriptions - for ((i = ${#comp} ; i < longest ; i++)); do - comp+=" " - done - else - # Don't pad the descriptions so we can fit more text after the completion - maxdesclength=$(( COLUMNS - ${#comp} - 4 )) - fi - - # If there is enough space for any description text, - # truncate the descriptions that are too long for the shell width - if ((maxdesclength > 0)); then - if ((${#desc} > maxdesclength)); then - desc=${desc:0:$(( maxdesclength - 1 ))} - desc+="…" - fi - comp+=" ($desc)" - fi - COMPREPLY[ci]=$comp - __goldwarden_debug "Final comp: $comp" - fi - done -} - -__start_goldwarden() -{ - local cur prev words cword split - - COMPREPLY=() - - # Call _init_completion from the bash-completion package - # to prepare the arguments properly - if declare -F _init_completion >/dev/null 2>&1; then - _init_completion -n =: || return - else - __goldwarden_init_completion -n =: || return - fi - - __goldwarden_debug - __goldwarden_debug "========= starting completion logic ==========" - __goldwarden_debug "cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}, cword is $cword" - - # The user could have moved the cursor backwards on the command-line. - # We need to trigger completion from the $cword location, so we need - # to truncate the command-line ($words) up to the $cword location. - words=("${words[@]:0:$cword+1}") - __goldwarden_debug "Truncated words[*]: ${words[*]}," - - local out directive - __goldwarden_get_completion_results - __goldwarden_process_completion_results -} - -if [[ $(type -t compopt) = "builtin" ]]; then - complete -o default -F __start_goldwarden goldwarden -else - complete -o default -o nospace -F __start_goldwarden goldwarden -fi - -# ex: ts=4 sw=4 et filetype=sh diff --git a/dependencies/goldwarden/completions.fish b/dependencies/goldwarden/completions.fish deleted file mode 100644 index 94c59285..00000000 --- a/dependencies/goldwarden/completions.fish +++ /dev/null @@ -1,235 +0,0 @@ -# fish completion for goldwarden -*- shell-script -*- - -function __goldwarden_debug - set -l file "$BASH_COMP_DEBUG_FILE" - if test -n "$file" - echo "$argv" >> $file - end -end - -function __goldwarden_perform_completion - __goldwarden_debug "Starting __goldwarden_perform_completion" - - # Extract all args except the last one - set -l args (commandline -opc) - # Extract the last arg and escape it in case it is a space - set -l lastArg (string escape -- (commandline -ct)) - - __goldwarden_debug "args: $args" - __goldwarden_debug "last arg: $lastArg" - - # Disable ActiveHelp which is not supported for fish shell - set -l requestComp "GOLDWARDEN_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg" - - __goldwarden_debug "Calling $requestComp" - set -l results (eval $requestComp 2> /dev/null) - - # Some programs may output extra empty lines after the directive. - # Let's ignore them or else it will break completion. - # Ref: https://github.com/spf13/cobra/issues/1279 - for line in $results[-1..1] - if test (string trim -- $line) = "" - # Found an empty line, remove it - set results $results[1..-2] - else - # Found non-empty line, we have our proper output - break - end - end - - set -l comps $results[1..-2] - set -l directiveLine $results[-1] - - # For Fish, when completing a flag with an = (e.g., -n=) - # completions must be prefixed with the flag - set -l flagPrefix (string match -r -- '-.*=' "$lastArg") - - __goldwarden_debug "Comps: $comps" - __goldwarden_debug "DirectiveLine: $directiveLine" - __goldwarden_debug "flagPrefix: $flagPrefix" - - for comp in $comps - printf "%s%s\n" "$flagPrefix" "$comp" - end - - printf "%s\n" "$directiveLine" -end - -# this function limits calls to __goldwarden_perform_completion, by caching the result behind $__goldwarden_perform_completion_once_result -function __goldwarden_perform_completion_once - __goldwarden_debug "Starting __goldwarden_perform_completion_once" - - if test -n "$__goldwarden_perform_completion_once_result" - __goldwarden_debug "Seems like a valid result already exists, skipping __goldwarden_perform_completion" - return 0 - end - - set --global __goldwarden_perform_completion_once_result (__goldwarden_perform_completion) - if test -z "$__goldwarden_perform_completion_once_result" - __goldwarden_debug "No completions, probably due to a failure" - return 1 - end - - __goldwarden_debug "Performed completions and set __goldwarden_perform_completion_once_result" - return 0 -end - -# this function is used to clear the $__goldwarden_perform_completion_once_result variable after completions are run -function __goldwarden_clear_perform_completion_once_result - __goldwarden_debug "" - __goldwarden_debug "========= clearing previously set __goldwarden_perform_completion_once_result variable ==========" - set --erase __goldwarden_perform_completion_once_result - __goldwarden_debug "Successfully erased the variable __goldwarden_perform_completion_once_result" -end - -function __goldwarden_requires_order_preservation - __goldwarden_debug "" - __goldwarden_debug "========= checking if order preservation is required ==========" - - __goldwarden_perform_completion_once - if test -z "$__goldwarden_perform_completion_once_result" - __goldwarden_debug "Error determining if order preservation is required" - return 1 - end - - set -l directive (string sub --start 2 $__goldwarden_perform_completion_once_result[-1]) - __goldwarden_debug "Directive is: $directive" - - set -l shellCompDirectiveKeepOrder 32 - set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2) - __goldwarden_debug "Keeporder is: $keeporder" - - if test $keeporder -ne 0 - __goldwarden_debug "This does require order preservation" - return 0 - end - - __goldwarden_debug "This doesn't require order preservation" - return 1 -end - - -# This function does two things: -# - Obtain the completions and store them in the global __goldwarden_comp_results -# - Return false if file completion should be performed -function __goldwarden_prepare_completions - __goldwarden_debug "" - __goldwarden_debug "========= starting completion logic ==========" - - # Start fresh - set --erase __goldwarden_comp_results - - __goldwarden_perform_completion_once - __goldwarden_debug "Completion results: $__goldwarden_perform_completion_once_result" - - if test -z "$__goldwarden_perform_completion_once_result" - __goldwarden_debug "No completion, probably due to a failure" - # Might as well do file completion, in case it helps - return 1 - end - - set -l directive (string sub --start 2 $__goldwarden_perform_completion_once_result[-1]) - set --global __goldwarden_comp_results $__goldwarden_perform_completion_once_result[1..-2] - - __goldwarden_debug "Completions are: $__goldwarden_comp_results" - __goldwarden_debug "Directive is: $directive" - - set -l shellCompDirectiveError 1 - set -l shellCompDirectiveNoSpace 2 - set -l shellCompDirectiveNoFileComp 4 - set -l shellCompDirectiveFilterFileExt 8 - set -l shellCompDirectiveFilterDirs 16 - - if test -z "$directive" - set directive 0 - end - - set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2) - if test $compErr -eq 1 - __goldwarden_debug "Received error directive: aborting." - # Might as well do file completion, in case it helps - return 1 - end - - set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2) - set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2) - if test $filefilter -eq 1; or test $dirfilter -eq 1 - __goldwarden_debug "File extension filtering or directory filtering not supported" - # Do full file completion instead - return 1 - end - - set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2) - set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2) - - __goldwarden_debug "nospace: $nospace, nofiles: $nofiles" - - # If we want to prevent a space, or if file completion is NOT disabled, - # we need to count the number of valid completions. - # To do so, we will filter on prefix as the completions we have received - # may not already be filtered so as to allow fish to match on different - # criteria than the prefix. - if test $nospace -ne 0; or test $nofiles -eq 0 - set -l prefix (commandline -t | string escape --style=regex) - __goldwarden_debug "prefix: $prefix" - - set -l completions (string match -r -- "^$prefix.*" $__goldwarden_comp_results) - set --global __goldwarden_comp_results $completions - __goldwarden_debug "Filtered completions are: $__goldwarden_comp_results" - - # Important not to quote the variable for count to work - set -l numComps (count $__goldwarden_comp_results) - __goldwarden_debug "numComps: $numComps" - - if test $numComps -eq 1; and test $nospace -ne 0 - # We must first split on \t to get rid of the descriptions to be - # able to check what the actual completion will be. - # We don't need descriptions anyway since there is only a single - # real completion which the shell will expand immediately. - set -l split (string split --max 1 \t $__goldwarden_comp_results[1]) - - # Fish won't add a space if the completion ends with any - # of the following characters: @=/:., - set -l lastChar (string sub -s -1 -- $split) - if not string match -r -q "[@=/:.,]" -- "$lastChar" - # In other cases, to support the "nospace" directive we trick the shell - # by outputting an extra, longer completion. - __goldwarden_debug "Adding second completion to perform nospace directive" - set --global __goldwarden_comp_results $split[1] $split[1]. - __goldwarden_debug "Completions are now: $__goldwarden_comp_results" - end - end - - if test $numComps -eq 0; and test $nofiles -eq 0 - # To be consistent with bash and zsh, we only trigger file - # completion when there are no other completions - __goldwarden_debug "Requesting file completion" - return 1 - end - end - - return 0 -end - -# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves -# so we can properly delete any completions provided by another script. -# Only do this if the program can be found, or else fish may print some errors; besides, -# the existing completions will only be loaded if the program can be found. -if type -q "goldwarden" - # The space after the program name is essential to trigger completion for the program - # and not completion of the program name itself. - # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish. - complete --do-complete "goldwarden " > /dev/null 2>&1 -end - -# Remove any pre-existing completions for the program since we will be handling all of them. -complete -c goldwarden -e - -# this will get called after the two calls below and clear the $__goldwarden_perform_completion_once_result global -complete -c goldwarden -n '__goldwarden_clear_perform_completion_once_result' -# The call to __goldwarden_prepare_completions will setup __goldwarden_comp_results -# which provides the program's completion choices. -# If this doesn't require order preservation, we don't use the -k flag -complete -c goldwarden -n 'not __goldwarden_requires_order_preservation && __goldwarden_prepare_completions' -f -a '$__goldwarden_comp_results' -# otherwise we use the -k flag -complete -k -c goldwarden -n '__goldwarden_requires_order_preservation && __goldwarden_prepare_completions' -f -a '$__goldwarden_comp_results' diff --git a/dependencies/goldwarden/completions.zsh b/dependencies/goldwarden/completions.zsh deleted file mode 100644 index 8957b37a..00000000 --- a/dependencies/goldwarden/completions.zsh +++ /dev/null @@ -1,212 +0,0 @@ -#compdef goldwarden -compdef _goldwarden goldwarden - -# zsh completion for goldwarden -*- shell-script -*- - -__goldwarden_debug() -{ - local file="$BASH_COMP_DEBUG_FILE" - if [[ -n ${file} ]]; then - echo "$*" >> "${file}" - fi -} - -_goldwarden() -{ - local shellCompDirectiveError=1 - local shellCompDirectiveNoSpace=2 - local shellCompDirectiveNoFileComp=4 - local shellCompDirectiveFilterFileExt=8 - local shellCompDirectiveFilterDirs=16 - local shellCompDirectiveKeepOrder=32 - - local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder - local -a completions - - __goldwarden_debug "\n========= starting completion logic ==========" - __goldwarden_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}" - - # The user could have moved the cursor backwards on the command-line. - # We need to trigger completion from the $CURRENT location, so we need - # to truncate the command-line ($words) up to the $CURRENT location. - # (We cannot use $CURSOR as its value does not work when a command is an alias.) - words=("${=words[1,CURRENT]}") - __goldwarden_debug "Truncated words[*]: ${words[*]}," - - lastParam=${words[-1]} - lastChar=${lastParam[-1]} - __goldwarden_debug "lastParam: ${lastParam}, lastChar: ${lastChar}" - - # For zsh, when completing a flag with an = (e.g., goldwarden -n=) - # completions must be prefixed with the flag - setopt local_options BASH_REMATCH - if [[ "${lastParam}" =~ '-.*=' ]]; then - # We are dealing with a flag with an = - flagPrefix="-P ${BASH_REMATCH}" - fi - - # Prepare the command to obtain completions - requestComp="${words[1]} __complete ${words[2,-1]}" - if [ "${lastChar}" = "" ]; then - # If the last parameter is complete (there is a space following it) - # We add an extra empty parameter so we can indicate this to the go completion code. - __goldwarden_debug "Adding extra empty parameter" - requestComp="${requestComp} \"\"" - fi - - __goldwarden_debug "About to call: eval ${requestComp}" - - # Use eval to handle any environment variables and such - out=$(eval ${requestComp} 2>/dev/null) - __goldwarden_debug "completion output: ${out}" - - # Extract the directive integer following a : from the last line - local lastLine - while IFS='\n' read -r line; do - lastLine=${line} - done < <(printf "%s\n" "${out[@]}") - __goldwarden_debug "last line: ${lastLine}" - - if [ "${lastLine[1]}" = : ]; then - directive=${lastLine[2,-1]} - # Remove the directive including the : and the newline - local suffix - (( suffix=${#lastLine}+2)) - out=${out[1,-$suffix]} - else - # There is no directive specified. Leave $out as is. - __goldwarden_debug "No directive found. Setting do default" - directive=0 - fi - - __goldwarden_debug "directive: ${directive}" - __goldwarden_debug "completions: ${out}" - __goldwarden_debug "flagPrefix: ${flagPrefix}" - - if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then - __goldwarden_debug "Completion received error. Ignoring completions." - return - fi - - local activeHelpMarker="_activeHelp_ " - local endIndex=${#activeHelpMarker} - local startIndex=$((${#activeHelpMarker}+1)) - local hasActiveHelp=0 - while IFS='\n' read -r comp; do - # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker) - if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then - __goldwarden_debug "ActiveHelp found: $comp" - comp="${comp[$startIndex,-1]}" - if [ -n "$comp" ]; then - compadd -x "${comp}" - __goldwarden_debug "ActiveHelp will need delimiter" - hasActiveHelp=1 - fi - - continue - fi - - if [ -n "$comp" ]; then - # If requested, completions are returned with a description. - # The description is preceded by a TAB character. - # For zsh's _describe, we need to use a : instead of a TAB. - # We first need to escape any : as part of the completion itself. - comp=${comp//:/\\:} - - local tab="$(printf '\t')" - comp=${comp//$tab/:} - - __goldwarden_debug "Adding completion: ${comp}" - completions+=${comp} - lastComp=$comp - fi - done < <(printf "%s\n" "${out[@]}") - - # Add a delimiter after the activeHelp statements, but only if: - # - there are completions following the activeHelp statements, or - # - file completion will be performed (so there will be choices after the activeHelp) - if [ $hasActiveHelp -eq 1 ]; then - if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then - __goldwarden_debug "Adding activeHelp delimiter" - compadd -x "--" - hasActiveHelp=0 - fi - fi - - if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then - __goldwarden_debug "Activating nospace." - noSpace="-S ''" - fi - - if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then - __goldwarden_debug "Activating keep order." - keepOrder="-V" - fi - - if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then - # File extension filtering - local filteringCmd - filteringCmd='_files' - for filter in ${completions[@]}; do - if [ ${filter[1]} != '*' ]; then - # zsh requires a glob pattern to do file filtering - filter="\*.$filter" - fi - filteringCmd+=" -g $filter" - done - filteringCmd+=" ${flagPrefix}" - - __goldwarden_debug "File filtering command: $filteringCmd" - _arguments '*:filename:'"$filteringCmd" - elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then - # File completion for directories only - local subdir - subdir="${completions[1]}" - if [ -n "$subdir" ]; then - __goldwarden_debug "Listing directories in $subdir" - pushd "${subdir}" >/dev/null 2>&1 - else - __goldwarden_debug "Listing directories in ." - fi - - local result - _arguments '*:dirname:_files -/'" ${flagPrefix}" - result=$? - if [ -n "$subdir" ]; then - popd >/dev/null 2>&1 - fi - return $result - else - __goldwarden_debug "Calling _describe" - if eval _describe $keepOrder "completions" completions $flagPrefix $noSpace; then - __goldwarden_debug "_describe found some completions" - - # Return the success of having called _describe - return 0 - else - __goldwarden_debug "_describe did not find completions." - __goldwarden_debug "Checking if we should do file completion." - if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then - __goldwarden_debug "deactivating file completion" - - # We must return an error code here to let zsh know that there were no - # completions found by _describe; this is what will trigger other - # matching algorithms to attempt to find completions. - # For example zsh can match letters in the middle of words. - return 1 - else - # Perform file completion - __goldwarden_debug "Activating file completion" - - # We must return the result of this command, so it must be the - # last command, or else we must store its result to return it. - _arguments '*:filename:_files'" ${flagPrefix}" - fi - fi - fi -} - -# don't run the completion function when being source-ed or eval-ed -if [ "$funcstack[1]" = "_goldwarden" ]; then - _goldwarden -fi diff --git a/dprint.json b/dprint.json index b392223d..a03f2852 100644 --- a/dprint.json +++ b/dprint.json @@ -1,11 +1,13 @@ { + "$schema": "https://dprint.dev/schemas/v0.json", "json": { "trailingCommas": "never" }, "markdown": { }, "yaml": { - "quotes": "preferSingle" + "quotes": "preferSingle", + "trimTrailingWhitespaces": false }, "toml": { }, @@ -17,9 +19,9 @@ "dependencies" ], "plugins": [ - "https://plugins.dprint.dev/json-0.19.3.wasm", + "https://plugins.dprint.dev/json-0.19.4.wasm", "https://plugins.dprint.dev/markdown-0.17.8.wasm", - "https://plugins.dprint.dev/toml-0.6.2.wasm", + "https://plugins.dprint.dev/toml-0.6.3.wasm", "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm", "https://plugins.dprint.dev/kachick/kdl-0.1.0.wasm" ] diff --git a/flake.lock b/flake.lock index 7f2706cc..e6b4847e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,18 +1,49 @@ { "nodes": { - "crane": { + "aquamarine": { "inputs": { + "hyprutils": [ + "xremap-flake", + "hyprland", + "hyprutils" + ], + "hyprwayland-scanner": [ + "xremap-flake", + "hyprland", + "hyprwayland-scanner" + ], "nixpkgs": [ "xremap-flake", + "hyprland", "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" ] }, "locked": { - "lastModified": 1721322122, - "narHash": "sha256-a0G1NvyXGzdwgu6e1HQpmK5R5yLsfxeBe07nNDyYd+g=", + "lastModified": 1725753098, + "narHash": "sha256-/NO/h/qD/eJXAQr/fHA4mdDgYsNT9thHQ+oT6KPi2ac=", + "owner": "hyprwm", + "repo": "aquamarine", + "rev": "e4a13203112a036fc7f437d391c7810f3dd5ab52", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "aquamarine", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1725409566, + "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=", "owner": "ipetkov", "repo": "crane", - "rev": "8a68b987c476a33e90f203f0927614a75c3f47ea", + "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c", "type": "github" }, "original": { @@ -23,15 +54,14 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1717408969, - "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", "owner": "numtide", "repo": "devshell", - "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", "type": "github" }, "original": { @@ -42,11 +72,11 @@ }, "edge-nixpkgs": { "locked": { - "lastModified": 1725103162, - "narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=", + "lastModified": 1729880355, + "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b", + "rev": "18536bf04cd71abd345f9579158841376fdd0c5a", "type": "github" }, "original": { @@ -77,11 +107,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1719994518, - "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", "type": "github" }, "original": { @@ -108,24 +138,6 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -133,11 +145,11 @@ ] }, "locked": { - "lastModified": 1720042825, - "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", + "lastModified": 1726989464, + "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", "owner": "nix-community", "repo": "home-manager", - "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", + "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", "type": "github" }, "original": { @@ -149,14 +161,14 @@ }, "home-manager_2": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1721135958, - "narHash": "sha256-H548rpPMsn25LDKn1PCFmPxmWlClJJGnvdzImHkqjuY=", + "lastModified": 1726440980, + "narHash": "sha256-ChhIrjtdu5d83W+YDRH+Ec5g1MmM0xk6hJnkz15Ot7M=", "owner": "nix-community", "repo": "home-manager", - "rev": "afd2021bedff2de92dfce0e257a3d03ae65c603d", + "rev": "a9c9cc6e50f7cbd2d58ccb1cd46a1e06e9e445ff", "type": "github" }, "original": { @@ -184,11 +196,11 @@ ] }, "locked": { - "lastModified": 1720108799, - "narHash": "sha256-AxRkTJlbB8r7aG6gvc7IaLhc2T9TO4/8uqanKRxukBQ=", + "lastModified": 1722623071, + "narHash": "sha256-sLADpVgebpCBFXkA1FlCXtvEPu1tdEsTfqK1hfeHySE=", "owner": "hyprwm", "repo": "hyprcursor", - "rev": "a5c0d57325c5f0814c39110a70ca19c070ae9486", + "rev": "912d56025f03d41b1ad29510c423757b4379eb1c", "type": "github" }, "original": { @@ -199,20 +211,21 @@ }, "hyprland": { "inputs": { + "aquamarine": "aquamarine", "hyprcursor": "hyprcursor", "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", - "nixpkgs": "nixpkgs_5", - "systems": "systems_3", + "nixpkgs": "nixpkgs_4", + "systems": "systems_2", "xdph": "xdph" }, "locked": { - "lastModified": 1721463092, - "narHash": "sha256-NT9adHxZtssgoYPsc1jW0NV2OAZBQoko0qdlLO7wkSg=", + "lastModified": 1726430622, + "narHash": "sha256-RN7CoPxYtyl+PVhMYKOp6o8c/n/NhKI2ILscu7jRwxo=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "f642fb97df5c69267a03452533de383ff8023570", + "rev": "9e356562446f44c471ae38a80506a9df039305d6", "type": "github" }, "original": { @@ -237,11 +250,11 @@ ] }, "locked": { - "lastModified": 1718746314, - "narHash": "sha256-HUklK5u86w2Yh9dOkk4FdsL8eehcOZ95jPhLixGDRQY=", + "lastModified": 1721326555, + "narHash": "sha256-zCu4R0CSHEactW9JqYki26gy8h9f6rHmSwj4XJmlHgg=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "1b61f0093afff20ab44d88ad707aed8bf2215290", + "rev": "5a11232266bf1a1f5952d5b179c3f4b2facaaa84", "type": "github" }, "original": { @@ -269,11 +282,11 @@ ] }, "locked": { - "lastModified": 1720381373, - "narHash": "sha256-lyC/EZdHULsaAKVryK11lgHY9u6pXr7qR4irnxNWC7k=", + "lastModified": 1725997860, + "narHash": "sha256-d/rZ/fHR5l1n7PeyLw0StWMNLXVU9c4HFyfskw568so=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "5df0174fd09de4ac5475233d65ffc703e89b82eb", + "rev": "dfeb5811dd6485490cce18d6cc1e38a055eea876", "type": "github" }, "original": { @@ -296,11 +309,11 @@ ] }, "locked": { - "lastModified": 1721071737, - "narHash": "sha256-qmC9jGfbE4+EIBbbSAkrfR/p49wShjpv4/KztgE/P54=", + "lastModified": 1724966483, + "narHash": "sha256-WXDgKIbzjYKczxSZOsJplCS1i1yrTUpsDPuJV/xpYLo=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "eb1ceff2b87f6820789249f63faa8e9dcb54d05f", + "rev": "8976e3f6a5357da953a09511d0c7f6a890fb6ec2", "type": "github" }, "original": { @@ -323,11 +336,11 @@ ] }, "locked": { - "lastModified": 1720215857, - "narHash": "sha256-JPdL+Qul+jEueAn8CARfcWP83eJgwkhMejQYfDvrgvU=", + "lastModified": 1721324119, + "narHash": "sha256-SOOqIT27/X792+vsLSeFdrNTF+OSRp5qXv6Te+fb2Qg=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "d5fa094ca27e0039be5e94c0a80ae433145af8bb", + "rev": "a048a6cb015340bd82f97c1f40a4b595ca85cc30", "type": "github" }, "original": { @@ -340,7 +353,9 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1720391164, @@ -359,11 +374,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719956923, - "narHash": "sha256-nNJHJ9kfPdzYsCOlHOnbiiyKjZUW5sWbwx3cakg3/C4=", + "lastModified": 1729973466, + "narHash": "sha256-knnVBGfTCZlQgxY1SgH0vn2OyehH9ykfF8geZgS95bk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "706eef542dec88cc0ed25b9075d3037564b2d164", + "rev": "cd3e8833d70618c4eea8df06f95b364b016d4950", "type": "github" }, "original": { @@ -375,55 +390,55 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1719876945, - "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", + "lastModified": 1725233747, + "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" } }, "nixpkgs_2": { "locked": { - "lastModified": 1725001927, - "narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=", + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_3": { "locked": { - "lastModified": 1704161960, - "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "lastModified": 1726062873, + "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_4": { "locked": { - "lastModified": 1719848872, - "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", + "lastModified": 1725983898, + "narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8", + "rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43", "type": "github" }, "original": { @@ -435,43 +450,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1720957393, - "narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "693bc46d169f5af9c992095736e82c3488bf7dbb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_6": { - "locked": { - "lastModified": 1721435672, - "narHash": "sha256-VaBqKvCu4iFWPwKFFigdhOfgccLUDEVByb6Wa2Z9i98=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "2d65995365a2a6b05db69e344d3b673c8d541bcd", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_7": { - "locked": { - "lastModified": 1719690277, - "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", + "lastModified": 1725103162, + "narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", + "rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b", "type": "github" }, "original": { @@ -486,26 +469,33 @@ "edge-nixpkgs": "edge-nixpkgs", "home-manager": "home-manager", "nixos-wsl": "nixos-wsl", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", + "selfup": "selfup", "xremap-flake": "xremap-flake" } }, - "systems": { + "selfup": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1729058896, + "narHash": "sha256-JdVC3/Agrc8vijReztNHyggEHRp6PAijp7ymVmYB+nU=", + "owner": "kachick", + "repo": "selfup", + "rev": "19e2cb02d17162faaaa65a9c2d47726fb76add3b", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "kachick", + "ref": "v1.1.6", + "repo": "selfup", "type": "github" } }, - "systems_2": { + "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -520,7 +510,7 @@ "type": "github" } }, - "systems_3": { + "systems_2": { "locked": { "lastModified": 1689347949, "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", @@ -537,14 +527,14 @@ }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1721458737, - "narHash": "sha256-wNXLQ/ATs1S4Opg1PmuNoJ+Wamqj93rgZYV3Di7kxkg=", + "lastModified": 1725271838, + "narHash": "sha256-VcqxWT0O/gMaeWTTjf1r4MOyG49NaNxW4GHTO3xuThE=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "888bfb10a9b091d9ed2f5f8064de8d488f7b7c97", + "rev": "9fb342d14b69aefdf46187f6bb80a4a0d97007cd", "type": "github" }, "original": { @@ -573,11 +563,11 @@ ] }, "locked": { - "lastModified": 1720194466, - "narHash": "sha256-Rizg9efi6ue95zOp0MeIV2ZedNo+5U9G2l6yirgBUnA=", + "lastModified": 1726046979, + "narHash": "sha256-6SEsjurq9cdTkITA6d49ncAJe4O/8CgRG5/F//s6Xh8=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "b9b97e5ba23fe7bd5fa4df54696102e8aa863cf6", + "rev": "e695669fd8e1d1be9eaae40f35e00f8bd8b64c18", "type": "github" }, "original": { @@ -589,16 +579,16 @@ "xremap": { "flake": false, "locked": { - "lastModified": 1716231654, - "narHash": "sha256-TZvi5EOZ5Ekg8aGXCAzCcphJ7U5YsPtTWKTUQKZXEsg=", + "lastModified": 1726457781, + "narHash": "sha256-+kSb1FV1kJyrxfITSRGJp0ja4icGdNQKkwPdq6rzNps=", "owner": "k0kubun", "repo": "xremap", - "rev": "d1b17c4b9958feb5804f317b654ab3936f852c61", + "rev": "a9b52ccda117dd65468727787b19fbd8bf2915fd", "type": "github" }, "original": { "owner": "k0kubun", - "ref": "v0.10.0", + "ref": "v0.10.1", "repo": "xremap", "type": "github" } @@ -610,16 +600,18 @@ "flake-parts": "flake-parts", "home-manager": "home-manager_2", "hyprland": "hyprland", - "nixpkgs": "nixpkgs_6", + "nixpkgs": [ + "edge-nixpkgs" + ], "treefmt-nix": "treefmt-nix", "xremap": "xremap" }, "locked": { - "lastModified": 1721842203, - "narHash": "sha256-3tV6a9Ri6JTapeOQFuBpIjYk+R+F9RGiaG7Hpz1sTv8=", + "lastModified": 1726701848, + "narHash": "sha256-NBGchlI3+dg3cHAFP+PKWlysW3a88y83XKnthLAmDns=", "owner": "xremap", "repo": "nix-flake", - "rev": "3717cb0539f4967010ba540baa439a4cf6ea8576", + "rev": "2c55335d6509702b0d337b8da697d7048e36123d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 21b17d1f..173a91f9 100644 --- a/flake.nix +++ b/flake.nix @@ -12,9 +12,22 @@ url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; }; - nixos-wsl.url = "github:nix-community/NixOS-WSL/2405.5.4"; + nixos-wsl = { + url = "github:nix-community/NixOS-WSL/2405.5.4"; + # https://github.com/nix-community/NixOS-WSL/blob/5a965cb108fb1f30b29a26dbc29b473f49e80b41/flake.nix#L5 + inputs.nixpkgs.follows = "nixpkgs"; + }; # https://github.com/xremap/nix-flake/blob/master/docs/HOWTO.md - xremap-flake.url = "github:xremap/nix-flake"; + xremap-flake = { + url = "github:xremap/nix-flake"; + # https://github.com/xremap/nix-flake/blob/2c55335d6509702b0d337b8da697d7048e36123d/flake.nix#L6 + inputs.nixpkgs.follows = "edge-nixpkgs"; + }; + selfup = { + url = "github:kachick/selfup/v1.1.6"; + # https://github.com/kachick/selfup/blob/991afc21e437a449c9bd4237b4253f8da407f569/flake.nix#L8 + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -23,18 +36,12 @@ nixpkgs, edge-nixpkgs, home-manager, - nixos-wsl, - xremap-flake, + ... }@inputs: let inherit (self) outputs; # Candidates: https://github.com/NixOS/nixpkgs/blob/release-24.05/lib/systems/flake-systems.nix - forAllSystems = nixpkgs.lib.genAttrs [ - "x86_64-linux" - "x86_64-darwin" - # I don't have M1+ mac, providing this for macos-14 free runner https://github.com/actions/runner-images/issues/9741 - "aarch64-darwin" - ]; + forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; mkApp = pkg: { type = "app"; @@ -65,14 +72,16 @@ in { default = pkgs.mkShellNoCC { + # Realize nixd pkgs version inlay hints for stable channel instead of latest + NIX_PATH = "nixpkgs=${pkgs.path}"; + + TYPOS_LSP_PATH = pkgs.lib.getExe pkgs.typos-lsp; # For vscode typos extension + buildInputs = (with pkgs; [ # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 bashInteractive nixfmt-rfc-style - # TODO: Consider to replace nil with nixd: https://github.com/oxalica/nil/issues/111 - nil # Used in vscode Nix extension - nixd # Used in zed Nix extension nixpkgs-lint-community nix-init nurl @@ -85,22 +94,35 @@ dprint stylua typos - typos-lsp - go_1_22 + typos-lsp # For zed-editor typos extension + go_1_23 goreleaser trivy + + (ruby_3_3.withPackages (ps: with ps; [ rubocop ])) ]) ++ (with edge-pkgs; [ + nixd # Don't use treefmt(treefmt1) that does not have crucial feature to cover hidden files # https://github.com/numtide/treefmt/pull/250 treefmt2 markdownlint-cli2 ]) - ++ (with homemade-pkgs; [ nix-hash-url ]); + ++ (with homemade-pkgs; [ nix-hash-url ]) + ++ [ inputs.selfup.packages.${system}.default ]; }; } ); + packages = forAllSystems (system: { + cozette = homemade-packages.${system}.cozette; + micro-kdl = homemade-packages.${system}.micro-kdl; + micro-nordcolors = homemade-packages.${system}.micro-nordcolors; + micro-everforest = homemade-packages.${system}.micro-everforest; + micro-catppuccin = homemade-packages.${system}.micro-catppuccin; + envs = homemade-packages.${system}.envs; + }); + apps = forAllSystems ( system: builtins.listToAttrs ( @@ -113,21 +135,27 @@ "bump_completions" "bump_gomod" "check_no_dirty_xz_in_nix_store" + "check_nixf" "bench_shells" "walk" "ir" "todo" "la" "lat" + "zed" "ghqf" "git-delete-merged-branches" "git-log-fzf" "git-log-simple" "git-resolve-conflict" - "prs" + "gh-prs" + "envs" "nix-hash-url" - "trim-github-user-prefix-for-reponame" + "reponame" "gredit" + "renmark" + "preview" + "p" ] ) ++ [ @@ -144,7 +172,6 @@ nixosConfigurations = let system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; edge-pkgs = import edge-nixpkgs { inherit system; config = { @@ -154,22 +181,6 @@ homemade-pkgs = homemade-packages.${system}; shared = { inherit system; - modules = [ - ./nixos/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - backupFileExtension = "backup"; - # FIXME: Apply gnome.nix in #680 - users.kachick = import ./home-manager/kachick.nix; - extraSpecialArgs = { - inherit homemade-pkgs edge-pkgs; - }; - }; - } - ]; specialArgs = { inherit inputs @@ -181,15 +192,9 @@ }; in { - "moss" = nixpkgs.lib.nixosSystem ( - shared // { modules = shared.modules ++ [ ./nixos/hosts/moss ]; } - ); - - "algae" = nixpkgs.lib.nixosSystem ( - shared // { modules = shared.modules ++ [ ./nixos/hosts/algae ]; } - ); - - "wsl" = nixpkgs.lib.nixosSystem (shared // { modules = shared.modules ++ [ ./nixos/hosts/wsl ]; }); + "moss" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/moss ]; }); + "algae" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/algae ]; }); + "wsl" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/wsl ]; }); }; homeConfigurations = @@ -202,24 +207,45 @@ }; }; - x86-macOS = { - pkgs = nixpkgs.legacyPackages.x86_64-darwin; - extraSpecialArgs = { - homemade-pkgs = homemade-packages.x86_64-darwin; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin; + x86-macOS = + let + system = "x86_64-darwin"; + in + { + pkgs = nixpkgs.legacyPackages.${system}; + extraSpecialArgs = { + homemade-pkgs = homemade-packages.${system}; + edge-pkgs = import edge-nixpkgs { + inherit system; + config = { + # Atleast required for following + # signal-desktop: https://github.com/NixOS/nixpkgs/pull/348165/files#diff-05921dc46b537c59c8a76dfc3c3e9a3a1fd93345ee5bff8573aae36dedf719bcR49 + # android-studio: https://github.com/NixOS/nixpkgs/blob/3490095db7c455272ee96c1d99d424d029bdf576/pkgs/applications/editors/android-studio/common.nix#L281 + allowUnfree = true; + }; + }; + }; }; - }; - aarch64-macOS = { - pkgs = nixpkgs.legacyPackages.aarch64-darwin; - extraSpecialArgs = { - homemade-pkgs = homemade-packages.aarch64-darwin; - edge-pkgs = edge-nixpkgs.legacyPackages.aarch64-darwin; + aarch64-macOS = + let + system = "aarch64-darwin"; + in + { + pkgs = nixpkgs.legacyPackages.${system}; + extraSpecialArgs = { + homemade-pkgs = homemade-packages.${system}; + edge-pkgs = import edge-nixpkgs { + inherit system; + config = { + allowUnfree = true; + }; + }; + }; }; - }; in { - "kachick@linux-gui" = home-manager.lib.homeManagerConfiguration ( + "kachick@desktop" = home-manager.lib.homeManagerConfiguration ( x86-Linux // { modules = [ @@ -269,7 +295,7 @@ } ); - "github-actions@macos-14" = home-manager.lib.homeManagerConfiguration ( + "github-actions@macos-15" = home-manager.lib.homeManagerConfiguration ( aarch64-macOS // { # Prefer "kachick" over "common" only here. diff --git a/go.mod b/go.mod index 89204898..bf1db1e1 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/kachick/dotfiles -go 1.22.6 +go 1.23.1 require ( golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b - golang.org/x/sys v0.24.0 + golang.org/x/sys v0.26.0 ) diff --git a/go.sum b/go.sum index 587e3dbf..ad4ef33e 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/home-manager/bash.nix b/home-manager/bash.nix index 3d9c184f..6d0d3c7c 100644 --- a/home-manager/bash.nix +++ b/home-manager/bash.nix @@ -3,6 +3,7 @@ lib, pkgs, homemade-pkgs, + edge-pkgs, ... }: @@ -122,10 +123,11 @@ source "${pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh" source "${pkgs.podman}/share/bash-completion/completions/podman" source "${pkgs.zellij}/share/bash-completion/completions/zellij.bash" - source "${homemade-pkgs.cargo-make-completions}/share/bash-completion/completions/makers-completion.bash" + + # Adding only in devshell is not enough + source "${edge-pkgs.cargo-make}/share/bash-completion/completions/makers-completion.bash" source "${../dependencies/dprint/completions.bash}" - source "${../dependencies/goldwarden/completions.bash}" # Disable `Ctrl + S(no output tty)` ${lib.getBin pkgs.coreutils}/bin/stty stop undef @@ -133,6 +135,10 @@ source "${homemade-pkgs.posix_shared_functions}" if [ 'linux' = "$TERM" ]; then + # Avoid Tofu + export LANG=C + export STARSHIP_CONFIG="${pkgs.starship}/share/starship/presets/plain-text-symbols.toml" + disable_blinking_cursor fi '' diff --git a/home-manager/common.nix b/home-manager/common.nix index 07c94983..024ad15e 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -12,10 +12,11 @@ ./bash.nix ./zsh.nix ./fish.nix - ./gpg.nix + ./encryption.nix ./ssh.nix ./git.nix ./editors.nix + ./terminals.nix ./fzf.nix ./firefox.nix ./linux.nix @@ -43,21 +44,12 @@ enableNixpkgsReleaseCheck = true; sessionVariables = { - # Do NOT set GIT_EDITOR, it overrides `core.editor` in git config - # https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference - EDITOR = lib.getExe pkgs.helix; - VISUAL = lib.getExe pkgs.helix; # vscode is heavy even if in VISUAL use PAGER = "less"; # https://github.com/sharkdp/bat/blob/v0.24.0/README.md?plain=1#L201-L219 MANPAGER = "${lib.getExe pkgs.bashInteractive} -c '${pkgs.util-linux}/bin/col -bx | ${lib.getExe pkgs.bat} -l man -p'"; MANROFFOPT = "-c"; - # - You can check the candidates in `locale -a` - # - pkgs.glibc installs many candidates, but it does not support darwin - # This value may overrides NixOS config for GNOME - # 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. @@ -67,6 +59,11 @@ LESSCHARSET = "utf-8"; STACK_XDG = "https://github.com/commercialhaskell/stack/blob/72f0a1273dd1121740501a159988fc23df2fb362/doc/stack_root.md?plain=1#L7-L11"; + + # Don't add needless quotation in the arguments. For example `gopass show 'rclone'` does not work. It should be `gopass show rclone`. + RCLONE_PASSWORD_COMMAND = "${lib.getExe pkgs.gopass} show rclone"; + + STARSHIP_CONFIG = "${../config/starship/starship.toml}"; }; sessionPath = [ @@ -79,11 +76,17 @@ inherit edge-pkgs; inherit homemade-pkgs; }; - }; - # 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 = pkgs.stdenv.isLinux; + # You can check the candidates in `locale -a` + # pkgs.glibc installs many candidates, but it does not support darwin + # https://wiki.archlinux.jp/index.php/%E3%83%AD%E3%82%B1%E3%83%BC%E3%83%AB + # https://github.com/nix-community/home-manager/blob/fe56302339bb28e3471632379d733547caec8103/modules/home-environment.nix#L11 + language = { + base = "ja_JP.UTF-8"; + # systemd config overrides this value in gnome-shell, however this will be used in Linux VT console + time = "en_DK.UTF-8"; # To prefer ISO 8601 format. See https://unix.stackexchange.com/questions/62316/why-is-there-no-euro-english-locale + }; + }; # Let Home Manager install and manage itself. programs.home-manager.enable = true; @@ -120,67 +123,21 @@ # Use same nixpkgs channel as same as fzf }; - # https://nixos.wiki/wiki/Home_Manager - # - Prefer XDG_* - # - If can't write the reason as a comment - - # Do not alias *.nix into `xdg.configFile`, it actually cannot be used because of using many relative dirs - # So you should call `home-manager switch` with `-f ~/repos/dotfiles/USER_NAME.nix` - - 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/common.toml".source = ../config/alacritty/common.toml; - xdg.configFile."alacritty/themes" = { - source = ../config/alacritty/themes; - recursive = true; - }; - - # Not under "starship/starship.toml" - xdg.configFile."starship.toml".source = ../config/starship/starship.toml; - # No home-manager module exists https://github.com/nix-community/home-manager/issues/2890 # TODO: Automate that needs to call `Install-Module -Name PSFzfHistory` first xdg.configFile."powershell/Microsoft.PowerShell_profile.ps1".source = ../config/powershell/Profile.ps1; - # https://github.com/NixOS/nixpkgs/issues/222925#issuecomment-1514112861 - xdg.configFile."autostart/userdirs.desktop".text = '' - [Desktop Entry] - Exec=xdg-user-dirs-update - TryExec=xdg-user-dirs-update - NoDisplay=true - StartupNotify=false - Type=Application - X-KDE-AutostartScript=true - X-KDE-autostart-phase=1 - ''; - - # https://wiki.archlinux.org/title/wayland - # Didn't work if the electron is bundled, so unfit for nixpkgs distributing apps - # xdg.configFile."electron-flags.conf".text = '' - # --enable-features=UseOzonePlatform - # --ozone-platform=wayland - # --enable-wayland-ime - # ''; - xdg.dataFile."tmpbin/.keep".text = ""; home.file.".hushlogin".text = "This file disables daily login message. Not depend on this text."; - xdg.configFile."fcitx5/config" = { - source = ../config/fcitx5/config; - }; - xdg.configFile."fcitx5/profile" = { - source = ../config/fcitx5/profile; - }; - # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/starship.nix programs.starship = { enable = true; }; # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/yazi.nix - # TODO: Use shell integrations for `yy` after release-24.11. 24.05 is using fixed old `ya` + # TODO: Use shell integrations for `y` after release-24.11. 24.05 is using fixed old `ya` programs.yazi = { enable = true; settings = { diff --git a/home-manager/darwin.nix b/home-manager/darwin.nix index afa21dbd..dba00689 100644 --- a/home-manager/darwin.nix +++ b/home-manager/darwin.nix @@ -1,15 +1,98 @@ -{ pkgs, lib, ... }: +{ + pkgs, + edge-pkgs, + homemade-pkgs, + lib, + config, + ... +}: # https://github.com/nix-community/home-manager/issues/414#issuecomment-427163925 lib.mkMerge [ (lib.mkIf pkgs.stdenv.isDarwin { - # https://github.com/NixOS/nixpkgs/issues/240819#issuecomment-1616760598 - # https://github.com/midchildan/dotfiles/blob/fae87a3ef327c23031d8081333678f9472e4c0ed/nix/home/modules/gnupg/default.nix#L38 - xdg.dataFile."gnupg/gpg-agent.conf".text = '' - grab - default-cache-ttl 60480000 - max-cache-ttl 60480000 - pinentry-program ${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac - ''; + home = { + sessionVariables = { + # ## If you prefer zed + # * Do not specify Nix store path for zed in macOS + # https://github.com/NixOS/nixpkgs/blob/bba8dffd3135f35810e9112c40ee621f4ede7cca/pkgs/by-name/ze/zed-editor/package.nix#L217-L219 + # * `cli: install` action installs into this path in macOS + # VISUAL = "zed --wait"; + VISUAL = lib.getExe edge-pkgs.vscode; + + BROWSER = "open"; + }; + + sessionPath = [ + # Many apps installs the binary here if not used nixpkgs + # For example: zed-editor, cloudflare-warp, vscode(symlink?) + "/usr/local/bin" + ]; + + packages = with pkgs; [ + # https://github.com/NixOS/nixpkgs/issues/240819 + pinentry_mac + + alacritty + kitty + # foot is only provided for Linux wayland + + # Don't install firefox via nixpkgs for darwin, it is broken https://github.com/NixOS/nixpkgs/blob/bac526a0fe6da6b10cfe2454f62a0defdbf1d898/pkgs/applications/networking/browsers/firefox/packages.nix#L23 + + # - 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 + plemoljp-nf + ibm-plex # For sans-serif, use plemoljp for developing + + source-han-code-jp # Includes many definitions, useful for fallback + inconsolata + + # Don't add zed in macOS with nixpkgs + # https://github.com/NixOS/nixpkgs/blob/bba8dffd3135f35810e9112c40ee621f4ede7cca/pkgs/by-name/ze/zed-editor/package.nix#L217-L219 + # edge-pkgs.zed-editor + + edge-pkgs.podman-desktop # Useable since https://github.com/NixOS/nixpkgs/pull/343648 + + edge-pkgs.vscode # Keep latest as possible + + edge-pkgs.signal-desktop # Useable since https://github.com/NixOS/nixpkgs/pull/348165 + + homemade-pkgs.maccy + ]; + }; + + xdg = { + configFile = { + "karabiner/assets" = { + source = ../config/karabiner/assets; + recursive = true; + }; + + "karabiner/HomeManagerInit_karabiner.json" = { + source = ../config/karabiner/karabiner.json; + # https://github.com/nix-community/home-manager/issues/3090#issuecomment-2010891733 + onChange = '' + rm -f ${config.xdg.configHome}/karabiner/karabiner.json + cp ${config.xdg.configHome}/karabiner/HomeManagerInit_karabiner.json ${config.xdg.configHome}/karabiner/karabiner.json + chmod u+w ${config.xdg.configHome}/karabiner/karabiner.json + ''; + }; + }; + + dataFile = { + # https://github.com/NixOS/nixpkgs/issues/240819#issuecomment-1616760598 + # https://github.com/midchildan/dotfiles/blob/fae87a3ef327c23031d8081333678f9472e4c0ed/nix/home/modules/gnupg/default.nix#L38 + "gnupg/gpg-agent.conf".text = '' + grab + default-cache-ttl 604800 + max-cache-ttl 604800 + pinentry-program ${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac + ''; + }; + }; }) ] diff --git a/home-manager/editors.nix b/home-manager/editors.nix index 3e37aecb..d45464fc 100644 --- a/home-manager/editors.nix +++ b/home-manager/editors.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { # Don't add unfree packages like vscode here for using in containers @@ -9,17 +9,25 @@ ./vim.nix ]; - # TODO: Update since merged https://github.com/nix-community/home-manager/pull/5455 + # TODO: Update since release-24.11 https://github.com/nix-community/home-manager/pull/5455 xdg.configFile."zed/settings.json".source = ../config/zed/settings.json; - # 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"; + home = { + sessionVariables = { + # Do NOT set GIT_EDITOR, it overrides `core.editor` in git config + # https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference + EDITOR = lib.getExe pkgs.helix; + }; + + # 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 + file.".editorconfig".source = + pkgs.fetchFromGitHub { + owner = "kachick"; + repo = "anylang-template"; + rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771"; + sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE="; + } + + "/.editorconfig"; + }; } diff --git a/home-manager/encryption.nix b/home-manager/encryption.nix new file mode 100644 index 00000000..246bacd0 --- /dev/null +++ b/home-manager/encryption.nix @@ -0,0 +1,80 @@ +{ + config, + pkgs, + edge-pkgs, + ... +}: + +# See https://github.com/kachick/dotfiles/wiki/Encryption for the extracted comments + +let + # All gpg-agent timeouts numbers should be specified with the `seconds` + day = 60 * 60 * 24; + passage_identity_dir = "${config.xdg.configHome}/passage"; +in +{ + # Don't set $SEQUOIA_HOME, it unified config and data, cache to one directory as same as gpg era. + # Use default $HOME instead, it respects XDG Base Directory Specification + + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/services/gpg-agent.nix + services.gpg-agent = { + enable = pkgs.stdenv.isLinux; + + # Update [darwin.nix](darwin.nix) if changed this section + # + # https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session + defaultCacheTtl = day * 7; + # https://github.com/openbsd/src/blob/862f3f2587ccb85ac6d8602dd1601a861ae5a3e8/usr.bin/ssh/ssh-agent.1#L167-L173 + # ssh-agent sets it as infinite by default. So I can relax here (maybe) + defaultCacheTtlSsh = day * 30; + maxCacheTtl = day * 7; + + pinentryPackage = pkgs.pinentry-tty; + + enableSshSupport = false; + }; + + home.sessionVariables = rec { + GOPASS_GPG_BINARY = "${pkgs.lib.getBin edge-pkgs.sequoia-chameleon-gnupg}/bin/gpg-sq"; + + # Do NOT include the identity here + PASSAGE_DIR = "${config.xdg.dataHome}/passage/store"; + + # Create with: `age-keygen | age --passphrase --armor` + PASSAGE_IDENTITIES_FILE = "${passage_identity_dir}/identities.age"; + + # Create with: `age --decrypt "$PASSAGE_IDENTITIES_FILE" | age-keygen -y` + PASSAGE_RECIPIENTS_FILE = "${PASSAGE_DIR}/.age-recipients"; + }; + + home.file."${passage_identity_dir}/.keep".text = "Keep this directory because of passage and age does not create the file if directory is missing"; + + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/gpg.nix + programs.gpg = { + enable = true; + # package = edge-pkgs.sequoia-chameleon-gnupg; # Also will be respected in gpg-agent: https://github.com/nix-community/home-manager/blob/5171f5ef654425e09d9c2100f856d887da595437/modules/services/gpg-agent.nix#L8C3-L8C9 + # However I prefer original gnupg for now, sequoia-chameleon-gnupg does not support crucial features for GPG toolset (etc. `gpg --edit-key`, `gpgconf`) + + # Preferring XDG_DATA_HOME rather than XDG_CONFIG_HOME from following examples + # - https://wiki.archlinux.org/title/XDG_Base_Directory + # - https://github.com/nix-community/home-manager/blob/5171f5ef654425e09d9c2100f856d887da595437/modules/programs/gpg.nix#L192 + homedir = "${config.xdg.dataHome}/gnupg"; + + # Used for `gpg.conf`. I don't know how to specify `gpgconf` with this. + # TODO: Set gpg binary as sequoia-chameleon-gnupg. AFAIK I don't actually need it for now, because I'm not using dependent tools. However it is ideal config. + # - How to read `--list-keys` - https://unix.stackexchange.com/questions/613839/help-understanding-gpg-list-keys-output + # - Ed448 in GitHub is not yet supported - https://github.com/orgs/community/discussions/45937 + settings = { + # https://unix.stackexchange.com/questions/339077/set-default-key-in-gpg-for-signing + # default-key = ""; + + personal-digest-preferences = "SHA512"; + }; + }; + + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/password-store.nix + programs.password-store = { + enable = true; + package = pkgs.gopass; # Setting package is not a aliasing command, however I would try this for now. https://github.com/gopasspw/gopass/blob/70c56f9102999661b54e28c28fa2d63fa5fc813b/docs/setup.md?plain=1#L292-L298 + }; +} diff --git a/home-manager/firefox.nix b/home-manager/firefox.nix index 4e7d80dc..8d539336 100644 --- a/home-manager/firefox.nix +++ b/home-manager/firefox.nix @@ -6,6 +6,10 @@ lib.mkMerge [ # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/firefox.nix programs.firefox = { enable = true; + # In firefox package, use null instead of `pkgs.emptyDirectory` + # - https://github.com/kachick/dotfiles/pull/835#discussion_r1796307643 + # - https://github.com/nix-community/home-manager/blob/342a1d682386d3a1d74f9555cb327f2f311dda6e/modules/programs/firefox/mkFirefoxModule.nix#L264 + package = null; profiles.default = { isDefault = true; settings = { diff --git a/home-manager/fish.nix b/home-manager/fish.nix index 4609ed72..3f65132b 100644 --- a/home-manager/fish.nix +++ b/home-manager/fish.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, ... }: +{ pkgs, ... }: { services.gpg-agent.enableFishIntegration = true; @@ -18,7 +18,6 @@ # If added here, check the result of `bench_shells`: https://github.com/kachick/dotfiles/pull/423/files#r1503804605 xdg.dataFile."fish/vendor_completions.d/podman.fish".source = "${pkgs.podman}/share/fish/vendor_completions.d/podman.fish"; xdg.dataFile."fish/vendor_completions.d/dprint.fish".source = ../dependencies/dprint/completions.fish; - xdg.dataFile."fish/vendor_completions.d/goldwarden.fish".source = ../dependencies/goldwarden/completions.fish; # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/fish.nix programs.fish = { diff --git a/home-manager/git.nix b/home-manager/git.nix index f5335c9b..443b1d9b 100644 --- a/home-manager/git.nix +++ b/home-manager/git.nix @@ -1,8 +1,8 @@ { pkgs, homemade-pkgs, + edge-pkgs, lib, - config, ... }: @@ -58,9 +58,11 @@ }; gpg = { - # I prefer GPG sign rather than SSH key to consider revocation and expiration usecase. + # I prefer PGP sign rather than SSH key to consider revocation and expiration usecase. # See https://github.com/kachick/dotfiles/issues/289 for detail. format = "openpgp"; + + program = "${pkgs.lib.getBin edge-pkgs.sequoia-chameleon-gnupg}/bin/gpg-sq"; # GH-830 }; commit = { @@ -136,6 +138,9 @@ enable = true; settings = { + # Without this, gh prefer $VISUAL + editor = lib.getExe pkgs.helix; + aliases = { # https://github.com/kachick/wait-other-jobs/blob/b576def89f0816aab642bed952817a018e99b373/docs/examples.md#github_token-vs-pat setup = '' @@ -168,5 +173,7 @@ "https://gist.github.com" ]; }; + + extensions = (with pkgs; [ gh-poi ]) ++ (with homemade-pkgs; [ gh-prs ]); }; } diff --git a/home-manager/gnome.nix b/home-manager/gnome.nix index da6658d3..5e0a7eaa 100644 --- a/home-manager/gnome.nix +++ b/home-manager/gnome.nix @@ -1,16 +1,12 @@ -{ - config, - lib, - pkgs, - edge-pkgs, - ... -}: +{ lib, pkgs, ... }: let spotify-pwa-file = "chrome-pjibgclleladliembfgfagdaldikeohf-Default.desktop"; + amazon_music-pwa-file = "chrome-dojpeppajphepagdhclblkkjnoaeamee-Profile_1.desktop"; in { xdg.dataFile."applications/${spotify-pwa-file}".source = ../config/pwa/spotify.desktop; + xdg.dataFile."applications/${amazon_music-pwa-file}".source = ../config/pwa/amazon_music.desktop; # https://github.com/nix-community/home-manager/blob/release-24.05/modules/misc/dconf.nix dconf = { @@ -27,8 +23,8 @@ in with pkgs.gnomeExtensions; [ appindicator - blur-my-shell - pop-shell + # blur-my-shell # Don't use this extension, it often makes flicker. See GH-775 + paperwm clipboard-history kimpanel removable-drive-menu @@ -41,20 +37,26 @@ in just-perfection dash-to-dock # color-picker # Don't enable by default. It conflicts with clipboard-history + xremap ] ); favorite-apps = [ - "Alacritty.desktop" + "kitty.desktop" "dev.zed.Zed.desktop" - "org.gnome.Nautilus.desktop" "firefox.desktop" + "google-chrome.desktop" + "podman-desktop.desktop" + "io.gitlab.news_flash.NewsFlash.desktop" + amazon_music-pwa-file + "org.gnome.Rhythmbox3.desktop" + "org.gnome.Nautilus.desktop" ]; }; # https://unix.stackexchange.com/questions/481142/launch-default-terminal-emulator-by-command "org/gnome/desktop/default-applications/terminal" = { - exec = lib.getExe pkgs.alacritty; + exec = lib.getExe pkgs.kitty; # exec-arg=""; }; @@ -85,10 +87,6 @@ in toggle-message-tray = [ "m" ]; # default: ['v', 'm'], `"disable"` restore default. So added annoy modifier to prevent trigger }; - "org/gnome/desktop/wm/preferences" = { - num-workspaces = 3; - }; - "org/gnome/desktop/wm/keybindings" = { activate-window-menu = [ ]; # Disabling default `space` to run launchers @@ -145,40 +143,19 @@ in }; "org/gnome/settings-daemon/plugins/media-keys" = { - # control-center = [ "comma" ]; # I set this because of inspired by vscode, but disable to avoid conflict of pop-shell minimizerr - www = [ "w" ]; # Prefer w even through pop-shell recommends to Super+b + www = [ "w" ]; home = [ ]; email = [ ]; - # terminal = [ "t" ]; I don't know why this won't work. So use cosutom keybinding - search = [ "f" ]; # pop-shell sets to file manager, but replace to overview + search = [ "space" ]; custom-keybindings = [ "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" ]; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { - name = "Alacritty"; + name = "Terminal"; binding = "t"; - command = lib.getExe pkgs.alacritty; - }; - - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = { - name = "Resource Monitor - TUI"; - binding = "r"; - command = "${lib.getExe pkgs.alacritty} --command=${lib.getExe pkgs.bottom} --title='Resource Monitor(btm)'"; - }; - - # https://github.com/pop-os/shell/blob/master_noble/schemas/org.gnome.shell.extensions.pop-shell.gschema.xml - "org/gnome/shell/extensions/pop-shell" = { - tile-by-default = true; - - # Keybindings: https://github.com/pop-os/shell/blob/master_noble/scripts/configure.sh - - # https://www.reddit.com/r/pop_os/comments/mt5kgf/how_to_change_default_keybind_for/ - activate-launcher = [ "space" ]; - - active-hint = true; + command = lib.getExe pkgs.kitty; }; "org/gnome/shell/extensions/clipboard-history" = { @@ -201,7 +178,7 @@ in # Disable default Super runs GNOME overview with search # https://ubuntuforums.org/showthread.php?t=2405352 - # The feature is useful, but frustrated when using pop-shell shortcuts. Super modifier is mostly used now + # The feature is useful, but frustrated when using paperwm or pop-shell shortcuts. Super modifier is mostly used in them overlay-key = ""; }; @@ -234,14 +211,33 @@ in "org/gnome/desktop/wm/preferences" = { theme = "Nordic"; + + num-workspaces = 3; + # This names are might not be persisted with paperwm, it also uses own UUID for that + workspace-names = [ + "Main" + "Sandbox" + "Music" + ]; }; "org/gnome/shell/extensions/auto-move-windows" = { application-list = [ "${spotify-pwa-file}:3" + "${amazon_music-pwa-file}:3" "org.gnome.Rhythmbox3.desktop:3" ]; }; + + "org/gnome/shell/extensions/paperwm/keybindings" = { + take-window = [ ]; # default: ['t'] + open-window-position = 0; + }; + + "org/virt-manager/virt-manager/connections" = { + autoconnect = [ "qemu:///system" ]; + uris = [ "qemu:///system" ]; + }; }; }; } diff --git a/home-manager/gpg.nix b/home-manager/gpg.nix deleted file mode 100644 index 18fd7e16..00000000 --- a/home-manager/gpg.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ config, pkgs, ... }: - -# ## FAQ - GPG -# -# - How to list keys? -# - 1. `gpg --list-secret-keys --keyid-format=long` # The `sec` first section displays same text as `pub` by `gpg --list-keys --keyid-format=long` -# - How to add subkey? -# - 1. `gpg --edit-key PUBKEY` -# - 2. `addkey` -# - 3. `save` -# - How to revoke subkey? -# - 1. `gpg --edit-key PUBKEY` -# - 2. `key n` n is the index of subkey -# - 3. `revkey` -# - 4. `save` -# - 5. Replace uploaded pubkey with new one, see https://github.com/kachick/dotfiles/pull/311#issuecomment-1715812324 for detail -# - How to get pubkey to upload? -# - `gpg --armor --export PUBKEY | clip.exe` -# - How to backup private key? -# - `gpg --export-secret-keys --armor > gpg-private.keys.bak` -{ - # https://github.com/nix-community/home-manager/blob/release-24.05/modules/services/gpg-agent.nix - services.gpg-agent = { - enable = pkgs.stdenv.isLinux; - - # Update [darwin.nix](darwin.nix) if changed this section - # - # https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session - defaultCacheTtl = 60480000; # 700 days - maxCacheTtl = 60480000; # 700 days - - pinentryPackage = pkgs.pinentry-tty; - }; - - # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/gpg.nix - - programs.gpg = { - enable = true; - - # Preferring XDG_DATA_HOME rather than XDG_CONFIG_HOME from following examples - # - https://wiki.archlinux.org/title/XDG_Base_Directory - # - https://github.com/nix-community/home-manager/blob/5171f5ef654425e09d9c2100f856d887da595437/modules/programs/gpg.nix#L192 - homedir = "${config.xdg.dataHome}/gnupg"; - - # - How to read `--list-keys` - https://unix.stackexchange.com/questions/613839/help-understanding-gpg-list-keys-output - # - Ed448 in GitHub is not yet supported - https://github.com/orgs/community/discussions/45937 - settings = { - # https://unix.stackexchange.com/questions/339077/set-default-key-in-gpg-for-signing - # default-key = ""; - - personal-digest-preferences = "SHA512"; - }; - }; -} diff --git a/home-manager/helix.nix b/home-manager/helix.nix index 8300de9f..ea551f5d 100644 --- a/home-manager/helix.nix +++ b/home-manager/helix.nix @@ -132,7 +132,6 @@ in formatter = mkDprint "md"; language-servers = [ "marksman" - "markdown-oxide" "typos" ]; } @@ -209,7 +208,7 @@ in rust-analyzer # Looks like required to enable gopls - go_1_22 + go_1_23 # https://github.com/helix-editor/helix/blob/24.03/languages.toml#L578 gopls # https://github.com/helix-editor/helix/blob/24.03/languages.toml#L132-L133 @@ -221,7 +220,10 @@ in # https://github.com/helix-editor/helix/blob/24.03/languages.toml#L1164 lua-language-server - ## Not helpful. Didin't activated? + # https://github.com/helix-editor/helix/blob/24.03/languages.toml#L94 + vscode-langservers-extracted + + ## Not helpful. Didn't activated? # # https://github.com/helix-editor/helix/blob/24.03/languages.toml#L1202 # nodePackages.yaml-language-server diff --git a/home-manager/linux.nix b/home-manager/linux.nix index aa6a887f..6c184ec2 100644 --- a/home-manager/linux.nix +++ b/home-manager/linux.nix @@ -1,6 +1,7 @@ { pkgs, lib, + edge-pkgs, homemade-pkgs, ... }: @@ -8,18 +9,59 @@ # https://github.com/nix-community/home-manager/issues/414#issuecomment-427163925 lib.mkMerge [ (lib.mkIf pkgs.stdenv.isLinux { + # 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 = true; + + home.packages = with pkgs; [ + # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` + glibc + + # https://github.com/nix-community/home-manager/blob/a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04/modules/services/ssh-agent.nix#L37 + openssh + + iputils # `ping` etc + + # https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/iw/iw/package.nix + edge-pkgs.iw # replacement of wireless-tools(iwconfig) + + # Alt w3m + # Do not install in dawin yet: https://github.com/NixOS/nixpkgs/blob/b4b293ec6c61e846d69224ea0637411283e2ad39/pkgs/by-name/ch/chawan/package.nix#L82 + # Keybindigs: https://git.sr.ht/~bptato/chawan/tree/master/item/res/config.toml + chawan # `cha` + + homemade-pkgs.renmark # Depend on chawan + ]; + # xdg-user-dirs NixOS module does not work or is not enough for me to keep English dirs even in Japanese locale. # Check your `~/.config/user-dirs.dirs` if you faced any trouble # https://github.com/nix-community/home-manager/blob/release-24.05/modules/misc/xdg-user-dirs.nix - xdg.userDirs = { - enable = true; - createDirectories = true; - }; + xdg = { + userDirs = { + enable = true; + createDirectories = true; + }; - xdg.configFile."hypr/hyprland.conf".source = ../config/hyprland/hyprland.conf; + configFile = { + "hypr/hyprland.conf".source = ../config/hyprland/hyprland.conf; - # For implementation, handling bitwarden logins which contains space seprared text here looks complex and buggy. So extracted to a script. - # And the dependent goldwarden does not support darwin yet: https://github.com/NixOS/nixpkgs/pull/278362/files#diff-062253d551cb2a1ebc07a298c69c8b69b1fb1152e8b08dc805e170ffe8134ae3R45 - home.sessionVariables.RCLONE_PASSWORD_COMMAND = lib.getExe homemade-pkgs.get-rclone-config-password; + # https://github.com/NixOS/nixpkgs/issues/222925#issuecomment-1514112861 + "autostart/userdirs.desktop".text = '' + [Desktop Entry] + Exec=xdg-user-dirs-update + TryExec=xdg-user-dirs-update + NoDisplay=true + StartupNotify=false + Type=Application + X-KDE-AutostartScript=true + X-KDE-autostart-phase=1 + ''; + + # Should sync with the directory instead of each file. See https://github.com/nix-community/home-manager/issues/3090#issuecomment-1799268943 + fcitx5 = { + source = ../config/fcitx5; + }; + }; + }; }) ] diff --git a/home-manager/micro.nix b/home-manager/micro.nix index 843ab3b2..3c19119b 100644 --- a/home-manager/micro.nix +++ b/home-manager/micro.nix @@ -6,12 +6,21 @@ }: { + home.sessionVariables = { + MICRO_TRUECOLOR = "1"; + }; + # For temporal use xdg.configFile."micro/colorschemes/.keep".text = ""; xdg.configFile."micro/plug/fzfinder".source = homemade-pkgs.micro-fzfinder; xdg.configFile."micro/plug/kdl".source = homemade-pkgs.micro-kdl; xdg.configFile."micro/plug/nordcolors".source = homemade-pkgs.micro-nordcolors; + xdg.configFile."micro/colorschemes" = { + source = "${homemade-pkgs.micro-catppuccin}/colorschemes"; + recursive = true; + }; + xdg.configFile."micro/colorschemes/everforest.micro".source = "${homemade-pkgs.micro-everforest}/colorschemes/everforest.micro"; # Default keybinfings are https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md xdg.configFile."micro/bindings.json".source = ../config/micro/bindings.json; @@ -60,7 +69,8 @@ # Embed candidates are https://github.com/zyedidia/micro/tree/c15abea64c20066fc0b4c328dfabd3e6ba3253a0/runtime/colorschemes # But none of fit colors with other place, See #587 for further detail - colorscheme = "nord-16"; + # Candidates: nord-16, everforest, catppuccin-mocha-transparent + colorscheme = "catppuccin-mocha-transparent"; fzfcmd = lib.getExe pkgs.fzf; fzfarg = "--preview '${lib.getExe pkgs.bat} --color=always {}'"; diff --git a/home-manager/packages.nix b/home-manager/packages.nix index cb72564b..f1272ddd 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -8,8 +8,7 @@ # 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;` -with pkgs; -[ +(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 @@ -43,8 +42,17 @@ with pkgs; gh ghq - # GPG - gnupg + edge-pkgs.sequoia-sq # Alt `gpg` - nixos-24.05 does not backport recent versions and the older requires to rebuild. https://github.com/NixOS/nixpkgs/pull/331099 + edge-pkgs.sequoia-chameleon-gnupg + gnupg # Also keep original GPG for now. sequoia-chameleon-gnupg does not support some crucial toolset. etc: `gpg --edit-key`, `gpgconf` + + age # Candidates: rage + + # Alt `pass` for password-store. Candidates: gopass, prs. Do not use ripasso-cursive for now. It only provides TUI, not a replacement of CLI. And currently unstable on my NixOS. + gopass # They will respect pass comaptibility: https://github.com/gopasspw/gopass/issues/1365#issuecomment-719655627 + + # Age fork of `pass`, also supports rage with $PASSAGE_AGE. + edge-pkgs.passage # Use latest to apply https://github.com/NixOS/nixpkgs/pull/339113 # Do not specify vim and the plugins at here, it made collisions from home-manager vim module. # See following issues @@ -61,18 +69,18 @@ with pkgs; edge-pkgs.jnv # interactive jq - Use unstable because it is a fresh tool ripgrep # `rg` bat # alt cat + mdcat # pipe friendly markdown viewer rather than glow hexyl # hex viewer dysk # alt df fd # alt find du-dust # `dust`, alt du procs + btop # alt top bottom # `btm`, alt top xh # alt HTTPie zellij yazi # prefer the shell wrapper `yy` - alacritty - typos hyperfine difftastic # `difft` @@ -95,7 +103,6 @@ with pkgs; # - Enable special module for Nix OS. # - Linux package does not contain podman-remote, you should install uidmap with apt and use this podman as actual engine # https://github.com/NixOS/nixpkgs/blob/194846768975b7ad2c4988bdb82572c00222c0d7/pkgs/applications/virtualization/podman/default.nix#L112-L116 - # - In darwin, this package will be used for podman-remote, you should manually install podman-desktop for the engine podman podman-tui docker-compose @@ -112,7 +119,7 @@ with pkgs; translate-shell # `echo "$text" | trans en:ja` zk # Support Zettelkasten method -] +]) ++ (with homemade-pkgs; [ la lat @@ -124,44 +131,11 @@ with pkgs; p g walk + envs ir updeps bench_shells archive-home-files - prs gredit -]) -++ (lib.optionals stdenv.isLinux [ - # Fix missing locales as `locale: Cannot set LC_CTYPE to default locale` - glibc - - # https://github.com/nix-community/home-manager/blob/a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04/modules/services/ssh-agent.nix#L37 - openssh - - iputils # `ping` etc - - # https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/iw/iw/package.nix - edge-pkgs.iw # replacement of wireless-tools(iwconfig) - - # Alt w3m - # Do not install in dawin yet: https://github.com/NixOS/nixpkgs/blob/b4b293ec6c61e846d69224ea0637411283e2ad39/pkgs/by-name/ch/chawan/package.nix#L82 - # Keybindigs: https://git.sr.ht/~bptato/chawan/tree/master/item/res/config.toml - chawan # `cha` -]) -++ (lib.optionals stdenv.isDarwin [ - # https://github.com/NixOS/nixpkgs/issues/240819 - pinentry_mac - - # - 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 - plemoljp-nf - ibm-plex # For sans-serif, use plemoljp for developing - - source-han-code-jp # Includes many definitions, useful for fallback - inconsolata + preview ]) diff --git a/home-manager/ssh.nix b/home-manager/ssh.nix index 759a29a6..f695acc9 100644 --- a/home-manager/ssh.nix +++ b/home-manager/ssh.nix @@ -1,4 +1,9 @@ -{ config, pkgs, ... }: +{ + pkgs, + edge-pkgs, + config, + ... +}: let # SSH files cannot use XDG Base Directory. @@ -18,6 +23,22 @@ in # https://github.com/nix-community/home-manager/blob/release-24.05/modules/services/ssh-agent.nix services.ssh-agent.enable = pkgs.stdenv.isLinux; + home.sessionVariables = { + # 'force' ignores $DISPLAY. 'prefer' is not enough + SSH_ASKPASS_REQUIRE = "force"; + SSH_ASKPASS = pkgs.lib.getExe ( + pkgs.writeShellApplication { + name = "ssh-ask-pass"; + text = "gopass show ssh-pass"; + meta.description = "GH-714. Required to be wrapped with one command because of SSH_ASKPASS does not accept arguments."; + runtimeInputs = (with pkgs; [ gopass ]) ++ (with edge-pkgs; [ sequoia-chameleon-gnupg ]); + runtimeEnv = { + GOPASS_GPG_BINARY = "${pkgs.lib.getBin edge-pkgs.sequoia-chameleon-gnupg}/bin/gpg-sq"; + }; + } + ); + }; + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/ssh.nix programs.ssh = { enable = true; diff --git a/home-manager/systemd.nix b/home-manager/systemd.nix index 0a584f42..2dd17af1 100644 --- a/home-manager/systemd.nix +++ b/home-manager/systemd.nix @@ -4,6 +4,14 @@ # https://github.com/nix-community/home-manager/blob/release-24.05/modules/systemd.nix#L161-L173 systemd = { user = { + # Enable locale for GNOME and terminals in the gnome-shell. Linux VT console respects home.sessionVariables instead + # https://superuser.com/a/1841368 + # https://github.com/nix-community/home-manager/blob/5ec753a1fc4454df9285d8b3ec0809234defb975/modules/systemd.nix#L92-L96 + sessionVariables = { + # GNOME clock respects LC_TIME. And does not support displaying iso-8601 format even if set en_DK + LC_TIME = "ja_JP.UTF-8"; + }; + services.podman = { Unit = { Description = "Podman API Service"; diff --git a/home-manager/terminals.nix b/home-manager/terminals.nix new file mode 100644 index 00000000..13b55a0e --- /dev/null +++ b/home-manager/terminals.nix @@ -0,0 +1,39 @@ +{ pkgs, lib, ... }: + +{ + xdg = { + configFile = { + "alacritty/alacritty.toml".source = ../config/alacritty/alacritty-unix.toml; + "alacritty/unix.toml".source = + if pkgs.stdenv.isDarwin then ../config/alacritty/macos.toml else ../config/alacritty/linux.toml; + "alacritty/common.toml".source = ../config/alacritty/common.toml; + "alacritty/themes" = { + source = ../config/alacritty/themes; + recursive = true; + }; + }; + }; + + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/kitty.nix + programs.kitty = { + enable = true; + package = pkgs.emptyDirectory; + theme = "zenwritten_dark"; + settings = { + shell = lib.getExe pkgs.zsh; + cursor_shape = "beam"; + cursor_blink_interval = 0; + copy_on_select = "clipboard"; + tab_bar_edge = "top"; + # tab_bar_style = "separator"; + # tab_separator = " | "; + tab_bar_style = "slant"; + }; + + # Avoiding a home-manager definition bug for rejecting all float. + # https://github.com/nix-community/home-manager/issues/4850 + extraConfig = '' + background_opacity 0.85 + ''; + }; +} diff --git a/home-manager/vim.nix b/home-manager/vim.nix index c6c4be93..ffe208ed 100644 --- a/home-manager/vim.nix +++ b/home-manager/vim.nix @@ -1,6 +1,14 @@ -{ pkgs, homemade-pkgs, ... }: +{ + pkgs, + config, + edge-pkgs, + ... +}: { + # TODO: Prefer xdg.stateFile since home-manager release-24.11. See https://github.com/nix-community/home-manager/pull/5779 + home.file."${config.xdg.stateHome}/vim/.keep".text = "Keep this directory because of home-manager and vim does not create the file if directory is missing"; + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/vim.nix # https://nixos.wiki/wiki/Vim programs.vim = { @@ -12,7 +20,7 @@ iceberg-vim fzf-vim ]) - ++ [ homemade-pkgs.kdl-vim ]; + ++ [ edge-pkgs.vimPlugins.kdl-vim ]; settings = { background = "dark"; @@ -20,6 +28,7 @@ extraConfig = '' colorscheme iceberg set termguicolors + set viminfofile=${config.xdg.stateHome}/vim/viminfo ''; }; } diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix index eaf8ae09..f9d86e9c 100644 --- a/home-manager/zsh.nix +++ b/home-manager/zsh.nix @@ -3,9 +3,18 @@ lib, pkgs, homemade-pkgs, + edge-pkgs, ... }: +# NOTE: +# Most frustrated part of zsh is how to keep speed with the slow completions. +# See https://github.com/zsh-users/zsh/blob/zsh-5.9/Completion/compinit for the options. + +let + ZCOMPDUMP_CACHE_DIR = "${config.xdg.cacheHome}/zsh"; + ZCOMPDUMP_CACHE_PATH = "${ZCOMPDUMP_CACHE_DIR}/zcompdump-${pkgs.zsh.version}"; +in { services.gpg-agent.enableZshIntegration = true; programs.starship.enableZshIntegration = true; @@ -15,6 +24,13 @@ # Avoid nested zellij in host and remote login as container programs.zellij.enableZshIntegration = false; + home.activation.refreshZcompdumpCache = config.lib.dag.entryAnywhere '' + if [[ -v oldGenPath && -f '${ZCOMPDUMP_CACHE_PATH}' ]]; then + # Enforcing to clear old cache, because of just omitting -C kept the command names + ${lib.getBin pkgs.coreutils}/bin/rm '${ZCOMPDUMP_CACHE_PATH}' + fi + ''; + # https://nixos.wiki/wiki/Zsh # https://zsh.sourceforge.io/Doc/Release/Options.html # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/zsh.nix @@ -27,6 +43,15 @@ # https://github.com/nix-community/home-manager/blob/8c731978f0916b9a904d67a0e53744ceff47882c/modules/programs/zsh.nix#L25C3-L25C10 dotDir = ".config/zsh"; + localVariables = { + inherit ZCOMPDUMP_CACHE_DIR ZCOMPDUMP_CACHE_PATH; + + # This is a minimum note for home-manager dead case such as https://github.com/kachick/dotfiles/issues/680#issuecomment-2353820508 + PROMPT = '' + %~ %? %# + > ''; + }; + history = { # in memory size = 84000; @@ -120,19 +145,19 @@ # speed - https://gist.github.com/ctechols/ca1035271ad134841284 # both - https://github.com/kachick/dotfiles/pull/155 _compinit_with_interval() { - local -r dump_dir="${config.xdg.cacheHome}/zsh" - local -r dump_path="$dump_dir/zcompdump-$ZSH_VERSION" # seconds * minutes * hours local -r threshold="$((60 * 60 * 3))" - if [ -e "$dump_path" ] && [ "$(_elapsed_seconds_for "$dump_path")" -le "$threshold" ]; then + if [ -e "$ZCOMPDUMP_CACHE_PATH" ] && [ "$(_elapsed_seconds_for "$ZCOMPDUMP_CACHE_PATH")" -le "$threshold" ]; then # https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Use-of-compinit # -C omit to check new functions - compinit -C -d "$dump_path" + compinit -C -d "$ZCOMPDUMP_CACHE_PATH" else - ${lib.getBin pkgs.coreutils}/bin/mkdir -p "$dump_dir" - compinit -d "$dump_path" - ${lib.getBin pkgs.coreutils}/bin/touch "$dump_path" # Ensure to update timestamp + # For refreshing the cache + + ${lib.getBin pkgs.coreutils}/bin/mkdir -p "$ZCOMPDUMP_CACHE_DIR" + compinit -d "$ZCOMPDUMP_CACHE_PATH" + ${lib.getBin pkgs.coreutils}/bin/touch "$ZCOMPDUMP_CACHE_PATH" # Ensure to update timestamp fi } ''; @@ -207,7 +232,7 @@ source "${pkgs.fzf-git-sh}/share/fzf-git-sh/fzf-git.sh" source "${pkgs.podman}/share/zsh/site-functions/_podman" # cargo-make recommends to use bash completions for zsh - source "${homemade-pkgs.cargo-make-completions}/share/bash-completion/completions/makers-completion.bash" + source "${edge-pkgs.cargo-make}/share/bash-completion/completions/makers-completion.bash" # fzf completions are also possible to be used in bash, but it overrides default completions with the registering # So currently injecting only in zsh @@ -254,7 +279,6 @@ } source "${../dependencies/dprint/completions.zsh}" - source "${../dependencies/goldwarden/completions.zsh}" # Disable `Ctrl + S(no output tty)` ${lib.getBin pkgs.coreutils}/bin/stty stop undef @@ -268,6 +292,10 @@ source_sh "${homemade-pkgs.posix_shared_functions}" if [ 'linux' = "$TERM" ]; then + # Avoid Tofu + export LANG=C + export STARSHIP_CONFIG="${pkgs.starship}/share/starship/presets/plain-text-symbols.toml" + disable_blinking_cursor fi @@ -281,19 +309,6 @@ fi ''; - # Use one of profileExtra or loginExtra. Not both - profileExtra = '' - # TODO: Switch to pkgs.zsh from current zsh in darwin - - if [[ "$OSTYPE" == darwin* ]]; then - # TODO: May move to sessionVariables - export BROWSER='open' - - # Microsoft recommends this will be written in ~/.zprofile, - if [ -x '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' ]; then - export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin" - fi - fi - ''; + # Useable one of profileExtra or loginExtra. Do not specify both. }; } diff --git a/nixos/WARP.md b/nixos/WARP.md index e1a9d719..3397e652 100644 --- a/nixos/WARP.md +++ b/nixos/WARP.md @@ -25,3 +25,13 @@ Or use with accessing to