Merge branch 'main' into patch-2

This commit is contained in:
raf 2025-07-20 14:39:14 +03:00 committed by GitHub
commit 6ffe9302a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 232 additions and 30 deletions

15
default.nix Normal file
View file

@ -0,0 +1,15 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.flake-compat.locked) url rev narHash;
in
builtins.fetchTarball {
url = "${url}/archive/${rev}.tar.gz";
sha256 = narHash;
}
) {
src = ./.;
copySourceTreeToStore = false;
useBuiltinsFetchTree = true;
})
.defaultNix

View file

@ -0,0 +1,33 @@
### Prerequisites {#sec-flakes-prerequisites}
To install nvf with flakes, you must make sure the following requirements are
met.
1. Nix 2.4 or later must be installed. You may use `nix-shell` to get a later
version of Nix from nixpkgs.
2. Flake-related experimental features must be enabled. Namely, you need
`nix-command` and `flakes`. Some Nix vendors enable those by default, please
consult their documentation if you are not using mainstream Nix.
- When using NixOS, add the following to your `configuration.nix` and rebuild
your system.
```nix
nix.settings.experimental-features = "nix-command flakes";
```
- If you are not using NixOS, add the following to `nix.conf` (located at
`~/.config/nix/` or `/etc/nix/nix.conf`).
```bash
experimental-features = nix-command flakes
```
- You may need to restart the Nix daemon with, for example,
`sudo systemctl restart nix-daemon.service`.
- Alternatively, you can enable flakes on a per-command basis with the
following additional flags to `nix` and `home-manager`:
```sh
$ nix --extra-experimental-features "nix-command flakes" <sub-commands>
```

View file

@ -5,9 +5,18 @@ inside the home-manager configuration without having to call for the wrapper
yourself. It is the recommended way to use **nvf** alongside the NixOS module
depending on your needs.
To use it, we first add the input flake.
## With Flakes {#sec-hm-flakes}
```{=include=}
flakes.md
```
### Usage {#sec-hm-flakes-usage}
To use **nvf** with flakes, we first need to add the input to our `flake.nix`.
```nix
# flake.nix
{
inputs = {
# Optional, if you intend to follow nvf's obsidian-nvim input
@ -16,7 +25,7 @@ To use it, we first add the input flake.
# Required, nvf works best and only directly supports flakes
nvf = {
url = "github:notashelf/nvf";
url = "github:NotAShelf/nvf";
# You can override the input nixpkgs to follow your system's
# instance of nixpkgs. This is safe to do as nvf does not depend
# on a binary cache.
@ -25,6 +34,8 @@ To use it, we first add the input flake.
# for example:
inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs
};
# ...
};
}
```
@ -39,7 +50,7 @@ Followed by importing the home-manager module somewhere in your configuration.
}
```
## Example Installation {#sec-example-installation-hm}
### Example Installation {#sec-example-installation-hm}
```nix
{
@ -66,7 +77,8 @@ Once the module is properly imported by your host, you will be able to use the
`programs.nvf` module option anywhere in your configuration in order to
configure **nvf**.
```nix{
```nix
{
programs.nvf = {
enable = true;
# your settings need to go into the settings attribute set
@ -89,3 +101,45 @@ installation sections of the manual. You may find all available options in the
[appendix](https://notashelf.github.io/nvf/options)
:::
## Without Flakes {#sec-hm-flakeless}
As of v0.8, it is possible to install **nvf** on a system if you are not using
flakes. This is possible thanks to the flake-compat project.
To get started, you must fetch the repository using `builtins.fetchTarball` or a
similar mechanism.
```nix
# home.nix
let
nvf = import (builtins.fetchTarball {
url = "https://github.com/notashelf/nvf/archive/<commit or tag>.tar.gz";
# Optionally, you can add 'sha256' for verification and caching
# sha256 = "<sha256>";
});
in {
imports = [
# Import the NixOS module from your fetched input
nvf.homeManagerModules.nvf
];
# Once the module is imported, you may use `programs.nvf` as exposed by the
# NixOS module.
programs.nvf.enable = true;
}
```
[npins]: https://github.com/andir/npins
[niv]: https://github.com/nmattia/niv
::: {.tip}
Nix2 does not have a builtin lockfile mechanism like flakes. As such you must
manually update the URL and hash for your input. This is annoying to deal with,
and most users choose to defer this task to projects such as [npins] or [niv].
If you are new to NixOS, I encourage you to look into Flakes and see if they fit
your use case. Alternatively, look into the aforementioned projects for more
convenient dependency management mechanisms.
:::

View file

@ -5,9 +5,18 @@ the NixOS configuration without having to call for the wrapper yourself. It is
the recommended way to use **nvf** alongside the home-manager module depending
on your needs.
To use it, we first add the input flake.
## With Flakes {#sec-nixos-flakes}
```{=include=}
flakes.md
```
### Usage {#sec-nixos-flakes-usage}
To use **nvf** with flakes, we first need to add the input to our `flake.nix`.
```nix
# flake.nix
{
inputs = {
# Optional, if you intend to follow nvf's obsidian-nvim input
@ -16,7 +25,7 @@ To use it, we first add the input flake.
# Required, nvf works best and only directly supports flakes
nvf = {
url = "github:notashelf/nvf";
url = "github:NotAShelf/nvf";
# You can override the input nixpkgs to follow your system's
# instance of nixpkgs. This is safe to do as nvf does not depend
# on a binary cache.
@ -25,6 +34,8 @@ To use it, we first add the input flake.
# for example:
inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs
};
# ...
};
}
```
@ -39,7 +50,7 @@ Followed by importing the NixOS module somewhere in your configuration.
}
```
## Example Installation {#sec-example-installation-nixos}
### Example Installation {#sec-example-installation-nixos}
```nix
{
@ -64,10 +75,12 @@ Once the module is properly imported by your host, you will be able to use the
`programs.nvf` module option anywhere in your configuration in order to
configure **nvf**.
```nix{
```nix
{
programs.nvf = {
enable = true;
# your settings need to go into the settings attribute set
# Your settings need to go into the settings attribute set
# most settings are documented in the appendix
settings = {
vim.viAlias = false;
@ -87,3 +100,45 @@ installation sections of the manual. You may find all available options in the
[appendix](https://notashelf.github.io/nvf/options)
:::
## Without Flakes {#sec-nixos-flakeless}
As of v0.8, it is possible to install **nvf** on a system if you are not using
flakes. This is possible thanks to the flake-compat project.
To get started, you must fetch the repository using `builtins.fetchTarball` or a
similar mechanism.
```nix
# configuration.nix
let
nvf = import (builtins.fetchTarball {
url = "https://github.com/notashelf/nvf/archive/<commit or tag>.tar.gz";
# Optionally, you can add 'sha256' for verification and caching
# sha256 = "<sha256>";
});
in {
imports = [
# Import the NixOS module from your fetched input
nvf.nixosModules.nvf
];
# Once the module is imported, you may use `programs.nvf` as exposed by the
# NixOS module.
programs.nvf.enable = true;
}
```
[npins]: https://github.com/andir/npins
[niv]: https://github.com/nmattia/niv
::: {.tip}
Nix2 does not have a builtin lockfile mechanism like flakes. As such you must
manually update the URL and hash for your input. This is annoying to deal with,
and most users choose to defer this task to projects such as [npins] or [niv].
If you are new to NixOS, I encourage you to look into Flakes and see if they fit
your use case. Alternatively, look into the aforementioned projects for more
convenient dependency management mechanisms.
:::

View file

@ -5,19 +5,20 @@ installing it to your machine. Below are the commands you may run to try out
different configurations provided by this flake. As of v0.5, two specialized
configurations are provided:
- **Nix** - Nix language server + simple utility plugins
- **Maximal** - Variable language servers + utility and decorative plugins
- **Nix** (`packages.nix`) - Nix language server + simple utility plugins
- **Maximal** (`packages.maximal`) - Variable language servers + utility and
decorative plugins
You may try out any of the provided configurations using the `nix run` command
on a system where Nix is installed.
```bash
```sh
$ cachix use nvf # Optional: it'll save you CPU resources and time
$ nix run github:notashelf/nvf#nix # will run the default minimal configuration
$ nix run github:notashelf/nvf#nix # Will run the default minimal configuration
```
Do keep in mind that this is **susceptible to garbage collection** meaning it
will be removed from your Nix store once you garbage collect.
Do keep in mind that this is **susceptible to garbage collection** meaning that
the built outputs will be removed from your Nix store once you garbage collect.
## Using Prebuilt Configs {#sec-using-prebuilt-configs}
@ -65,6 +66,7 @@ companion or fun plugins.
::: {.warning}
Running the maximal config will download _a lot_ of packages as it is
downloading language servers, formatters, and more.
downloading language servers, formatters, and more. If CPU time and bandwidth
are concerns, please use the default package instead.
:::

17
flake.lock generated
View file

@ -1,5 +1,21 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1751685974,
"narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=",
"ref": "refs/heads/main",
"rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1",
"revCount": 92,
"type": "git",
"url": "https://git.lix.systems/lix-project/flake-compat.git"
},
"original": {
"type": "git",
"url": "https://git.lix.systems/lix-project/flake-compat.git"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@ -73,6 +89,7 @@
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"flake-utils": "flake-utils",
"mnw": "mnw",

View file

@ -5,8 +5,9 @@
self,
...
} @ inputs: let
# call the extended library with `inputs`
# inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function
# Call the extended library with `inputs`.
# inputs is used to get the original standard library, and to pass inputs
# to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix {inherit inputs self;};
in
flake-parts.lib.mkFlake {
@ -29,6 +30,8 @@
inherit (lib.nvim) neovimConfiguration;
};
inherit (lib.importJSON ./npins/sources.json) pins;
homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;};
default = self.homeManagerModules.nvf;
@ -50,21 +53,33 @@
''
self.nixosModules.nvf;
};
inherit (lib.importJSON ./npins/sources.json) pins;
};
perSystem = {pkgs, ...}: {
# Provide the default formatter. `nix fmt` in project root
# will format available files with the correct formatter.
# P.S: Please do not format with nixfmt! It messes with many
# syntax elements and results in unreadable code.
formatter = pkgs.alejandra;
# Provides the default formatter for 'nix fmt', which will format the
# entire tree with Alejandra. The wrapper script is necessary due to
# changes to the behaviour of Nix, which now encourages wrappers for
# tree-wide formatting.
formatter = pkgs.writeShellApplication {
name = "nix3-fmt-wrapper";
# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
runtimeInputs = [
pkgs.alejandra
pkgs.fd
];
text = ''
# Find Nix files in the tree and format them with Alejandra
fd "$@" -t f -e nix -x alejandra -q '{}'
'';
};
# Provides checks to be built an ran on 'nix flake check'. They can also
# be built individually with 'nix build' as described below.
checks = {
# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} ''
alejandra --check ${self} < /dev/null | tee $out
'';
@ -72,8 +87,9 @@
};
};
# Flake inputs
inputs = {
systems.url = "github:nix-systems/default";
## Basic Inputs
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
@ -87,7 +103,10 @@
inputs.systems.follows = "systems";
};
systems.url = "github:nix-systems/default";
flake-compat = {
url = "git+https://git.lix.systems/lix-project/flake-compat.git";
flake = false;
};
# Alternate neovim-wrapper
mnw.url = "github:Gerg-L/mnw";

7
shell.nix Normal file
View file

@ -0,0 +1,7 @@
# Make the behaviour of `nix-shell` consistent with the one of `nix develop`
# by returning the default devShell output from the flake. This is useful when
# I do not want to work with direnv, or simply need backwards compatibility.
{system ? builtins.currentSystem}: let
nvf = import ./.;
in
nvf.devShells.${system}.default