diff --git a/modules/home/helix.nix b/modules/home/helix.nix index ad7a366..b4fef12 100644 --- a/modules/home/helix.nix +++ b/modules/home/helix.nix @@ -130,10 +130,6 @@ args = ["--stdio"]; }; - language-server.rust-analyzer = { - config.cargo.allFeatures = true; - }; - language-server.vscode-css-language-server = { command = "vscode-css-language-server"; args = ["--stdio"]; @@ -185,11 +181,6 @@ (def "markdown" { rulers = [81]; }) - (def "rust" { - formatter = { - command = "rustfmt"; - }; - }) (def "sql" { indent.tab-width = 4; indent.unit = " "; diff --git a/modules/home/jujutsu/default.nix b/modules/home/jujutsu/default.nix index 05b364c..64a180e 100644 --- a/modules/home/jujutsu/default.nix +++ b/modules/home/jujutsu/default.nix @@ -203,29 +203,6 @@ }) ]; } - (lib.mkIf config.modules.home.rust.enable { - # `jj fix` pipes content via stdin, leaving rustfmt unable to walk - # upward to find Cargo.toml and read the workspace's edition. The - # wrapper takes `$root`/`$path` from jj's substitution, resolves - # the file's enclosing crate (handling workspace inheritance via - # `[workspace.package].edition`), and invokes rustfmt with - # `--edition` set correctly per file. - home.file.".config/jj/scripts/rustfmt-wrapper.sh" = { - source = ./rustfmt-wrapper.sh; - executable = true; - }; - - programs.jujutsu.settings = { - fix.tools.rustfmt = { - command = [ - "${config.home.homeDirectory}/.config/jj/scripts/rustfmt-wrapper.sh" - "$root" - "$path" - ]; - patterns = ["glob:'**/*.rs'"]; - }; - }; - }) (lib.mkIf config.modules.home.nushell.enable { modules.home.wsl-bridge.map = { "~/.config/jj/scripts/fork.nu" = { diff --git a/modules/home/rust/default.nix b/modules/home/rust/default.nix index c39c20b..cd0dea2 100644 --- a/modules/home/rust/default.nix +++ b/modules/home/rust/default.nix @@ -17,24 +17,61 @@ config = let rust = config.modules.home.rust; + helix = config.modules.home.helix; + jujutsu = config.modules.home.jujutsu; in - lib.mkIf rust.enable { - modules.home.skills.definitions.rust.source = ./skill.md; + lib.mkIf rust.enable (lib.mkMerge [ + { + modules.home.skills.definitions.rust.source = ./skill.md; - home.packages = - (utils.mkIfOptions rust { - samply = pkgs.samply; - bacon = pkgs.bacon; - gcc = pkgs.gcc; - lldb = pkgs.lldb; - }) - ++ (lib.optionals rust.leptos.enable [ - pkgs.trunk - pkgs.leptosfmt - ]) - ++ [ - pkgs.cargo-nextest - pkgs.rustup + home.packages = + (utils.mkIfOptions rust { + samply = pkgs.samply; + bacon = pkgs.bacon; + gcc = pkgs.gcc; + lldb = pkgs.lldb; + }) + ++ (lib.optionals rust.leptos.enable [ + pkgs.trunk + pkgs.leptosfmt + ]) + ++ [ + pkgs.cargo-nextest + pkgs.rustup + ]; + } + (lib.mkIf helix.enable { + programs.helix.languages.language-server.rust-analyzer = { + config.cargo.allFeatures = true; + }; + + programs.helix.languages.language = [ + { + name = "rust"; + formatter.command = "rustfmt"; + } ]; - }; + }) + (lib.mkIf jujutsu.enable { + # `jj fix` pipes content via stdin, leaving rustfmt unable to walk + # upward to find Cargo.toml and read the workspace's edition. The + # wrapper takes `$root`/`$path` from jj's substitution, resolves + # the file's enclosing crate (handling workspace inheritance via + # `[workspace.package].edition`), and invokes rustfmt with + # `--edition` set correctly per file. + home.file.".config/jj/scripts/rustfmt-wrapper.sh" = { + source = ./rustfmt-wrapper.sh; + executable = true; + }; + + programs.jujutsu.settings.fix.tools.rustfmt = { + command = [ + "${config.home.homeDirectory}/.config/jj/scripts/rustfmt-wrapper.sh" + "$root" + "$path" + ]; + patterns = ["glob:'**/*.rs'"]; + }; + }) + ]); } diff --git a/modules/home/jujutsu/rustfmt-wrapper.sh b/modules/home/rust/rustfmt-wrapper.sh similarity index 100% rename from modules/home/jujutsu/rustfmt-wrapper.sh rename to modules/home/rust/rustfmt-wrapper.sh