From 20ecde0e153c004b1b05bb88dfd5c6ac568e418d Mon Sep 17 00:00:00 2001 From: elwrcl Date: Sun, 2 Aug 2026 04:07:25 +0300 Subject: [PATCH] secret --- hosts/copland.ulu.nix | 18 +++ hosts/sohryu-darwin.ulu.nix | 12 ++ modules/home/home-direnv.ulu.nix | 12 ++ modules/home/home-gh.ulu.nix | 11 ++ modules/home/home-jujutsu-difftastic.ulu.nix | 19 +++ modules/home/home-jujutsu-mergiraf.ulu.nix | 21 +++ modules/home/home-jujutsu-watchman.ulu.nix | 21 +++ modules/home/home-jujutsu.ulu.nix | 122 ++++++++++++++++++ modules/home/home-nushell-colors.ulu.nix | 38 ++++++ .../home-nushell-commandline-copy.ulu.nix | 37 ++++++ modules/home/home-nushell-completions.ulu.nix | 68 ++++++++++ modules/home/home-nushell-last.ulu.nix | 19 +++ modules/home/home-nushell-prompt.ulu.nix | 115 +++++++++++++++++ modules/home/home-radicle.ulu.nix | 29 +++++ modules/home/home-shell-tools.ulu.nix | 5 +- modules/nixos/common/secrets/radicle.age | Bin 0 -> 697 bytes secrets.nix | 10 ++ 17 files changed, 556 insertions(+), 1 deletion(-) create mode 100644 modules/home/home-direnv.ulu.nix create mode 100644 modules/home/home-gh.ulu.nix create mode 100644 modules/home/home-jujutsu-difftastic.ulu.nix create mode 100644 modules/home/home-jujutsu-mergiraf.ulu.nix create mode 100644 modules/home/home-jujutsu-watchman.ulu.nix create mode 100644 modules/home/home-jujutsu.ulu.nix create mode 100644 modules/home/home-nushell-colors.ulu.nix create mode 100644 modules/home/home-nushell-commandline-copy.ulu.nix create mode 100644 modules/home/home-nushell-completions.ulu.nix create mode 100644 modules/home/home-nushell-last.ulu.nix create mode 100644 modules/home/home-nushell-prompt.ulu.nix create mode 100644 modules/home/home-radicle.ulu.nix create mode 100644 modules/nixos/common/secrets/radicle.age create mode 100644 secrets.nix diff --git a/hosts/copland.ulu.nix b/hosts/copland.ulu.nix index 56cd751..1bd2e43 100644 --- a/hosts/copland.ulu.nix +++ b/hosts/copland.ulu.nix @@ -31,6 +31,18 @@ in config.flake.homeModules.home-base config.flake.homeModules.home-ghostty config.flake.homeModules.home-nushell + config.flake.homeModules.home-nushell-colors + config.flake.homeModules.home-nushell-completions + config.flake.homeModules.home-nushell-prompt + config.flake.homeModules.home-nushell-commandline-copy + config.flake.homeModules.home-nushell-last + config.flake.homeModules.home-direnv + config.flake.homeModules.home-jujutsu + config.flake.homeModules.home-jujutsu-difftastic + config.flake.homeModules.home-jujutsu-mergiraf + config.flake.homeModules.home-jujutsu-watchman + config.flake.homeModules.home-gh + config.flake.homeModules.home-radicle config.flake.homeModules.home-zsh config.flake.homeModules.home-shell-tools config.flake.homeModules.home-session-vars @@ -86,6 +98,7 @@ in config.flake.nixosModules.service-docker config.flake.nixosModules.service-virt-manager config.flake.nixosModules.common-git + config.flake.nixosModules.common-agenix config.flake.nixosModules.common-packages # import ./copland-hardware.nix @@ -105,6 +118,11 @@ in "/share/mime" "/share/X11" ]; + + age.secrets.radicle-key = { + file = ../modules/nixos/common/secrets/radicle.age; + owner = "elars"; + }; } ]; }; diff --git a/hosts/sohryu-darwin.ulu.nix b/hosts/sohryu-darwin.ulu.nix index 8e5d4f6..66374bc 100644 --- a/hosts/sohryu-darwin.ulu.nix +++ b/hosts/sohryu-darwin.ulu.nix @@ -29,6 +29,18 @@ in config.flake.homeModules.home-base config.flake.homeModules.home-ghostty config.flake.homeModules.home-nushell + config.flake.homeModules.home-nushell-colors + config.flake.homeModules.home-nushell-completions + config.flake.homeModules.home-nushell-prompt + config.flake.homeModules.home-nushell-commandline-copy + config.flake.homeModules.home-nushell-last + config.flake.homeModules.home-direnv + config.flake.homeModules.home-jujutsu + config.flake.homeModules.home-jujutsu-difftastic + config.flake.homeModules.home-jujutsu-mergiraf + config.flake.homeModules.home-jujutsu-watchman + config.flake.homeModules.home-gh + config.flake.homeModules.home-radicle ]; home.username = "sohryu"; home.homeDirectory = "/Users/sohryu"; diff --git a/modules/home/home-direnv.ulu.nix b/modules/home/home-direnv.ulu.nix new file mode 100644 index 0000000..ea1971e --- /dev/null +++ b/modules/home/home-direnv.ulu.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + flake.homeModules.home-direnv = + { ... }: + { + programs.direnv = { + enable = true; + nix-direnv.enable = true; + enableNushellIntegration = true; + }; + }; +} diff --git a/modules/home/home-gh.ulu.nix b/modules/home/home-gh.ulu.nix new file mode 100644 index 0000000..9b549b2 --- /dev/null +++ b/modules/home/home-gh.ulu.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + flake.homeModules.home-gh = + { ... }: + { + programs.gh = { + enable = true; + settings.version = 1; + }; + }; +} diff --git a/modules/home/home-jujutsu-difftastic.ulu.nix b/modules/home/home-jujutsu-difftastic.ulu.nix new file mode 100644 index 0000000..03013dc --- /dev/null +++ b/modules/home/home-jujutsu-difftastic.ulu.nix @@ -0,0 +1,19 @@ +{ ... }: +{ + flake.homeModules.home-jujutsu-difftastic = + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe; + in + { + home.packages = [ pkgs.difftastic ]; + + programs.jujutsu.settings.ui.diff-formatter = [ + (getExe pkgs.difftastic) + "--color" + "always" + "$left" + "$right" + ]; + }; +} diff --git a/modules/home/home-jujutsu-mergiraf.ulu.nix b/modules/home/home-jujutsu-mergiraf.ulu.nix new file mode 100644 index 0000000..3baf5f7 --- /dev/null +++ b/modules/home/home-jujutsu-mergiraf.ulu.nix @@ -0,0 +1,21 @@ +{ ... }: +{ + flake.homeModules.home-jujutsu-mergiraf = + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe; + in + { + home.packages = [ pkgs.mergiraf ]; + + programs.jujutsu.settings = { + aliases.resolve-ast = [ + "resolve" + "--tool" + "mergiraf" + ]; + + merge-tools.mergiraf.program = getExe pkgs.mergiraf; + }; + }; +} diff --git a/modules/home/home-jujutsu-watchman.ulu.nix b/modules/home/home-jujutsu-watchman.ulu.nix new file mode 100644 index 0000000..64d5683 --- /dev/null +++ b/modules/home/home-jujutsu-watchman.ulu.nix @@ -0,0 +1,21 @@ +{ ... }: +{ + flake.homeModules.home-jujutsu-watchman = + { pkgs, lib, ... }: + { + home.packages = [ pkgs.watchman ]; + + xdg.configFile."watchman/watchman.json".text = builtins.toJSON { + ignore_dirs = [ + ".direnv" + "node_modules" + "target" + ]; + }; + + programs.jujutsu.settings = { + fsmonitor.backend = "watchman"; + fsmonitor.watchman.register-snapshot-trigger = true; + }; + }; +} diff --git a/modules/home/home-jujutsu.ulu.nix b/modules/home/home-jujutsu.ulu.nix new file mode 100644 index 0000000..db11c20 --- /dev/null +++ b/modules/home/home-jujutsu.ulu.nix @@ -0,0 +1,122 @@ +{ ... }: +{ + flake.homeModules.home-jujutsu = + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe; + in + { + programs.jujutsu = { + enable = true; + + settings = { + user = { + name = "elwrcl"; + email = "elwerici@proton.me"; + }; + + aliases.".." = [ + "edit" + "@-" + ]; + aliases.",," = [ + "edit" + "@+" + ]; + + aliases.f = [ + "git" + "fetch" + ]; + aliases.p = [ + "git" + "push" + ]; + + aliases.a = [ "abandon" ]; + aliases.c = [ "commit" ]; + aliases.ci = [ + "commit" + "--interactive" + ]; + aliases.d = [ "diff" ]; + aliases.e = [ "edit" ]; + aliases.l = [ "log" ]; + aliases.la = [ + "log" + "--revisions" + "::" + ]; + aliases.s = [ "squash" ]; + aliases.si = [ + "squash" + "--interactive" + ]; + aliases.u = [ "undo" ]; + + # `jj fork` — renames the current `origin` remote to `upstream`, forks + # the repository on GitHub via `gh`, and tracks the trunk bookmark. + aliases.fork = [ + "util" + "exec" + "--" + (getExe ( + pkgs.writeShellScriptBin "jj-fork" '' + remote_names() { + jj git remote list | cut -d' ' -f1 + } + + if ! remote_names | grep -qx upstream; then + jj git remote rename origin upstream + fi + + if ! remote_names | grep -qx origin; then + ${getExe pkgs.gh} repo fork --remote --remote-name origin + fi + + jj git fetch + + trunk_remote=$(jj config get 'revset-aliases."trunk()"' | cut -d'@' -f1) + jj bookmark track "$trunk_remote" + '' + )) + ]; + + revsets.log = # python + '' + present(@) | present(trunk()) | ancestors(remote_bookmarks().. | @.., 8) + ''; + + ui.default-command = "log"; + ui.diff-editor = ":builtin"; + ui.conflict-marker-style = "snapshot"; + + templates.draft_commit_description = # python + '' + concat( + coalesce(description, "\n"), + surround( + "\nJJ: This commit contains the following changes:\n", "", + indent("JJ: ", diff.stat(72)), + ), + "\nJJ: ignore-rest\n", + diff.git(), + ) + ''; + + remotes."*" = { + auto-track-bookmarks = "elwrcl/*"; + push-new-bookmarks = true; + }; + + templates.git_push_bookmark = ''"elwrcl/change-" ++ change_id.short()''; + + git.fetch = [ + "origin" + "upstream" + ]; + git.push = "origin"; + }; + }; + }; +} diff --git a/modules/home/home-nushell-colors.ulu.nix b/modules/home/home-nushell-colors.ulu.nix new file mode 100644 index 0000000..d1f765c --- /dev/null +++ b/modules/home/home-nushell-colors.ulu.nix @@ -0,0 +1,38 @@ +{ ... }: +{ + flake.homeModules.home-nushell-colors = + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe; + + lsColors = pkgs.runCommand "ls_colors.txt" { } '' + ${getExe pkgs.vivid} generate gruvbox-dark-hard > $out + ''; + in + { + home.packages = [ pkgs.vivid ]; + + programs.nushell.extraConfig = '' + $env.LS_COLORS = open --raw ${lsColors} + + $env.config.color_config.row_index = "light_yellow_bold" + $env.config.color_config.header = "light_yellow_bold" + + $env.config.color_config.bool = {|| + if $in { + "light_green_bold" + } else { + "light_red_bold" + } + } + + $env.config.color_config.string = {|| + if $in =~ "^(#|0x)[a-fA-F0-9]+$" { + $in | str replace "0x" "#" + } else { + "white" + } + } + ''; + }; +} diff --git a/modules/home/home-nushell-commandline-copy.ulu.nix b/modules/home/home-nushell-commandline-copy.ulu.nix new file mode 100644 index 0000000..e382241 --- /dev/null +++ b/modules/home/home-nushell-commandline-copy.ulu.nix @@ -0,0 +1,37 @@ +{ ... }: +{ + flake.homeModules.home-nushell-commandline-copy = + { ... }: + { + programs.nushell.extraConfig = '' + use std/clip + def nu-highlight-default [] { + + let input = $in + $env.config.color_config = {} + $input | nu-highlight + } + + def "nu-keybind commandline-copy" []: nothing -> nothing { + commandline + | nu-highlight-default + | [ "```ansi" $in "```" ] + | str join (char nl) + | clip copy --ansi + } + + $env.config.keybindings ++= [ + { + name: copy_color_commandline + modifier: control_alt + keycode: char_c + mode: [ emacs vi_insert vi_normal ] + event: { + send: executehostcommand + cmd: 'nu-keybind commandline-copy' + } + } + ] + ''; + }; +} diff --git a/modules/home/home-nushell-completions.ulu.nix b/modules/home/home-nushell-completions.ulu.nix new file mode 100644 index 0000000..a185990 --- /dev/null +++ b/modules/home/home-nushell-completions.ulu.nix @@ -0,0 +1,68 @@ +{ ... }: +{ + flake.homeModules.home-nushell-completions = + { pkgs, lib, ... }: + let + inherit (lib.meta) getExe; + + carapaceNu = pkgs.runCommand "carapace.nu" { } '' + ${getExe pkgs.carapace} _carapace nushell > $out + ''; + in + { + home.packages = [ pkgs.carapace ]; + + programs.nushell.environmentVariables.CARAPACE_BRIDGES = "zsh,fish,bash"; + + programs.nushell.extraConfig = '' + let menus = [ + { + name: completion_menu + only_buffer_difference: false + marker: ($env.PROMPT_INDICATOR? | default "> ") + type: { + layout: ide + min_completion_width: 0 + max_completion_width: 150 + max_completion_height: 25 + padding: 0 + border: false + cursor_offset: 0 + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + correct_cursor_pos: true + } + style: { + text: white + selected_text: white_reverse + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: history_menu + only_buffer_difference: true + marker: ($env.PROMPT_INDICATOR? | default "> ") + type: { + layout: list + page_size: 10 + } + style: { + text: white + selected_text: white_reverse + } + } + ] + + $env.config.menus = $env.config.menus + | where name not-in ($menus | get name) + | append $menus + + source ${carapaceNu} + ''; + }; +} diff --git a/modules/home/home-nushell-last.ulu.nix b/modules/home/home-nushell-last.ulu.nix new file mode 100644 index 0000000..ba7334d --- /dev/null +++ b/modules/home/home-nushell-last.ulu.nix @@ -0,0 +1,19 @@ +{ ... }: +{ + flake.homeModules.home-nushell-last = + { ... }: + { + programs.nushell.extraConfig = '' + $env.config.hooks.display_output = {|| + tee { table --expand | print } + # SQLiteDatabase doesn't support equality comparisons. + | try { if $in != null { $env.last = $in } } + } + + # Retrieve the output of the last command. + def _ []: nothing -> any { + $env.last? + } + ''; + }; +} diff --git a/modules/home/home-nushell-prompt.ulu.nix b/modules/home/home-nushell-prompt.ulu.nix new file mode 100644 index 0000000..0fdd477 --- /dev/null +++ b/modules/home/home-nushell-prompt.ulu.nix @@ -0,0 +1,115 @@ +{ ... }: +{ + flake.homeModules.home-nushell-prompt = + { ... }: + { + programs.nushell.extraConfig = '' + do --env { + use std null_device + + def prompt-header [ + --left-char: string + ]: nothing -> string { + let code = $env.LAST_EXIT_CODE + + let jj_workspace_root = try { + jj workspace root err> $null_device + } catch { + "" + } + + let hostname = if ($env.SSH_CONNECTION? | is-not-empty) { + $"(ansi light_green_bold)@(sys host | get hostname)(ansi reset) " + } else { + "" + } + + let body = if ($jj_workspace_root | is-not-empty) { + let subpath = pwd | path relative-to $jj_workspace_root + let subpath = if ($subpath | is-not-empty) { + $"(ansi magenta_bold) → (ansi reset)(ansi blue)($subpath)" + } + + $"($hostname)(ansi light_yellow_bold)($jj_workspace_root | path basename)($subpath)(ansi reset)" + } else { + $"($hostname)(ansi cyan)( + if (pwd | str starts-with $env.HOME) { + "~" | path join (pwd | path relative-to $env.HOME) + } else { + pwd + } + )(ansi reset)" + } + + let command_duration = ($env.CMD_DURATION_MS | into int) * 1ms + let command_duration = if $command_duration <= 2sec { + "" + } else { + $"┫(ansi light_magenta_bold)($command_duration)(ansi light_yellow_bold)┣━" + } + + let exit_code = if $code == 0 { + "" + } else { + $"┫(ansi light_red_bold)($code)(ansi light_yellow_bold)┣━" + } + + let middle = if $command_duration == "" and $exit_code == "" { + "━" + } else { + "" + } + + $"(ansi light_yellow_bold)($left_char)($exit_code)($middle)($command_duration)(ansi reset) ($body)(char newline)" + } + + $env.PROMPT_INDICATOR = $"(ansi light_yellow_bold)┃(ansi reset) " + $env.PROMPT_INDICATOR_VI_NORMAL = $env.PROMPT_INDICATOR + $env.PROMPT_INDICATOR_VI_INSERT = $env.PROMPT_INDICATOR + $env.PROMPT_MULTILINE_INDICATOR = $env.PROMPT_INDICATOR + $env.PROMPT_COMMAND = {|| + prompt-header --left-char "┏" + } + $env.PROMPT_COMMAND_RIGHT = {|| + try { + jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template ' + separate( + " ", + if(empty, label("empty", "(empty)")), + coalesce( + surround( + "\"", + "\"", + if( + description.first_line().substr(0, 24).starts_with(description.first_line()), + description.first_line().substr(0, 24), + description.first_line().substr(0, 23) ++ "…" + ) + ), + label(if(empty, "empty"), description_placeholder) + ), + bookmarks.join(", "), + change_id.shortest(), + commit_id.shortest(), + if(conflict, label("conflict", "(conflict)")), + if(divergent, label("divergent prefix", "(divergent)")), + if(hidden, label("hidden prefix", "(hidden)")), + ) + ' err> $null_device + } catch { + "" + } + } + + $env.TRANSIENT_PROMPT_INDICATOR = " " + $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = $env.TRANSIENT_PROMPT_INDICATOR + $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = $env.TRANSIENT_PROMPT_INDICATOR + $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = $env.TRANSIENT_PROMPT_INDICATOR + $env.TRANSIENT_PROMPT_COMMAND = {|| + prompt-header --left-char "━" + } + $env.TRANSIENT_PROMPT_COMMAND_RIGHT = $env.PROMPT_COMMAND_RIGHT + } + ''; + }; +} diff --git a/modules/home/home-radicle.ulu.nix b/modules/home/home-radicle.ulu.nix new file mode 100644 index 0000000..9c6406e --- /dev/null +++ b/modules/home/home-radicle.ulu.nix @@ -0,0 +1,29 @@ +{ ... }: +{ + flake.homeModules.home-radicle = + { + osConfig, + pkgs, + lib, + ... + }: + let + inherit (lib.attrsets) optionalAttrs; + hasSecret = (osConfig.age.secrets or { }) ? radicle-key; + in + { + home.packages = [ pkgs.radicle-node ]; + home.file = { + ".radicle/config.json".text = builtins.toJSON { + publicExplorer = "https://radicle.network/nodes/$host/$rid$path"; + preferredSeeds = [ + "z6MkrLMMsiPWUcNPHcRajuMi9mDfYckSoJyPwwnknocNYPm7@iris.radicle.network:8776" + "z6Mkmqogy2qEM2ummccUthFEaaHvyYmYBYh3dbe9W4ebScxo@rosa.radicle.network:8776" + ]; + }; + } + // optionalAttrs hasSecret { + ".radicle/keys/radicle".source = osConfig.age.secrets.radicle-key.path; + }; + }; +} diff --git a/modules/home/home-shell-tools.ulu.nix b/modules/home/home-shell-tools.ulu.nix index 343297c..cfb66f5 100644 --- a/modules/home/home-shell-tools.ulu.nix +++ b/modules/home/home-shell-tools.ulu.nix @@ -5,6 +5,9 @@ { programs.starship.enable = true; programs.fzf.enable = true; - programs.zoxide.enable = true; + programs.zoxide = { + enable = true; + enableNushellIntegration = true; + }; }; } diff --git a/modules/nixos/common/secrets/radicle.age b/modules/nixos/common/secrets/radicle.age new file mode 100644 index 0000000000000000000000000000000000000000..6d4a35d40795ad9707c5edf615f2c5f47811b0bb GIT binary patch literal 697 zcmV;q0!IB|XJsvAZewzJaCB*JZZ2_*LBEf<+AaE*^p@|y4=U{0ifi!zU(RWb#*&C zXLRx+DEX&3G_!_9V5}dL4`l(xe%t(GQ-$ocuGzMQWkdTS+o5*&xpVaSmkp}0|0N4;S}2`0$s_LXN$7xb6-2k`T-_5@nIlm zg}`>mM7{}m>3J`ii;5ZK=g!_5NnI9Uv*6eTAZgd%G09YEv{W5ZTaY1R)NMS8JeN*A z&h`;9b&9axp)bAxa&eHYFv^ZUKsuTpO> zNrVP(I24FUikgj>?>7LC7phG9`eLVKY%C!8&BG?qRrR!5%!(IgA~@9fmwqQO9=eW8)eabcq5cj?5PjXrpyuZppo4}AH(78z1c6X$-B81BNn f!UXQ34FYQsVz%h!r$N-5h^Fen;6^eLvxG|H>#Hpe literal 0 HcmV?d00001 diff --git a/secrets.nix b/secrets.nix new file mode 100644 index 0000000..64ed1d5 --- /dev/null +++ b/secrets.nix @@ -0,0 +1,10 @@ +let + admin = "age15akskah37k32fqnktxhh58y9kdhmu3ce4gtw07j49qtfhtjjsvtq8z78hq"; + copland = "age1egtkxm54e8gwsvn42sz37cv5x5yj2pkp3x5fwwv2s3ux0cupscmqya3mye"; +in +{ + "modules/nixos/common/secrets/radicle.age".publicKeys = [ + admin + copland + ]; +}