Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
needs: [approved]
strategy:
matrix:
template: [bogus, minimal, microvm]
template: [bogus, minimal, microvm, nvf-standalone]
os: [ubuntu-latest]
name: Check template ${{matrix.template}} ${{matrix.os}}
runs-on: ${{matrix.os}}
Expand All @@ -100,6 +100,8 @@ jobs:
EOF
git add templates/${{matrix.template}}/modules/ci-runtime.nix
- run: nix flake check -L ./templates/${{matrix.template}} --override-input den github:$GITHUB_REPOSITORY/$GITHUB_SHA
- run: (cd templates/nvf-standalone && nix build .#my-neovim)
if: matrix.template == 'nvf-standalone'
- run: (cd templates/minimal && nix build .#.nixosConfigurations.igloo.config.system.build.toplevel)
if: matrix.template == 'minimal'
- run: (cd templates/minimal && nix run .#igloo -- build --offline)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ Growing community adoption: [Usage Search](https://github.com/search?q=den.aspec
nix run github:vic/den?dir=templates/microvm#runnable-microvm
```

```console
# Run NVF-Standalone neovim from templates/nvf-standalone
nix run github:vic/den?dir=templates/nvf-standalone#my-neovim
```

```console
# Run qemu VM from templates/example
nix run github:vic/den
Expand Down
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default defineConfig({
{ label: 'Minimal', slug: 'tutorials/minimal' },
{ label: 'Default', slug: 'tutorials/default' },
{ label: 'No-Flake', slug: 'tutorials/noflake' },
{ label: 'NVF Standalone', slug: 'tutorials/nvf-standalone' },
{ label: 'MicroVM', slug: 'tutorials/microvm' },
{ label: 'Example', slug: 'tutorials/example' },
{ label: 'Bug Reproduction', slug: 'tutorials/bogus' },
Expand Down
34 changes: 34 additions & 0 deletions docs/src/content/docs/tutorials/nvf-standalone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Template: NVF Standalone"
description: Den based NVF configuration without NixOS
---

The `nvf-standalone` template demonstrates how to use Den for
other configurations outside NixOS/nix-Darwin/HM. For demo
purposes this uses [NVF Standalone](https://nvf.notashelf.dev/#ch-standalone-installation) to confirue a runnable `.#my-neovim` app.

## Initialize

```console
mkdir my-neovim && cd my-neovim
nix flake init -t github:vic/den#nvf-standalone
nix flake update den
nix run .#my-neovim
```

## Project Structure

```
flake.nix # dependencies including NVF
modules/
den.nix # uses Den to expose an standalone neovim app.
```

Key points:
- **Runnable app** — exposes `.#my-neovim` app
- **Custom forward class** — uses a `vim` class that forwards to `nvf.config.vim`
- **Custom ctx** — shows how to use Den with custom context to resolve `nvf` module.

## Next Steps

- Read [NVF Documentation](https://nvf.notashelf.dev/)
1 change: 1 addition & 0 deletions docs/src/content/docs/tutorials/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nix flake init -t github:vic/den#<template>
| [**default**](/tutorials/default/) | Recommended starting point | ✓ | ✓ | ✓ |
| [**example**](/tutorials/example/) | Feature showcase with namespaces | ✓ | ✓ | ✓ |
| [**noflake**](/tutorials/noflake/) | Stable Nix, no flakes | ✗ | ✗ | ✗ |
| [**nvf-standalone**](/tutorials/nv-standalone/) | Den based NVF without NixOS | ✓ | ✗ | ✗ |
| [**microvm**](/tutorials/microvm/) | MicroVM host and guests | ✓ | ✗ | ✗ |
| [**bogus**](/tutorials/bogus/) | Bug reproduction | ✓ | ✓ | ✓ |
| [**ci**](/tutorials/ci/) | Den's own test suite | ✓ | ✓ | ✓ |
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let
example.description = "Example";
microvm.path = ../templates/microvm;
microvm.description = "MicroVM example";
nvf-standalone.path = ../templates/nvf-standalone;
nvf-standalone.description = "Standalone NVF";
ci.path = ../templates/ci;
ci.description = "Feature Tests";
bogus.path = ../templates/bogus;
Expand Down
15 changes: 15 additions & 0 deletions templates/nvf-standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NVF Standalone in Den

This is an example showing how to create custom
configurations outside NixOS/Darwin/HM in Den.

For Demo purposes this template configures
an [NVF Standalone](https://nvf.notashelf.dev/index.html#ch-standalone-installation) instance using Den aspects
and forwarding classes.

It exposes the standalone nvf as `my-neovim` app,
runnable with:

```console
nix run .#my-neovim
```
187 changes: 187 additions & 0 deletions templates/nvf-standalone/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions templates/nvf-standalone/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
outputs =
inputs:
(inputs.nixpkgs.lib.evalModules {
modules = [ (inputs.import-tree ./modules) ];
specialArgs = { inherit inputs; };
}).config.flake;

inputs = {
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
import-tree.url = "github:vic/import-tree";
flake-aspects.url = "github:vic/flake-aspects";
den.url = "github:vic/den";
nvf.url = "github:notashelf/nvf";
nvf.inputs.nixpkgs.follows = "nixpkgs";
};
}
50 changes: 50 additions & 0 deletions templates/nvf-standalone/modules/den.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
inputs,
den,
lib,
...
}:
{
imports = [ inputs.den.flakeModule ];

# a custom `vim` class that forwards to `nvf.config.vim`
den.aspects.vimClass =
{ class, aspect-chain }:
den._.forward {
each = lib.singleton true;
fromClass = _: "vim";
intoClass = _: "nvf";
intoPath = _: [
"config"
"vim"
];
fromAspect = _: lib.head aspect-chain;
adaptArgs = lib.id;
};

den.aspects.my-neovim = {
includes = [ den.aspects.vimClass ];

vim.theme.enable = true;
};

# Expose my-neovim app. Runnable with `nix run .#my-neovim`.
# Adapt if you use flake-parts or whatever
flake.packages = lib.genAttrs lib.systems.flakeExposed (
system:
let
ctx = { }; # whatever context your aspects need
aspect = den.aspects.my-neovim ctx;
module = den.lib.aspects.resolve "nvf" [ ] aspect;

nvf = inputs.nvf.lib.neovimConfiguration {
pkgs = inputs.nixpkgs.legacyPackages.${system};
modules = [ module ];
};
my-neovim = nvf.neovim;
in
{
inherit my-neovim;
}
);
}
Loading