From 7388e3635f108424f595097e172d0594d2399d1b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 16 Aug 2024 12:37:58 +0200 Subject: [PATCH] WIP --- flake.nix | 10 +++++++++ home/home.nix | 1 + home/programs/vscode/default.nix | 3 +++ home/services/ra-multiplex.nix | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 home/services/ra-multiplex.nix diff --git a/flake.nix b/flake.nix index 2d9ddff..c05c7e9 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + ra-multiplex = { + url = "github:pr2502/ra-multiplex"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Nix expressions and keys (TODO: move keys to another solution like agenix) # which should be kept from the main repo for privacy reasons. # @@ -75,6 +80,7 @@ secrets, sops-nix, vscode-server, + ra-multiplex # website }: let system = "x86_64-linux"; @@ -101,6 +107,10 @@ inherit (nonrecursive-unstable-pkgs) atuin wstunnel; }) + (self: super: { + ra-multiplex = ra-multiplex.packages.${system}.default; + }) + # https://github.com/NixOS/nixpkgs/pull/251706 (self: super: { mozc = self.qt6Packages.callPackage ./package-overrides/mozc.nix { }; diff --git a/home/home.nix b/home/home.nix index ba64b5c..c9987ec 100644 --- a/home/home.nix +++ b/home/home.nix @@ -51,6 +51,7 @@ in { ./services/mpd.nix ./services/picom.nix ./services/polybar.nix + ./services/ra-multiplex.nix ./services/screen-locker.nix # ./services/stalonetray.nix ./services/sxhkd.nix diff --git a/home/programs/vscode/default.nix b/home/programs/vscode/default.nix index e671ffb..cf842d9 100644 --- a/home/programs/vscode/default.nix +++ b/home/programs/vscode/default.nix @@ -161,6 +161,9 @@ in "vsintellicode.modify.editor.suggestSelection" = "automaticallyOverrodeDefaultValue"; "window.zoomLevel" = 1; + "rust-analyzer.server.path" = + toString (pkgs.writeShellScript "ra-multiplex-client" "${lib.getExe pkgs.ra-multiplex} client"); + "search.exclude" = { "**/node_modules" = true; "**/bower_components" = true; diff --git a/home/services/ra-multiplex.nix b/home/services/ra-multiplex.nix new file mode 100644 index 0000000..d522f37 --- /dev/null +++ b/home/services/ra-multiplex.nix @@ -0,0 +1,36 @@ +{ pkgs, lib, ... }: +let + format = pkgs.formats.toml { }; + package = pkgs.ra-multiplex; +in +{ + xdg.configFile."ra-multiplex/config.toml".source = format.generate "ra-multiplex-config.toml" { + # listen = "/var/run/user/1001/ra-mux/ra-multiplex.sock"; + # connect = "/var/run/user/1001/ra-mux/ra-multiplex.sock"; + listen = [ "127.0.0.1" 27631 ]; + connect = [ "127.0.0.1" 27631 ]; + pass_environment = [ + "RUST_SRC_PATH" + "RUSTC_WRAPPER" + "SCCACHE_DIR" + ]; + }; + + systemd.user.services.ra-multiplex = { + Unit = { + Description = "Rust analyzer multiplex server"; + }; + + Service = { + Type = "simple"; + ExecStart = "${lib.getExe package} server"; + Environment = [ + "PATH=${lib.makeBinPath [ pkgs.rust-analyzer ]}" + ]; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; +}