Compare commits

..

1 commit

Author SHA1 Message Date
copilot-swe-agent[bot]
31bc081831
fix: enable full Quarto support when R is activated
Agent-Logs-Url: https://github.com/dwinkler1/np/sessions/8f21e9a2-22be-44c9-aa37-bc4fd64b20a3

Co-authored-by: dwinkler1 <22460147+dwinkler1@users.noreply.github.com>
2026-04-29 06:25:26 +00:00
6 changed files with 130 additions and 272 deletions

View file

@ -22,6 +22,7 @@ jobs:
name: rde name: rde
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: rstats-on-nix, nix-community extraPullNames: rstats-on-nix, nix-community
- run: cd templates/rde/ && nix develop -c p-updateDeps
- name: Update ed flake.lock - name: Update ed flake.lock
uses: DeterminateSystems/update-flake-lock@v28 uses: DeterminateSystems/update-flake-lock@v28
with: with:

View file

@ -1,73 +0,0 @@
# Project Editor
A per-project Neovim wrapper built with [nix-wrapper-modules](https://birdeehub.github.io/nix-wrapper-modules/) and [nvimConfig](https://github.com/dwinkler1/nvimConfig).
## Setup
The flake provides two entry points:
| Command | What you get |
|---|---|
| `direnv allow` / `nix develop` | **(Recommended)** A shell with `nv` and all enabled language toolchains (R, Python, Julia, Quarto) on `PATH`. |
| `nix run` | Launches only the `nv` editor. Language toolchains (R, Python, etc.) are **not** on `PATH`. |
### With direnv (recommended)
```bash
direnv allow # enter the devShell automatically
nv # launch the pre-configured Neovim
R # R REPL is available (if enabled in flake.nix)
```
### Without direnv
```bash
nix develop # enter the devShell manually
nv # launch Neovim
R # R REPL is available (if enabled in flake.nix)
```
> **Why `nix run` only gives the editor:** The flake's `packages.default` is the wrapped Neovim binary. Language toolchains (R, radian, quarto, etc.) live in `devShells.default`. Use `nix develop` (or `direnv allow`) to get the full environment.
## Configuration
The `flake.nix` is the single source of truth. Key knobs:
| Option | What it controls |
|---|---|
| `cats` | Toggle language support (nix, r, python, julia, etc.) |
| `settings.lang_packages.<lang>` | Language-specific packages installed in the wrapper |
| `settings.colorscheme` | Neovim colorscheme |
| `settings.background` | `"dark"` or `"light"` |
| `settings.wrapRc` | When `true`, init.lua is embedded (rebuild to change); when `false`, init.lua is external (reload without rebuild) |
| `binName` | The wrapper binary name (`nv` by default) |
| `env` | Environment variables set in the wrapper |
| `extraPackages` | Extra system packages available in the wrapper's PATH |
| `specs.extraLua` | Inject lazy.nvim plugin specs |
### Adding packages without editing flake.nix
Create any of these optional files in the project root to add dependencies without modifying `flake.nix`:
- **`python-packages.nix`** — receives `python3Packages`, return a list of packages:
```nix
p: with p; [ numpy scipy ]
```
- **`r-packages.nix`** — receives `rpkgs` (includes `rPackages`), return a list:
```nix
p: with p.rPackages; [ ggplot2 data.table ]
```
- **`julia-packages.nix`** — no arguments, return a list of package name strings:
```nix
[ "DataFrames" "Plots" ]
```
## Formatting
```bash
nix fmt
```
Uses `nixfmt-rfc-style` pinned via the flake's `formatter` output.

View file

@ -22,11 +22,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1778869304, "lastModified": 1776877367,
"narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=", "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d233902339c02a9c334e7e593de68855ad26c4cb", "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -45,19 +45,20 @@
"nixpkgs" "nixpkgs"
], ],
"plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references", "plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references",
"plugins-r": "plugins-r", "plugins-r": [
"r-nvim-nix": "r-nvim-nix", "plugins-r"
],
"rixpkgs": [ "rixpkgs": [
"rixpkgs" "rixpkgs"
], ],
"wrappers": "wrappers" "wrappers": "wrappers"
}, },
"locked": { "locked": {
"lastModified": 1779362150, "lastModified": 1776413627,
"narHash": "sha256-y3JTpxmNgtEYG1m21Ymvdmrul/WvJzOCX45AlV21aak=", "narHash": "sha256-pU3u7T4MqpjUWxflNvd4i47FURp756L7nMRL8MV+QEw=",
"owner": "dwinkler1", "owner": "dwinkler1",
"repo": "nvimConfig", "repo": "nvimConfig",
"rev": "af6d975129768cce36ac4c46198ab2b3ebaafad3", "rev": "2617face3b1be40534d2cae7f0a374a062b3710d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -85,45 +86,20 @@
"plugins-r": { "plugins-r": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1776905071, "lastModified": 1769881528,
"narHash": "sha256-dXox6qEs1VDE7vPNDoN8bY4g06uj1IEs6uki72w8lpA=", "narHash": "sha256-oQSHHu6filJkAyH94yEvyTVuxA+5MU2dMOEAnsIjJKQ=",
"owner": "R-nvim", "owner": "R-nvim",
"repo": "R.nvim", "repo": "R.nvim",
"rev": "582f2af11290ac067e49018db38e12a511325556", "rev": "958b472d763cb258927c7ef69af4fd9945cc5469",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "R-nvim", "owner": "R-nvim",
"ref": "v0.99.4", "ref": "v0.99.3",
"repo": "R.nvim", "repo": "R.nvim",
"type": "github" "type": "github"
} }
}, },
"r-nvim-nix": {
"inputs": {
"nixpkgs": [
"nvimConfig",
"rixpkgs"
],
"rnvimsrc": [
"nvimConfig",
"plugins-r"
]
},
"locked": {
"lastModified": 1778684156,
"narHash": "sha256-Z4y1tQfkIsPK4NRxGn668HMDfWxnxNxSJ0CAOOXiIfY=",
"owner": "dwinkler1",
"repo": "r_nvim_nix",
"rev": "2f49dfee27886068e2f49cbd54558ce4cc424c82",
"type": "github"
},
"original": {
"owner": "dwinkler1",
"repo": "r_nvim_nix",
"type": "github"
}
},
"rixpkgs": { "rixpkgs": {
"locked": { "locked": {
"lastModified": 1771303851, "lastModified": 1771303851,
@ -135,8 +111,8 @@
}, },
"original": { "original": {
"owner": "dwinkler1", "owner": "dwinkler1",
"ref": "nixpkgs",
"repo": "rixpkgs", "repo": "rixpkgs",
"rev": "af2dd3f7b4b172077747c0869d4e30702fb71b0e",
"type": "github" "type": "github"
} }
}, },
@ -145,6 +121,7 @@
"fran": "fran", "fran": "fran",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nvimConfig": "nvimConfig", "nvimConfig": "nvimConfig",
"plugins-r": "plugins-r",
"rixpkgs": "rixpkgs" "rixpkgs": "rixpkgs"
} }
}, },
@ -156,11 +133,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1779297405, "lastModified": 1776375800,
"narHash": "sha256-VFoBwH7ZjVxCnvZTb5ODRXt70sLtWMxstive0N+RS50=", "narHash": "sha256-/SSAR77Brr9fbapsh1cb2K47JXCbvwS1GjM4yyDxle8=",
"owner": "BirdeeHub", "owner": "BirdeeHub",
"repo": "nix-wrapper-modules", "repo": "nix-wrapper-modules",
"rev": "e7ed7a1205945befdf2e0d73ba7df91d935e5af1", "rev": "f11469ca69068bac13d9e163b2bd268cc06dff57",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -7,8 +7,7 @@
nvimConfig, nvimConfig,
... ...
} @ inputs: let } @ inputs: let
# ── Shared language support flags ────────────────────────────── projectSettings = {pkgs}: {
# Used by both the neovim wrapper module and the devShell
cats = { cats = {
clickhouse = false; clickhouse = false;
gitPlugins = false; gitPlugins = false;
@ -21,23 +20,12 @@
r = false; r = false;
}; };
# ── Language package lists ──────────────────────────────────── settings = let
# Shared between wrapper lang_packages and devShell toolchains. # With `replace` packages are replaced otherwise they are merged with base packages
# Accept pkgs so they work inside forAllSystems for each system. replace = pkgs.lib.mkForce;
in {
rPackages = pkgs: lang_packages = {
(with pkgs.rpkgs.rPackages; [ python = replace (
fixest
# pkgs.extraRPackages.musicMetadata
])
++ (
if builtins.pathExists ./r-packages.nix
# p: with p.rPackages; [ ... ]
then import ./r-packages.nix pkgs.rpkgs
else []
);
pythonPackages = pkgs:
(with pkgs.python3Packages; [ (with pkgs.python3Packages; [
duckdb duckdb
polars polars
@ -47,52 +35,44 @@
# p: with p; [ ... ] # p: with p; [ ... ]
then import ./python-packages.nix pkgs.python3Packages then import ./python-packages.nix pkgs.python3Packages
else [] else []
)
); );
juliaPackages = r = replace (
["StatsBase"] (with pkgs.rpkgs.rPackages; [
fixest
# pkgs.extraRPackages.musicMetadata
])
++ (
if builtins.pathExists ./r-packages.nix
# p: with p.rPackages; [ ... ]
then import ./r-packages.nix pkgs.rpkgs
else []
)
);
julia = replace ([
"StatsBase"
]
++ ( ++ (
if builtins.pathExists ./julia-packages.nix if builtins.pathExists ./julia-packages.nix
# [ ... ] # [ ... ]
then import ./julia-packages.nix then import ./julia-packages.nix
else [] else []
); ));
systems = ["aarch64-darwin" "x86_64-linux" "aarch64-linux"];
forAllSystems = nixpkgs.lib.genAttrs systems;
overlays = [inputs.nvimConfig.overlays.dependencies];
in {
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system overlays;
config = {allowUnfree = true;};
};
# Plain attrset — pkgs is captured from the surrounding scope,
# so the module system does not need lazy _module.args resolution.
projectSettings = {
inherit cats;
settings = let
# With `replace` packages are replaced otherwise they are merged with base packages
replace = pkgs.lib.mkForce;
in {
lang_packages = {
python = replace (pythonPackages pkgs);
r = replace (rPackages pkgs);
julia = replace juliaPackages;
}; };
colorscheme = "kanagawa"; colorscheme = "kanagawa";
background = "dark"; background = "dark";
wrapRc = true; wrapRc = true;
}; };
binName = "nv"; binName = "vv";
env = { env = {
IS_PROJECT_EDITOR = "1"; IS_PROJECT_EDITOR = "1";
R_LIBS_USER = "./.nvimcom";
}; };
runtimePkgs = with pkgs; [ extraPackages = with pkgs; [
cowsay cowsay
]; ];
@ -108,83 +88,34 @@
''; '';
}; };
}; };
evalResult = nvimConfig.inputs.wrappers.lib.evalModules {
modules = [ systems = nixpkgs.lib.systems.flakeExposed;
nvimConfig.wrapperModules.default forAllSystems = nixpkgs.lib.genAttrs systems;
projectSettings overlays = [inputs.nvimConfig.overlays.dependencies];
];
};
in { in {
default = evalResult.config.wrap {inherit pkgs;}; packages = forAllSystems (system: let
pkgs = import nixpkgs {inherit system overlays;};
baseNvim = nvimConfig.packages.${system}.default;
nvim = (baseNvim.eval (projectSettings {inherit pkgs;})).config.wrapper;
default = nvim;
in {
default = nvim;
}); });
devShells = forAllSystems (system: let devShells = forAllSystems (system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {inherit system overlays;};
inherit system overlays;
config = {allowUnfree = true;};
};
nv = self.packages.${system}.default; nv = self.packages.${system}.default;
in { in {
default = pkgs.mkShell { default = pkgs.mkShell {
shellHook = '' packages = [nv pkgs.updateR];
exec nu
alias gst='git status'
alias glol='git log --oneline --graph --decorate'
alias gc='git commit'
alias gl='git pull'
alias gp='git push'
'';
packages =
[
nv
pkgs.git
pkgs.pre-commit
pkgs.nushell
]
# ── R toolchain (R REPL, quarto, LSP, formatter) ─────
++ pkgs.lib.optionals cats.r (let
r_packages = (pkgs.baseRPackages or []) ++ rPackages pkgs;
in [
(pkgs.rWrapper.override {packages = r_packages;})
pkgs.radianWrapper
pkgs.air-formatter
pkgs.yaml-language-server
pkgs.nvimcom
pkgs.rnvimserver
])
# ── Python toolchain (interpreter, LSP, formatter) ────
++ pkgs.lib.optionals cats.python [
(pkgs.python3.withPackages (ps: pkgs.basePythonPackages ps ++ pythonPackages pkgs))
pkgs.nodejs
pkgs.ruff
pkgs.basedpyright
pkgs.uv
]
# ── Julia toolchain ───────────────────────────────────
++ pkgs.lib.optionals cats.julia [
pkgs.julia-bin.withPackages
juliaPackages
]
# ── Markdown toolchain (quarto, zk) ───────────────────
++ (let
r_packages = (pkgs.baseRPackages or []) ++ rPackages pkgs;
quarto =
if cats.r
then pkgs.quarto.override {extraRPackages = r_packages;}
else pkgs.quarto;
in
pkgs.lib.optionals cats.markdown [
pkgs.python313Packages.pylatexenc
quarto
pkgs.zk
]);
}; };
}); });
}; };
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rixpkgs.url = "github:dwinkler1/rixpkgs/af2dd3f7b4b172077747c0869d4e30702fb71b0e"; rixpkgs.url = "github:dwinkler1/rixpkgs/nixpkgs";
fran = { fran = {
url = "github:dwinkler1/fran"; url = "github:dwinkler1/fran";
inputs = { inputs = {
@ -197,7 +128,12 @@
rixpkgs.follows = "rixpkgs"; rixpkgs.follows = "rixpkgs";
nixpkgs.follows = "nixpkgs"; nixpkgs.follows = "nixpkgs";
fran.follows = "fran"; fran.follows = "fran";
"plugins-r".follows = "plugins-r";
}; };
}; };
"plugins-r" = {
url = "github:R-nvim/R.nvim/v0.99.3";
flake = false;
};
}; };
} }

View file

@ -185,6 +185,10 @@
julia = config.enabledLanguages.julia; julia = config.enabledLanguages.julia;
python = config.enabledLanguages.python; python = config.enabledLanguages.python;
r = config.enabledLanguages.r; r = config.enabledLanguages.r;
# Enable markdown/quarto plugins whenever R is active so that
# .qmd buffers get proper syntax highlighting and chunk
# recognition via quarto-nvim and otter-nvim.
markdown = config.enabledLanguages.r;
project = true; project = true;
gitPlugins = config.enabledPackages.gitPlugins; gitPlugins = config.enabledPackages.gitPlugins;
background = config.theme.background; background = config.theme.background;
@ -202,11 +206,22 @@
# Development shell configuration # Development shell configuration
devShells = forSystems (system: let devShells = forSystems (system: let
pkgs = import nixpkgs {inherit system;}; pkgs = import nixpkgs {inherit system;};
# When R is enabled, build an overlaid pkgs that includes the R-enhanced
# quarto (with knitr and other R packages baked in via extraRPackages).
# This ensures `quarto render` from the terminal also works correctly.
rPkgs =
if config.enabledLanguages.r
then
import nixpkgs {
inherit system;
overlays = [rixOverlay rOverlay];
}
else pkgs;
# Language-specific packages that should be available in shell # Language-specific packages that should be available in shell
languagePackages = with pkgs; languagePackages =
[] []
++ (if config.enabledLanguages.r then [quarto] else []) ++ (if config.enabledLanguages.r then [rPkgs.quarto] else [])
++ (if config.enabledLanguages.python then [uv] else []) ++ (if config.enabledLanguages.python then [pkgs.uv] else [])
++ (if config.enabledLanguages.julia then [] else []); ++ (if config.enabledLanguages.julia then [] else []);
in { in {
default = pkgs.mkShell { default = pkgs.mkShell {

View file

@ -18,8 +18,10 @@ final: prev: let
broom # Tidy model outputs broom # Tidy model outputs
data_table # Fast data manipulation data_table # Fast data manipulation
janitor # Data cleaning helpers janitor # Data cleaning helpers
knitr # Required by Quarto to execute R code chunks
languageserver # LSP for IDE support languageserver # LSP for IDE support
reprex # Reproducible examples reprex # Reproducible examples
rmarkdown # Required by Quarto for R-based rendering
styler # Code formatting styler # Code formatting
tidyverse # Data science ecosystem tidyverse # Data science ecosystem
] ]