From d84646800cb8bc47c2c3e839ab6a0fc05091cc3e Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Tue, 20 Jan 2026 17:10:49 +0000 Subject: [PATCH] refactor --- flake.nix | 4 ++-- lib/build-rust-package.nix | 20 +++++++++++++++++++ overlays/jj-ryu.nix | 20 ++++--------------- overlays/jj-starship.nix | 1 + overlays/lumen.nix | 20 ++++--------------- profiles/ghostty.nix | 2 +- profiles/jujutsu.nix | 19 +++++++++++++++--- profiles/opencode.nix | 40 +++++++++++++++++++++++++++++++------- profiles/packages.nix | 1 + profiles/ripgrep.nix | 1 + profiles/starship.nix | 29 +++++---------------------- 11 files changed, 88 insertions(+), 69 deletions(-) create mode 100644 lib/build-rust-package.nix create mode 100644 overlays/jj-starship.nix diff --git a/flake.nix b/flake.nix index 1f678cd..0911c22 100644 --- a/flake.nix +++ b/flake.nix @@ -47,7 +47,7 @@ jj-starship.url = "github:dmmulroy/jj-starship"; }; - outputs = inputs @ {flake-parts, jj-starship, ...}: + outputs = inputs @ {flake-parts, ...}: flake-parts.lib.mkFlake {inherit inputs;} ( let inherit (inputs.nixpkgs) lib; @@ -57,7 +57,7 @@ darwinHosts = ["chidi" "jason"]; nixosHosts = ["michael" "tahani"]; - overlays = import ./overlays {inherit inputs;} ++ [jj-starship.overlays.default]; + overlays = import ./overlays {inherit inputs;}; nixpkgsConfig = hostPlatform: { nixpkgs = {inherit hostPlatform overlays;}; }; diff --git a/lib/build-rust-package.nix b/lib/build-rust-package.nix new file mode 100644 index 0000000..7989374 --- /dev/null +++ b/lib/build-rust-package.nix @@ -0,0 +1,20 @@ +{ + input, + prev, +}: let + manifest = (prev.lib.importTOML "${input}/Cargo.toml").package; +in + prev.rustPlatform.buildRustPackage { + pname = manifest.name; + version = manifest.version; + + cargoLock.lockFile = "${input}/Cargo.lock"; + + src = input; + + nativeBuildInputs = [prev.pkg-config]; + buildInputs = [prev.openssl]; + OPENSSL_NO_VENDOR = 1; + + doCheck = false; + } diff --git a/overlays/jj-ryu.nix b/overlays/jj-ryu.nix index 4ff3379..a9acba5 100644 --- a/overlays/jj-ryu.nix +++ b/overlays/jj-ryu.nix @@ -1,19 +1,7 @@ -{inputs}: final: prev: let - manifest = (prev.lib.importTOML "${inputs.jj-ryu}/Cargo.toml").package; -in { +{inputs}: final: prev: { jj-ryu = - prev.rustPlatform.buildRustPackage { - pname = manifest.name; - version = manifest.version; - - cargoLock.lockFile = "${inputs.jj-ryu}/Cargo.lock"; - - src = inputs.jj-ryu; - - nativeBuildInputs = [prev.pkg-config]; - buildInputs = [prev.openssl]; - OPENSSL_NO_VENDOR = 1; - - doCheck = false; + import ../lib/build-rust-package.nix { + inherit prev; + input = inputs.jj-ryu; }; } diff --git a/overlays/jj-starship.nix b/overlays/jj-starship.nix new file mode 100644 index 0000000..3485dbf --- /dev/null +++ b/overlays/jj-starship.nix @@ -0,0 +1 @@ +{inputs}: inputs.jj-starship.overlays.default diff --git a/overlays/lumen.nix b/overlays/lumen.nix index ed20136..1dfd339 100644 --- a/overlays/lumen.nix +++ b/overlays/lumen.nix @@ -1,19 +1,7 @@ -{inputs}: final: prev: let - manifest = (prev.lib.importTOML "${inputs.lumen}/Cargo.toml").package; -in { +{inputs}: final: prev: { lumen = - prev.rustPlatform.buildRustPackage { - pname = manifest.name; - version = manifest.version; - - cargoLock.lockFile = "${inputs.lumen}/Cargo.lock"; - - src = inputs.lumen; - - nativeBuildInputs = [prev.pkg-config]; - buildInputs = [prev.openssl]; - OPENSSL_NO_VENDOR = 1; - - doCheck = false; + import ../lib/build-rust-package.nix { + inherit prev; + input = inputs.lumen; }; } diff --git a/profiles/ghostty.nix b/profiles/ghostty.nix index 5a3b8de..87e01f1 100644 --- a/profiles/ghostty.nix +++ b/profiles/ghostty.nix @@ -10,7 +10,7 @@ cursor-style = block mouse-hide-while-typing = true mouse-scroll-multiplier = 1.25 - shell-integration = detect + shell-integration = fish shell-integration-features = no-cursor clipboard-read = allow clipboard-write = allow diff --git a/profiles/jujutsu.nix b/profiles/jujutsu.nix index 2dd6b28..dcc37ca 100644 --- a/profiles/jujutsu.nix +++ b/profiles/jujutsu.nix @@ -10,24 +10,37 @@ sign-on-push = true; subprocess = true; write-change-id-header = true; + private-commits = "description(glob:'wip:*') | description(glob:'WIP:*') | description(exact:'')"; }; - diff = { - tool = "delta"; + fsmonitor = { + backend = "watchman"; }; ui = { default-command = "status"; diff-formatter = ":git"; pager = ["delta" "--pager" "less -FRX"]; diff-editor = ["nvim" "-c" "DiffEditor $left $right $output"]; + movement = { + edit = true; + }; }; aliases = { n = ["new"]; tug = ["bookmark" "move" "--from" "closest_bookmark(@-)" "--to" "@-"]; - stack = ["log" "-r" "ancestors((trunk()..@)::bookmarks() | @, 2)"]; + stack = ["log" "-r" "stack()"]; retrunk = ["rebase" "-d" "trunk()"]; + bm = ["bookmark"]; + gf = ["git" "fetch"]; + gp = ["git" "push"]; }; revset-aliases = { "closest_bookmark(to)" = "heads(::to & bookmarks())"; + "closest_pushable(to)" = "heads(::to & mutable() & ~description(exact:\"\") & (~empty() | merges()))"; + "mine()" = "author(christoph@schmatzler.com)"; + "wip()" = "mine() ~ immutable()"; + "open()" = "mine() ~ ::trunk()"; + "current()" = "@:: & mutable()"; + "stack()" = "reachable(@, mutable())"; }; templates = { draft_commit_description = '' diff --git a/profiles/opencode.nix b/profiles/opencode.nix index 8c9873f..2a89d57 100644 --- a/profiles/opencode.nix +++ b/profiles/opencode.nix @@ -10,7 +10,23 @@ model = "opencode/gpt-5-2-codex"; small_model = "opencode/gpt-5-1-codex-mini"; theme = "catppuccin"; - permission = "allow"; + keybinds = { + leader = "ctrl+o"; + }; + permission = { + read = { + "*" = "allow"; + "*.env" = "deny"; + "*.env.*" = "deny"; + "*.envrc" = "deny"; + "secrets/*" = "deny"; + }; + }; + agent = { + explore = { + model = "opencode/minimax-m2.1-free"; + }; + }; instructions = [ "CLAUDE.md" "AGENT.md" @@ -22,7 +38,23 @@ }; }; mcp = { + context7 = { + enabled = true; + type = "remote"; + url = "https://mcp.context7.com/mcp"; + }; + grep_app = { + enabled = true; + type = "remote"; + url = "https://mcp.grep.app"; + }; + opensrc = { + enabled = true; + type = "local"; + command = ["bunx" "opensrc-mcp"]; + }; appsignal = { + enabled = false; type = "local"; command = [ "docker" @@ -36,12 +68,6 @@ environment = { APPSIGNAL_API_KEY = "{env:APPSIGNAL_API_KEY}"; }; - enabled = true; - }; - }; - agent = { - explore = { - model = "opencode/minimax-m2.1-free"; }; }; }; diff --git a/profiles/packages.nix b/profiles/packages.nix index 9c17445..e7dd2ff 100644 --- a/profiles/packages.nix +++ b/profiles/packages.nix @@ -47,6 +47,7 @@ with pkgs; tree-sitter unzip vivid + watchman zip ] ++ lib.optionals stdenv.isDarwin [ diff --git a/profiles/ripgrep.nix b/profiles/ripgrep.nix index 776cf7f..4c1a84d 100644 --- a/profiles/ripgrep.nix +++ b/profiles/ripgrep.nix @@ -4,6 +4,7 @@ arguments = [ "--max-columns=150" "--max-columns-preview" + "--hidden" "--smart-case" "--colors=column:none" "--colors=column:fg:4" diff --git a/profiles/starship.nix b/profiles/starship.nix index e052dca..ecab9fa 100644 --- a/profiles/starship.nix +++ b/profiles/starship.nix @@ -5,7 +5,7 @@ settings = { add_newline = true; command_timeout = 2000; - format = "[$directory$\{custom.jj}]($style)$character"; + format = "[$directory$\{custom.scm}]($style)$character"; character = { error_symbol = "[✗ ](bold #e64553)"; success_symbol = "[❯](bold #40a02b)[❯](bold #df8e1d)[❯](bold #dc8a78)"; @@ -16,29 +16,10 @@ repo_root_style = "bold cyan"; repo_root_format = "[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; }; - custom.jj = { - command = '' - jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template ' - separate(" ", - change_id.shortest(4), - bookmarks, - "|", - concat( - if(conflict, "💥"), - if(divergent, "🚧"), - if(hidden, "👻"), - if(immutable, "🔒"), - ), - raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"), - raw_escape_sequence("\x1b[1;32m") ++ coalesce( - truncate_end(29, description.first_line(), "…"), - "(no description set)", - ) ++ raw_escape_sequence("\x1b[0m"), - ) - ' - ''; - when = "jj --ignore-working-copy root"; - symbol = "🥋"; + custom.scm = { + when = "jj-starship detect"; + shell = ["jj-starship" "--strip-bookmark-prefix" "cschmatzler/" "--truncate-name" "20" "--bookmarks-display-limit" "1"]; + format = "$output "; }; }; };