diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e0af74b..a231159 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,20 @@ name: "Test RDE template" on: workflow_dispatch: # allows manual triggering + push: + paths: + - 'templates/rde/flake.lock' + - 'templates/rde/**/*.nix' + - 'templates/rde/**/*.sh' + - 'templates/rde/**/*.lua' + - '.github/workflows/check.yml' + pull_request: + paths: + - 'templates/rde/flake.lock' + - 'templates/rde/**/*.nix' + - 'templates/rde/**/*.sh' + - 'templates/rde/**/*.lua' + - '.github/workflows/check.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -18,7 +32,7 @@ jobs: - uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v17 + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' @@ -111,7 +125,7 @@ jobs: - uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v17 + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' @@ -167,7 +181,7 @@ jobs: - uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v17 + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' diff --git a/.github/workflows/check_ed.yml b/.github/workflows/check_ed.yml index 497d060..7485b62 100644 --- a/.github/workflows/check_ed.yml +++ b/.github/workflows/check_ed.yml @@ -1,19 +1,21 @@ -name: "Test ed template" +name: "Test ED template" on: - workflow_dispatch: + workflow_dispatch: # allows manual triggering push: paths: - - 'templates/ed/**' - - 'tests/ed/**' + - 'templates/ed/flake.lock' + - 'templates/ed/**/*.nix' - '.github/workflows/check_ed.yml' pull_request: paths: - - 'templates/ed/**' - - 'tests/ed/**' + - 'templates/ed/flake.lock' + - 'templates/ed/**/*.nix' - '.github/workflows/check_ed.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: read jobs: tests: runs-on: ${{ matrix.os }} @@ -22,102 +24,257 @@ jobs: os: [ubuntu-latest] steps: - uses: actions/checkout@v6 + - uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: 'carve' - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ github.token }} - - uses: cachix/cachix-action@v17 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - + + # Build and basic checks - name: Build template run: nix build ./templates/ed - - - name: Test R script - env: - NO_NUSHELL: '1' + - name: Run flake check + run: nix flake check ./templates/ed + + # Test development shell functionality + - name: Test dev shell enters successfully run: | cd templates/ed - nix develop --command bash -c "Rscript ${{ github.workspace }}/tests/ed/test.R" - - - name: Test Python script (disabled by default) - env: - NO_NUSHELL: '1' + nix develop --command bash -c "echo 'Dev shell works'" + + # Test Neovim functionality (custom binary name: vv) + - name: Test vv command is available run: | cd templates/ed - nix develop --command bash -c "python3 ${{ github.workspace }}/tests/ed/test.py" || echo "SKIP: Python packages not enabled" - + nix develop --command bash -c "which vv" + + - name: Test vv launches in headless mode + run: | + cd templates/ed + nix develop --command bash -c "vv --headless --version" + + # Test utility commands + - name: Test updateR command is available + run: | + cd templates/ed + nix develop --command bash -c "which updateR" + + # Test extra packages + - name: Test cowsay is available + run: | + cd templates/ed + nix develop --command bash -c "which cowsay" + + - name: Test cowsay works + run: | + cd templates/ed + nix develop --command bash -c "cowsay 'ED template test'" + + # Test that package is built correctly + - name: Test default package can be run + run: | + cd templates/ed + nix run . -- --headless --version + + # Test Neovim configuration + - name: Test mini-notify plugin loads + run: | + cd templates/ed + # Check that the welcome notification config is present + nix develop --command bash -c "vv --headless -c 'lua print(vim.inspect(require(\"mini.notify\")))' -c 'quit' 2>&1 | grep -q 'table'" + test-with-python: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: 'carve' - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ github.token }} - - uses: cachix/cachix-action@v17 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - + + # Create a temporary directory with Python enabled - name: Setup test directory with Python enabled run: | TEST_DIR=$(mktemp -d) cp -r templates/ed/. "$TEST_DIR/" cd "$TEST_DIR" + # Enable Python in the config sed -i 's/python[[:space:]]*=[[:space:]]*false;/python = true;/' flake.nix + # Verify the change was successful grep -q "python[[:space:]]*=[[:space:]]*true;" flake.nix || { echo "Error: Failed to enable Python in flake.nix" exit 1 } - echo "TEST_DIR=$TEST_DIR" >> $GITHUB_ENV - + echo "TEST_PYTHON_DIR=$TEST_DIR" >> $GITHUB_ENV + - name: Build with Python enabled run: | - cd "$TEST_DIR" + cd "$TEST_PYTHON_DIR" nix build - - - name: Test Python packages - env: - NO_NUSHELL: '1' + + - name: Test Python packages are available run: | - cd "$TEST_DIR" - nix develop --command bash -c "python3 ${{ github.workspace }}/tests/ed/test.py" - - test-with-julia: + cd "$TEST_PYTHON_DIR" + nix develop --command bash -c "python3 -c 'import duckdb; import polars; print(\"Python packages loaded\")'" + + - name: Test Python can execute code + run: | + cd "$TEST_PYTHON_DIR" + nix develop --command bash -c "python3 -c 'print(1+1)'" + + test-with-r: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: 'carve' - uses: cachix/install-nix-action@v31 with: - github_access_token: ${{ github.token }} - - uses: cachix/cachix-action@v17 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - + + # Create a temporary directory with R enabled + - name: Setup test directory with R enabled + run: | + TEST_DIR=$(mktemp -d) + cp -r templates/ed/. "$TEST_DIR/" + cd "$TEST_DIR" + # Enable R in the config + sed -i 's/r[[:space:]]*=[[:space:]]*false;/r = true;/' flake.nix + # Verify the change was successful + grep -q "r[[:space:]]*=[[:space:]]*true;" flake.nix || { + echo "Error: Failed to enable R in flake.nix" + exit 1 + } + echo "TEST_R_DIR=$TEST_DIR" >> $GITHUB_ENV + + - name: Build with R enabled + run: | + cd "$TEST_R_DIR" + nix build + + - name: Test R launches + run: | + cd "$TEST_R_DIR" + nix develop --command bash -c "R --version" + + - name: Test R packages are available + run: | + cd "$TEST_R_DIR" + nix develop --command bash -c "R -e 'library(fixest); print(\"R package fixest loaded\")'" + + - name: Test R can execute code + run: | + cd "$TEST_R_DIR" + nix develop --command bash -c "R -e 'print(1+1)'" + + test-with-julia: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: 'carve' + - uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v16 + with: + name: rde + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: rstats-on-nix, nix-community + + # Create a temporary directory with Julia enabled - name: Setup test directory with Julia enabled run: | TEST_DIR=$(mktemp -d) cp -r templates/ed/. "$TEST_DIR/" cd "$TEST_DIR" + # Enable Julia in the config sed -i 's/julia[[:space:]]*=[[:space:]]*false;/julia = true;/' flake.nix + # Verify the change was successful grep -q "julia[[:space:]]*=[[:space:]]*true;" flake.nix || { echo "Error: Failed to enable Julia in flake.nix" exit 1 } - echo "TEST_DIR=$TEST_DIR" >> $GITHUB_ENV - + echo "TEST_JULIA_DIR=$TEST_DIR" >> $GITHUB_ENV + - name: Build with Julia enabled run: | - cd "$TEST_DIR" + cd "$TEST_JULIA_DIR" nix build - - - name: Test Julia packages - env: - NO_NUSHELL: '1' + + - name: Test Julia launches run: | + cd "$TEST_JULIA_DIR" + nix develop --command bash -c "julia --version" + + - name: Test Julia can execute code + run: | + cd "$TEST_JULIA_DIR" + nix develop --command bash -c "julia -e 'println(1+1)'" + + test-with-multiple-languages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: 'carve' + - uses: cachix/install-nix-action@v31 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: cachix/cachix-action@v16 + with: + name: rde + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: rstats-on-nix, nix-community + + # Create a temporary directory with multiple languages enabled + - name: Setup test directory with all languages enabled + run: | + TEST_DIR=$(mktemp -d) + cp -r templates/ed/. "$TEST_DIR/" cd "$TEST_DIR" - # nix develop --command bash -c "julia ${{ github.workspace }}/tests/ed/test.jl" + # Enable all languages in the config + sed -i 's/python[[:space:]]*=[[:space:]]*false;/python = true;/' flake.nix + sed -i 's/r[[:space:]]*=[[:space:]]*false;/r = true;/' flake.nix + sed -i 's/julia[[:space:]]*=[[:space:]]*false;/julia = true;/' flake.nix + # Verify the changes were successful + grep -q "python[[:space:]]*=[[:space:]]*true;" flake.nix || exit 1 + grep -q "r[[:space:]]*=[[:space:]]*true;" flake.nix || exit 1 + grep -q "julia[[:space:]]*=[[:space:]]*true;" flake.nix || exit 1 + echo "TEST_MULTI_DIR=$TEST_DIR" >> $GITHUB_ENV + + - name: Build with all languages enabled + run: | + cd "$TEST_MULTI_DIR" + nix build + + - name: Test all languages work together + run: | + cd "$TEST_MULTI_DIR" + nix develop --command bash -c "python3 --version && R --version && julia --version" + + - name: Test all language packages are available + run: | + cd "$TEST_MULTI_DIR" + nix develop --command bash -c "python3 -c 'import duckdb' && R -e 'library(fixest)' && julia -e 'using StatsBase'" diff --git a/.github/workflows/check_macos.yml b/.github/workflows/check_macos.yml index ad9d3ed..4e49161 100644 --- a/.github/workflows/check_macos.yml +++ b/.github/workflows/check_macos.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: # allows manual triggering push: branches: - - 'update_ed' + - 'update_rde' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -18,9 +18,28 @@ jobs: - uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v17 + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - - run: nix build ./templates/ed + + # Test RDE template + - name: Build RDE template + run: nix build ./templates/rde + - name: Check RDE flake + run: nix flake check ./templates/rde + - name: Test RDE dev shell + run: | + cd templates/rde + nix develop --command bash -c "p --headless --version" + + # Test ED template + - name: Build ED template + run: nix build ./templates/ed + - name: Check ED flake + run: nix flake check ./templates/ed + - name: Test ED dev shell + run: | + cd templates/ed + nix develop --command bash -c "vv --headless --version" diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 4b3cb00..891e992 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -17,16 +17,18 @@ jobs: - uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - uses: cachix/cachix-action@v17 + - uses: cachix/cachix-action@v16 with: name: rde authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' extraPullNames: rstats-on-nix, nix-community - - name: Update ed flake.lock + - run: cd templates/rde/ && nix develop -c p-updateDeps + - run: cd templates/ed/ && nix develop -c updateR + - name: Update n flake.lock uses: DeterminateSystems/update-flake-lock@v28 with: token: ${{ secrets.GH_TOKEN_FOR_UPDATES }} - branch: update_ed + branch: update_rde path-to-flake-dir: "templates/ed" pr-title: "Update RDE flake.lock" # Title of PR to be created pr-labels: | # Labels to be set on the PR diff --git a/README.md b/README.md index bfa3c32..daf004d 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,32 @@ A collection of Nix flake templates for reproducible development environments. ## Templates +### ED (Editor) + +A simple Neovim-based development environment with optional language support. + +**Quick start:** +```bash +nix flake init -t github:dwinkler1/np#ed +nix develop +vv # Launch Neovim (custom binary name) +``` + +**Features:** +- ✨ Lightweight Neovim configuration +- 🔧 Configurable language support (Python, R, Julia, Nix) +- 📦 Reproducible with Nix +- 🎨 Custom theming (Kanagawa by default) +- 🔔 Mini-notify plugin for notifications + +**Default configuration:** +- Nix support enabled +- Custom binary: `vv` +- Includes: cowsay, updateR utility + ### RDE (Research Development Environment) -The default template for data science and research projects with support for R, Python, and Julia. +A comprehensive template for data science and research projects with support for R, Python, and Julia. **Quick start:** ```bash @@ -34,12 +57,63 @@ All templates are automatically tested to ensure functionality: ### CI Workflows -- `.github/workflows/check.yml` - Comprehensive functionality tests (Ubuntu) -- `.github/workflows/check_macos.yml` - macOS compatibility tests +**RDE Template:** +- `.github/workflows/check.yml` - Comprehensive functionality tests for RDE (Ubuntu) + - Basic build and flake checks + - Dev shell functionality + - R command availability and functionality + - Neovim integration + - Utility commands (p-initProject, p-updateDeps) + - Separate jobs for Python and Julia configurations + +**ED Template:** +- `.github/workflows/check_ed.yml` - Comprehensive functionality tests for ED (Ubuntu) + - Basic build and flake checks + - Dev shell functionality + - Neovim (vv) command tests + - updateR utility tests + - Extra packages (cowsay) verification + - Separate jobs for Python, R, Julia, and multi-language configurations + +**Cross-platform:** +- `.github/workflows/check_macos.yml` - macOS compatibility tests for both templates - `.github/workflows/update.yml` - Automated dependency updates ## Usage +### ED Template + +1. **Initialize a new project:** + ```bash + nix flake init -t github:dwinkler1/np#ed + ``` + +2. **Enter development environment:** + ```bash + nix develop + # or with direnv + echo "use flake" > .envrc && direnv allow + ``` + +3. **Start editing:** + ```bash + vv # Launch Neovim + updateR # Update R packages (when R is enabled) + cowsay "Hello!" # Fun utility included + ``` + +4. **Enable languages:** + Edit `flake.nix` and change `false` to `true` in the `cats` section: + ```nix + cats = { + python = true; # Enable Python support + r = true; # Enable R support + julia = true; # Enable Julia support + }; + ``` + +### RDE Template + 1. **Initialize a new project:** ```bash nix flake init -t github:dwinkler1/np#rde diff --git a/templates/ed/.gitignore b/templates/ed/.gitignore index ffc0e1a..52e8a70 100644 --- a/templates/ed/.gitignore +++ b/templates/ed/.gitignore @@ -1,2 +1 @@ .nvimcom -.commandcode/ diff --git a/templates/ed/README.md b/templates/ed/README.md index 272d827..b78c32d 100644 --- a/templates/ed/README.md +++ b/templates/ed/README.md @@ -1,73 +1,284 @@ -# Project Editor +# ED Template - Simple Editor Environment -A per-project Neovim wrapper built with [nix-wrapper-modules](https://birdeehub.github.io/nix-wrapper-modules/) and [nvimConfig](https://github.com/dwinkler1/nvimConfig). +A lightweight, customizable Neovim-based development environment with optional language support for Python, R, Julia, and Nix. -## Setup +## Features -The flake provides two entry points: +- ✨ **Lightweight**: Minimal configuration, fast startup +- 🔧 **Configurable**: Enable only the languages you need +- 📦 **Reproducible**: Nix-based environment management +- 🎨 **Themed**: Beautiful Kanagawa colorscheme (customizable) +- 🔔 **Notifications**: Mini-notify plugin for user feedback -| 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) +## Quick Start ```bash -direnv allow # enter the devShell automatically -nv # launch the pre-configured Neovim -R # R REPL is available (if enabled in flake.nix) +# Initialize a new project with the ED template +nix flake init -t github:dwinkler1/np#ed + +# Enter the development environment +nix develop + +# Launch Neovim +vv ``` -### 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: +The ED template uses a centralized configuration structure at the top of `flake.nix`: -| Option | What it controls | -|---|---| -| `cats` | Toggle language support (nix, r, python, julia, etc.) | -| `settings.lang_packages.` | 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 +```nix +cats = { + clickhouse = false; + gitPlugins = false; + julia = false; + lua = false; + markdown = false; + nix = true; # Enabled by default + optional = false; + python = false; + r = false; +}; ``` -Uses `nixfmt-rfc-style` pinned via the flake's `formatter` output. +### Enabling Languages + +To enable support for a specific language, edit `flake.nix` and set the corresponding cat to `true`: + +#### Python +```nix +cats = { + python = true; + # ... other settings +}; +``` + +Includes: Python 3, duckdb, polars packages by default + +#### R +```nix +cats = { + r = true; + # ... other settings +}; +``` + +Includes: fixest package by default + +#### Julia +```nix +cats = { + julia = true; + # ... other settings +}; +``` + +Includes: StatsBase package by default + +### Custom Package Files + +You can specify additional packages by creating these files in your project: + +- `python-packages.nix` - Additional Python packages + ```nix + p: with p; [ + numpy + pandas + # ... more packages + ] + ``` + +- `r-packages.nix` - Additional R packages + ```nix + p: with p.rPackages; [ + ggplot2 + dplyr + # ... more packages + ] + ``` + +- `julia-packages.nix` - Additional Julia packages + ```nix + [ + "DataFrames" + "Plots" + # ... more packages + ] + ``` + +## Available Commands + +### Neovim +- `vv` - Launch Neovim (custom binary name) +- `vv --headless` - Run Neovim in headless mode for scripting + +### Utilities +- `updateR` - Update R package snapshots from rstats-on-nix +- `cowsay` - Fun ASCII art text formatter (included as example) + +## Customization + +### Binary Name + +The default binary name is `vv`. To change it, edit the `binName` in `flake.nix`: + +```nix +binName = "myeditor"; # Changes command from 'vv' to 'myeditor' +``` + +### Colorscheme + +Change the colorscheme in the settings section: + +```nix +settings = { + colorscheme = "kanagawa"; # or "gruvbox", "tokyonight", etc. + background = "dark"; # or "light" + # ... +}; +``` + +### Extra Packages + +Add more system packages in the `extraPackages` section: + +```nix +extraPackages = with pkgs; [ + cowsay + ripgrep + fd + # ... more packages +]; +``` + +### Welcome Message + +The template includes a welcome notification. Customize it in the `specs.extraLua` section: + +```nix +config = '' + require("mini.notify").setup() + vim.notify = MiniNotify.make_notify() + vim.notify("Welcome to ${name}!") +''; +``` + +## Environment Variables + +The template sets the following environment variables: + +- `IS_PROJECT_EDITOR=1` - Indicates you're in the project editor environment +- `R_LIBS_USER=./.nvimcom` - Project-local R package directory + +## Language Package Management + +### Replace vs Merge + +By default, language packages are **replaced** rather than merged with base packages. This is controlled by: + +```nix +let + replace = pkgs.lib.mkForce; +in { + lang_packages = { + python = replace ([...]); # Replaces base packages + r = replace ([...]); # Replaces base packages + julia = replace ([...]); # Replaces base packages + }; +} +``` + +To **merge** with base packages instead, remove the `replace` wrapper: + +```nix +lang_packages = { + python = (with pkgs.python3Packages; [...]); + # ... +}; +``` + +## Development Shell + +The development shell provides access to the Neovim package plus additional utilities: + +```bash +nix develop # Enter the dev shell +``` + +Available in dev shell: +- `vv` - The configured Neovim +- `updateR` - Update R packages (when R support is enabled) +- All packages listed in `extraPackages` + +## Testing + +The ED template has comprehensive CI/CD tests: + +### Automated Tests (`.github/workflows/check_ed.yml`) + +1. **Basic Tests** (Ubuntu) + - Build verification + - Flake check + - Dev shell entry + - Neovim launch and version check + - Utility commands availability + +2. **Language-Specific Tests** + - Python configuration: Package imports, code execution + - R configuration: Package loading, code execution + - Julia configuration: Version check, code execution + - Multi-language: All languages enabled together + +3. **macOS Tests** (`.github/workflows/check_macos.yml`) + - Build verification on macOS + - Basic functionality tests + +## Tips + +1. **Use direnv for automatic environment loading:** + ```bash + echo "use flake" > .envrc + direnv allow + ``` + +2. **Pin specific package versions** by editing `flake.lock`: + ```bash + nix flake update # Update all inputs + nix flake lock --update-input nixpkgs # Update specific input + ``` + +3. **Check what's included in your build:** + ```bash + nix path-info -Sh ./result + ``` + +4. **Build for different platforms:** + ```bash + nix build .#packages.x86_64-linux.default + nix build .#packages.aarch64-darwin.default + ``` + +## Comparison with RDE Template + +| Feature | ED Template | RDE Template | +|---------|-------------|--------------| +| **Complexity** | Lightweight | Comprehensive | +| **Binary Name** | `vv` | `p` | +| **Project Structure** | Manual | `p-initProject` command | +| **Language Support** | Optional (Python, R, Julia, Nix) | Built-in (R default, Python/Julia optional) | +| **Research Tools** | None | Quarto, Marimo, Pluto.jl | +| **Package Management** | updateR | p-updateDeps (comprehensive) | +| **Use Case** | Simple editing, lightweight projects | Research, data science, complex projects | + +## Contributing + +When modifying the ED template, please ensure: + +1. All tests pass in `.github/workflows/check_ed.yml` +2. The template builds on both Linux and macOS +3. Documentation is updated to reflect changes +4. Changes follow the existing code patterns + +## License + +See [LICENSE](../../LICENSE) file for details. diff --git a/templates/ed/flake.lock b/templates/ed/flake.lock index feb65be..5839626 100644 --- a/templates/ed/flake.lock +++ b/templates/ed/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1776413584, - "narHash": "sha256-xqqv46MTveuT4yJH2YihmbHGy5mdLnnLFDebVmUws/E=", + "lastModified": 1771133455, + "narHash": "sha256-DvHfkW3DctWV+YnigY4+5Stn9NgI38JqR2IScXDX8z8=", "owner": "dwinkler1", "repo": "fran", - "rev": "da09626e4dd8f0f57078b3a04e0443a8c20defa1", + "rev": "68b189ab981adae06590ee1929a70c8b86afd2b8", "type": "github" }, "original": { @@ -22,16 +22,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779560665, - "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", - "owner": "nixos", + "lastModified": 1771043024, + "narHash": "sha256-O1XDr7EWbRp+kHrNNgLWgIrB0/US5wvw9K6RERWAj6I=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", + "rev": "3aadb7ca9eac2891d52a9dec199d9580a6e2bf44", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" } @@ -45,18 +45,18 @@ "nixpkgs" ], "plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references", - "r-nvim-nix": "r-nvim-nix", + "plugins-r": "plugins-r", "rixpkgs": [ "rixpkgs" ], "wrappers": "wrappers" }, "locked": { - "lastModified": 1779544872, - "narHash": "sha256-AnuNQ9nbXrDYmL97TOejAds/FQOgD6FEOHABp/8dmsU=", + "lastModified": 1770172480, + "narHash": "sha256-gem34C89cocBGuWLj7cdrAS5WkrOBp6V+ycQM/RhcCw=", "owner": "dwinkler1", "repo": "nvimConfig", - "rev": "aec9110e709e1aa50d78f06293c4bde14974b23f", + "rev": "8f5c05252e914cb3738039a7ec13eb7d5955227a", "type": "github" }, "original": { @@ -81,59 +81,35 @@ "type": "github" } }, - "r-nvim-nix": { - "inputs": { - "nixpkgs": [ - "nvimConfig", - "rixpkgs" - ], - "rnvimsrc": "rnvimsrc" - }, + "plugins-r": { + "flake": false, "locked": { - "lastModified": 1779438909, - "narHash": "sha256-1lvv0bdvSVyeCIgeZ7Ws7ffbDFurA5LJscS9dRLHzC8=", - "owner": "dwinkler1", - "repo": "r_nvim_nix", - "rev": "ec17e22ab362a0ddfd6c2e9c5e95d43897a143be", + "lastModified": 1769736135, + "narHash": "sha256-T4QgcBL+LCXvrEiRE2JW4jtUKl8DKzFHk8czGUO1jgY=", + "owner": "R-nvim", + "repo": "R.nvim", + "rev": "2701ec64f5485e17c0e057081a9ae2058d776464", "type": "github" }, "original": { - "owner": "dwinkler1", - "ref": "v0.99.4", - "repo": "r_nvim_nix", + "owner": "R-nvim", + "repo": "R.nvim", "type": "github" } }, "rixpkgs": { "locked": { - "lastModified": 1771303851, - "narHash": "sha256-tgveHozOJ2D/mi3LxVy/FcmLFDlM5XKZxsNB2XpvzaM=", - "owner": "dwinkler1", - "repo": "rixpkgs", - "rev": "af2dd3f7b4b172077747c0869d4e30702fb71b0e", + "lastModified": 1770035835, + "narHash": "sha256-Pi8f3LPTFmG7SZeAJEAamOWly1SZhEofT92uBqS4atY=", + "owner": "rstats-on-nix", + "repo": "nixpkgs", + "rev": "0d3fe7afce51d2126fdccf0b717d8048b90e4781", "type": "github" }, "original": { - "owner": "dwinkler1", - "repo": "rixpkgs", - "rev": "af2dd3f7b4b172077747c0869d4e30702fb71b0e", - "type": "github" - } - }, - "rnvimsrc": { - "flake": false, - "locked": { - "lastModified": 1776905071, - "narHash": "sha256-dXox6qEs1VDE7vPNDoN8bY4g06uj1IEs6uki72w8lpA=", - "owner": "R-nvim", - "repo": "R.nvim", - "rev": "582f2af11290ac067e49018db38e12a511325556", - "type": "github" - }, - "original": { - "owner": "R-nvim", - "ref": "v0.99.4", - "repo": "R.nvim", + "owner": "rstats-on-nix", + "ref": "2026-02-02", + "repo": "nixpkgs", "type": "github" } }, @@ -153,11 +129,11 @@ ] }, "locked": { - "lastModified": 1779297405, - "narHash": "sha256-VFoBwH7ZjVxCnvZTb5ODRXt70sLtWMxstive0N+RS50=", + "lastModified": 1769745458, + "narHash": "sha256-Fq6THKEiAKx+wWQ4wTg9HvOAyD6i8JkWfHVQDZH7Byo=", "owner": "BirdeeHub", "repo": "nix-wrapper-modules", - "rev": "e7ed7a1205945befdf2e0d73ba7df91d935e5af1", + "rev": "cc5e052dd1e93ae75dc06e3fabf46f0820c272f2", "type": "github" }, "original": { diff --git a/templates/ed/flake.nix b/templates/ed/flake.nix index 07603fa..46b9141 100644 --- a/templates/ed/flake.nix +++ b/templates/ed/flake.nix @@ -6,36 +6,8 @@ nixpkgs, nvimConfig, ... - }: let - systems = ["aarch64-darwin" "x86_64-linux" "aarch64-linux"]; - forAllSystems = nixpkgs.lib.genAttrs systems; - - mkPkgs = system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = [nvimConfig.overlays.dependencies]; - }; - - projectModule = pkgs: let - baseConfig = nvimConfig.wrapperConfigs.default {inherit pkgs;}; - extraRPackages = - if builtins.pathExists ./r-packages.nix - then import ./r-packages.nix pkgs.rpkgs - else []; - - extraPythonPackages = - if builtins.pathExists ./python-packages.nix - then import ./python-packages.nix pkgs.python3Packages - else []; - - extraJuliaPackages = - if builtins.pathExists ./julia-packages.nix - then import ./julia-packages.nix - else []; - - projectName = builtins.baseNameOf (toString self.outPath); - in { + } @ inputs: let + projectSettings = {pkgs}: { cats = { clickhouse = false; gitPlugins = false; @@ -45,115 +17,116 @@ nix = true; optional = false; python = false; - r = true; + r = false; }; - settings = { + settings = let + # With `replace` packages are replaced otherwise they are merged with base packages + replace = pkgs.lib.mkForce; + in { lang_packages = { - python = with pkgs.python3Packages; - [ - requests - ] - ++ extraPythonPackages; - - r = - (with pkgs.rpkgs.rPackages; [ - arrow - data_table - fixest - pkgs.nvimcom + python = replace ( + (with pkgs.python3Packages; [ + duckdb + polars ]) - ++ extraRPackages; + ++ ( + if builtins.pathExists ./python-packages.nix + # p: with p; [ ... ] + then import ./python-packages.nix pkgs.python3Packages + else [] + ) + ); - julia = - ["StatsBase"] - ++ extraJuliaPackages; + r = replace ( + (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 + # [ ... ] + then import ./julia-packages.nix + else [] + )); }; - - colorscheme = "tokyonight"; #"kanagawa"; + colorscheme = "kanagawa"; background = "dark"; wrapRc = true; }; + binName = "vv"; - binName = "nv"; - - env.IS_PROJECT_EDITOR = "1"; - - catPkgs = { - always = [ - pkgs.git - pkgs.pre-commit - pkgs.cowsay - ]; - - nix = [ - pkgs.nil - pkgs.nixfmt - ]; + env = { + IS_PROJECT_EDITOR = "1"; + R_LIBS_USER = "./.nvimcom"; }; - specs.extraLua = { + extraPackages = with pkgs; [ + cowsay + ]; + + specs.extraLua = let + name = builtins.baseNameOf (builtins.toString ./.); + in { + data = pkgs.vimPlugins.mini-notify; before = ["INIT_MAIN"]; - data = pkgs.writeText "project-startup.lua" '' + config = '' require("mini.notify").setup() vim.notify = MiniNotify.make_notify() - vim.notify("Welcome to ${projectName}!") + vim.notify("Welcome to ${name}!") ''; }; }; - in { - formatter = forAllSystems (system: (mkPkgs system).nixfmt-tree); + systems = nixpkgs.lib.systems.flakeExposed; + forAllSystems = nixpkgs.lib.genAttrs systems; + overlays = [inputs.nvimConfig.overlays.dependencies]; + in { packages = forAllSystems (system: let - pkgs = mkPkgs system; + pkgs = import nixpkgs {inherit system overlays;}; + baseNvim = nvimConfig.packages.${system}.default; + + nvim = (baseNvim.eval (projectSettings {inherit pkgs;})).config.wrapper; + default = nvim; in { - default = nvimConfig.lib.mkWrapper { - inherit pkgs; - modules = [(projectModule pkgs)]; - }; + default = nvim; }); devShells = forAllSystems (system: let - pkgs = mkPkgs system; - evalResult = nvimConfig.lib.eval { - inherit pkgs; - modules = [(projectModule pkgs)]; - }; - nv = evalResult.config.wrap {inherit pkgs;}; + pkgs = import nixpkgs {inherit system overlays;}; + nv = self.packages.${system}.default; in { default = pkgs.mkShell { - packages = - [ - nv - pkgs.nushell - ] - ++ nvimConfig.lib.devShellPackages evalResult.config; - shellHook = - nvimConfig.lib.shellHook evalResult.config - + '' - if [ -z "''${NO_NUSHELL:-}" ]; then - exec nu - fi - ''; + packages = [nv pkgs.updateR]; }; }); }; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - - rixpkgs.url = "github:dwinkler1/rixpkgs/af2dd3f7b4b172077747c0869d4e30702fb71b0e"; - + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + rixpkgs.url = "github:dwinkler1/rixpkgs/nixpkgs"; fran = { url = "github:dwinkler1/fran"; - inputs.nixpkgs.follows = "rixpkgs"; + inputs = { + nixpkgs.follows = "rixpkgs"; + }; }; - nvimConfig = { url = "github:dwinkler1/nvimConfig"; inputs = { - nixpkgs.follows = "nixpkgs"; rixpkgs.follows = "rixpkgs"; + nixpkgs.follows = "nixpkgs"; fran.follows = "fran"; }; }; diff --git a/templates/rde/flake.lock b/templates/rde/flake.lock index 6e88194..7617db3 100644 --- a/templates/rde/flake.lock +++ b/templates/rde/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1776413584, - "narHash": "sha256-xqqv46MTveuT4yJH2YihmbHGy5mdLnnLFDebVmUws/E=", + "lastModified": 1771133455, + "narHash": "sha256-DvHfkW3DctWV+YnigY4+5Stn9NgI38JqR2IScXDX8z8=", "owner": "dwinkler1", "repo": "fran", - "rev": "da09626e4dd8f0f57078b3a04e0443a8c20defa1", + "rev": "68b189ab981adae06590ee1929a70c8b86afd2b8", "type": "github" }, "original": { @@ -73,11 +73,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1777077449, - "narHash": "sha256-AIiMJiqvGrN4HyLEbKAoCSRRYn0rnlW5VbKNIMIYqm4=", + "lastModified": 1771043024, + "narHash": "sha256-O1XDr7EWbRp+kHrNNgLWgIrB0/US5wvw9K6RERWAj6I=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a4bf06618f0b5ee50f14ed8f0da77d34ecc19160", + "rev": "3aadb7ca9eac2891d52a9dec199d9580a6e2bf44", "type": "github" }, "original": { @@ -138,16 +138,16 @@ }, "rixpkgs": { "locked": { - "lastModified": 1776958221, - "narHash": "sha256-cOHLrMWifj8HQMIG6gMhGowwPAkyX/kijDx38wK8kUM=", + "lastModified": 1770035835, + "narHash": "sha256-Pi8f3LPTFmG7SZeAJEAamOWly1SZhEofT92uBqS4atY=", "owner": "rstats-on-nix", "repo": "nixpkgs", - "rev": "db90c554b7172188324b84deea35ed5975e20e44", + "rev": "0d3fe7afce51d2126fdccf0b717d8048b90e4781", "type": "github" }, "original": { "owner": "rstats-on-nix", - "ref": "2026-04-22", + "ref": "2026-02-02", "repo": "nixpkgs", "type": "github" } diff --git a/templates/rde/flake.nix b/templates/rde/flake.nix index 12ae4f0..a6aa9a3 100644 --- a/templates/rde/flake.nix +++ b/templates/rde/flake.nix @@ -219,7 +219,7 @@ }); }; inputs = { - rixpkgs.url = "github:rstats-on-nix/nixpkgs/2026-04-22"; + rixpkgs.url = "github:rstats-on-nix/nixpkgs/2026-02-02"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; nixCats = { url = "github:dwinkler1/nixCatsConfig"; diff --git a/tests/ed/test.R b/tests/ed/test.R deleted file mode 100755 index ad2967a..0000000 --- a/tests/ed/test.R +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env Rscript - -packages <- c("arrow", "data.table", "fixest", "nvimcom") -failed <- character(0) - -for (pkg in packages) { - ok <- tryCatch( - { - # nvimcom requires Neovim; skip loading but check it's installed - if (pkg == "nvimcom") { - requireNamespace(pkg, quietly = TRUE) - } else { - library(pkg, character.only = TRUE, quietly = TRUE) - } - TRUE - }, - error = function(e) FALSE - ) - if (!ok) { - failed <- c(failed, pkg) - } -} - -if (length(failed) > 0) { - cat(sprintf("FAIL: %s\n", paste(failed, collapse = ", "))) - quit(status = 1) -} - -cat("PASS: all packages loaded\n") diff --git a/tests/ed/test.jl b/tests/ed/test.jl deleted file mode 100755 index 5971f80..0000000 --- a/tests/ed/test.jl +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env julia - -packages = ["StatsBase"] -failed = String[] - -for pkg in packages - try - @eval using $pkg - catch - push!(failed, pkg) - end -end - -if !isempty(failed) - @error "FAIL: $(join(failed, ", "))" - exit(1) -end - -println("PASS: all packages loaded") diff --git a/tests/ed/test.py b/tests/ed/test.py deleted file mode 100755 index b893419..0000000 --- a/tests/ed/test.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 -import sys - -packages = ["requests"] -failed = [] - -for pkg in packages: - try: - __import__(pkg) - except ImportError: - failed.append(pkg) - -if failed: - sys.stderr.write(f"FAIL: {', '.join(failed)}\n") - sys.exit(1) - -print("PASS: all packages loaded")