From 99507cc9c2d4e766c166531c05ae2ba93f180ee7 Mon Sep 17 00:00:00 2001 From: nevaforget <> Date: Mon, 24 Aug 2026 10:28:18 +0200 Subject: [PATCH] feat(zed): install the Zed editor with the Arch config Seeds settings.json into the home directory with a tmpfiles 'C' rule, the same route swaylock and waypaper take: Zed rewrites the file whenever a setting is changed from its UI, so a store symlink would break saving. nix-ld is what makes the language servers Zed downloads run here; the alternative, zed-editor.fhsWithPackages, would cut them off from project-level tooling out of a nix-shell. --- README.md | 3 +- flake.nix | 1 + modules/zed.nix | 157 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 modules/zed.nix diff --git a/README.md b/README.md index 7d11c4d..9587305 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ modules/ desktop.nix /etc deployment, package set, theme greetd.nix greetd + regreet, autologin per host services.nix systemd system and user services + zed.nix Zed editor, nix-ld, seeded user config hosts/ testvm/ QEMU test VM thinkpad/ ThinkPad T14 Gen 3 (AMD) @@ -35,7 +36,7 @@ hosts/ ``` `nixosModules.moonarch` is the entry point: it imports disko's NixOS module -alongside the five above and hands them the packages and the config source. +alongside the six above and hands them the packages and the config source. ## Usage diff --git a/flake.nix b/flake.nix index 4889bb4..f20321c 100644 --- a/flake.nix +++ b/flake.nix @@ -95,6 +95,7 @@ ./modules/desktop.nix ./modules/greetd.nix ./modules/services.nix + ./modules/zed.nix ]; _module.args = { diff --git a/modules/zed.nix b/modules/zed.nix new file mode 100644 index 0000000..a5bd096 --- /dev/null +++ b/modules/zed.nix @@ -0,0 +1,157 @@ +# ABOUTME: Installs the Zed editor and seeds its user configuration. +# ABOUTME: nix-ld is what makes the language servers Zed downloads run here. + +{ pkgs, ... }: + +let + # Zed rewrites this file whenever a setting is changed from its UI, so it is + # copied into the home directory rather than linked from the store. + zedSettings = pkgs.writeText "zed-settings.json" '' + { + "cli_default_open_behavior": "new_window", + "reduce_motion": "on", + "edit_predictions": { + "provider": "none" + }, + "project_panel": { + "dock": "left" + }, + "outline_panel": { + "dock": "left" + }, + "git_panel": { + "dock": "left" + }, + "base_keymap": "SublimeText", + "cursor_shape": "block", + "ui_font_size": 14, + "ui_font_family": "Hack Nerd Font", + "ui_font_features": { + "calt": true + }, + "buffer_font_family": "Hack Nerd Font", + "buffer_font_size": 14, + "theme": { + "mode": "system", + "light": "Catppuccin Latte", + "dark": "Catppuccin Mocha" + }, + "telemetry": { + "diagnostics": false, + "metrics": false + }, + "terminal": { + "shell": { + "program": "zsh" + }, + // LC_MESSAGES=C keeps tool output (git, pytest, ruff) in English so it + // stays greppable. Number and date formatting follows the system LANG. + "env": { + "LC_MESSAGES": "C" + } + }, + "show_edit_predictions": false, + "toolbar": { + "quick_actions": false + }, + "agent": { + "dock": "right", + "enabled": false, + "button": false + }, + "chat_panel": { + "button": "never" + }, + "collaboration_panel": { + "dock": "left", + "button": false + }, + "auto_install_extensions": { + "catppuccin": true, + "dockerfile": true, + "html": true, + "log": true, + "nix": true, + "php": true, + "scss": true, + "vue": true + }, + "languages": { + "Python": { + // ruff formats and organizes imports, basedpyright does type checking. + // The other three bundled servers are disabled explicitly: without the + // negations the "..." placeholder pulls in pyright, pylsp and ty as well, + // which means four type checkers reporting on the same file. + "language_servers": [ + "ruff", + "basedpyright", + "!pyright", + "!pylsp", + "!ty", + "..." + ], + "formatter": { + "language_server": { + "name": "ruff" + } + }, + "code_actions_on_format": { + "source.organizeImports.ruff": true + } + }, + "JavaScript": { + "code_actions_on_format": { + "source.fixAll.eslint": true + } + }, + "TypeScript": { + "code_actions_on_format": { + "source.fixAll.eslint": true + } + }, + "TSX": { + "code_actions_on_format": { + "source.fixAll.eslint": true + } + }, + "PHP": { + // Intelephense without a licence key: completion, diagnostics, hover, + // formatting and find-all-references are covered. Rename, code actions + // and inlay hints stay locked behind the paid tier. + "language_servers": [ + "intelephense", + "!phpactor", + "!phptools", + "!phpantom", + "..." + ] + } + }, + "lsp": { + "rust-analyzer": { + "initialization_options": { + "check": { + "command": "clippy" + } + } + } + } + } + ''; +in +{ + # CLI entry point is `zeditor`, not `zed`. Needs working Vulkan, the GUI does + # not start without it. + environment.systemPackages = [ pkgs.zed-editor ]; + + # Zed downloads its language servers into ~/.local/share/zed/languages/ and + # those binaries expect an FHS layout that does not exist here. nix-ld + # supplies the loader they look for — the route the NixOS wiki recommends, + # over zed-editor.fhsWithPackages, which would cut the servers off from + # project-level tooling coming out of a nix-shell. + programs.nix-ld.enable = true; + + systemd.user.tmpfiles.rules = [ + "C %h/.config/zed/settings.json 0644 - - - ${zedSettings}" + ]; +}