mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-20 13:59:22 +00:00
flake: remove flake-parts and nix-systems from flake
This commit is contained in:
parent
cd45295f9c
commit
3bc7761c1c
7 changed files with 270 additions and 313 deletions
|
|
@ -1,11 +0,0 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.meta) getExe;
|
||||
in {
|
||||
perSystem = {config, ...}: {
|
||||
apps = {
|
||||
nix.program = getExe config.packages.nix;
|
||||
maximal.program = getExe config.packages.maximal;
|
||||
default = config.apps.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
{lib, ...}: {
|
||||
perSystem = {pkgs, ...}: {
|
||||
# The default dev shell provides packages required to interact with
|
||||
# the codebase as described by the contributing guidelines. It includes the
|
||||
# formatters required, and a few additional goodies for linting work.
|
||||
devShells = {
|
||||
default = pkgs.mkShellNoCC {
|
||||
packages = with pkgs; [
|
||||
# Nix tooling
|
||||
nil # LSP
|
||||
statix # static checker
|
||||
deadnix # dead code finder
|
||||
|
||||
# So that we can interact with plugin sources
|
||||
npins
|
||||
|
||||
# Formatters
|
||||
alejandra
|
||||
deno
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# This package exists to make development easier by providing the place and
|
||||
# boilerplate to build a test nvf configuration. Feel free to use this for
|
||||
# testing, but make sure to discard the changes before creating a pull
|
||||
# request.
|
||||
packages.dev = let
|
||||
configuration = {
|
||||
# This is essentially the configuration that will be passed to the
|
||||
# builder function. For example:
|
||||
# vim.languages.nix.enable = true;
|
||||
};
|
||||
|
||||
customNeovim = lib.nvim.neovimConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [configuration];
|
||||
};
|
||||
in
|
||||
customNeovim.neovim;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,127 +1,122 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
self,
|
||||
system,
|
||||
...
|
||||
} @ args: {
|
||||
perSystem = {
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.customisation) makeScope;
|
||||
inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs;
|
||||
inherit (lib.strings) concatStringsSep;
|
||||
inherit (lib.filesystem) packagesFromDirectoryRecursive;
|
||||
}: let
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
|
||||
# Entrypoint for nvf documentation and relevant packages.
|
||||
docs = import ../docs {inherit pkgs inputs lib;};
|
||||
inherit (lib.customisation) makeScope;
|
||||
inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs;
|
||||
inherit (lib.strings) concatStringsSep;
|
||||
inherit (lib.filesystem) packagesFromDirectoryRecursive;
|
||||
|
||||
# Helper function for creating demo configurations for nvf
|
||||
# TODO: make this more generic.
|
||||
buildPkg = maximal:
|
||||
(args.config.flake.lib.nvim.neovimConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [(import ../configuration.nix maximal)];
|
||||
}).neovim;
|
||||
# Entrypoint for nvf documentation and relevant packages.
|
||||
docs = import ../docs {inherit pkgs inputs lib;};
|
||||
|
||||
# This constructs a by-name overlay similar to the one found in Nixpkgs.
|
||||
# The goal is to automatically discover and packages found in pkgs/by-name
|
||||
# as long as they have a 'package.nix' in the package directory. We also
|
||||
# pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore
|
||||
# they are always available in the relevant 'package.nix' files.
|
||||
# ---
|
||||
# The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available
|
||||
# under the MIT license.
|
||||
flattenPkgs = separator: path: value:
|
||||
if isDerivation value
|
||||
then {
|
||||
${concatStringsSep separator path} = value;
|
||||
}
|
||||
else if isAttrs value
|
||||
then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value
|
||||
else
|
||||
# Ignore the functions which makeScope returns
|
||||
{};
|
||||
# Helper function for creating demo configurations for nvf
|
||||
# TODO: make this more generic.
|
||||
buildPkg = maximal:
|
||||
(lib.nvim.neovimConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [(import ../configuration.nix maximal)];
|
||||
}).neovim;
|
||||
|
||||
inputsScope = makeScope pkgs.newScope (_: {
|
||||
inherit inputs;
|
||||
inherit (self) pins;
|
||||
});
|
||||
# This constructs a by-name overlay similar to the one found in Nixpkgs.
|
||||
# The goal is to automatically discover and packages found in pkgs/by-name
|
||||
# as long as they have a 'package.nix' in the package directory. We also
|
||||
# pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore
|
||||
# they are always available in the relevant 'package.nix' files.
|
||||
# ---
|
||||
# The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available
|
||||
# under the MIT license.
|
||||
flattenPkgs = separator: path: value:
|
||||
if isDerivation value
|
||||
then {
|
||||
${concatStringsSep separator path} = value;
|
||||
}
|
||||
else if isAttrs value
|
||||
then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value
|
||||
else
|
||||
# Ignore the functions which makeScope returns
|
||||
{};
|
||||
|
||||
scopeFromDirectory = directory:
|
||||
packagesFromDirectoryRecursive {
|
||||
inherit directory;
|
||||
inherit (inputsScope) newScope callPackage;
|
||||
inputsScope = makeScope pkgs.newScope (_: {
|
||||
inherit inputs;
|
||||
inherit (self) pins;
|
||||
});
|
||||
|
||||
scopeFromDirectory = directory:
|
||||
packagesFromDirectoryRecursive {
|
||||
inherit directory;
|
||||
inherit (inputsScope) newScope callPackage;
|
||||
};
|
||||
|
||||
legacyPackages = scopeFromDirectory ./pkgs/by-name;
|
||||
in
|
||||
(flattenPkgs "/" [] legacyPackages)
|
||||
// {
|
||||
inherit (docs.manual) htmlOpenTool;
|
||||
|
||||
# Documentation
|
||||
docs = docs.manual.html;
|
||||
docs-html = docs.manual.html;
|
||||
docs-manpages = docs.manPages;
|
||||
docs-json = docs.options.json;
|
||||
docs-linkcheck = let
|
||||
site = self.packages.${system}.docs;
|
||||
in
|
||||
pkgs.testers.lycheeLinkCheck {
|
||||
inherit site;
|
||||
|
||||
remap = {
|
||||
"https://notashelf.github.io/nvf/" = "${site}/share/doc/";
|
||||
"https://nvf.notashelf.dev/" = "${site}/share/doc/";
|
||||
};
|
||||
|
||||
extraConfig = {
|
||||
exclude = [
|
||||
# This is not an email, but just part of an SCM query inside a nix code block.
|
||||
# The leading escaped non breaking space is there on purpose.
|
||||
"%C2%A0@injection.content"
|
||||
];
|
||||
include_mail = true;
|
||||
include_verbatim = true;
|
||||
};
|
||||
};
|
||||
|
||||
legacyPackages = scopeFromDirectory ./pkgs/by-name;
|
||||
in {
|
||||
packages =
|
||||
(flattenPkgs "/" [] legacyPackages)
|
||||
// {
|
||||
inherit (docs.manual) htmlOpenTool;
|
||||
# Helper utility for building the HTML manual and opening it in the
|
||||
# browser with $BROWSER or using xdg-open as a fallback tool.
|
||||
# Adapted from Home-Manager, available under the MIT license.
|
||||
docs-html-wrapped = let
|
||||
xdg-open = lib.getExe' pkgs.xdg-utils "xdg-open";
|
||||
docs-html = docs.manual.html + /share/doc/nvf;
|
||||
in
|
||||
pkgs.writeShellScriptBin "docs-html-wrapped" ''
|
||||
set -euo pipefail
|
||||
|
||||
# Documentation
|
||||
docs = docs.manual.html;
|
||||
docs-html = docs.manual.html;
|
||||
docs-manpages = docs.manPages;
|
||||
docs-json = docs.options.json;
|
||||
docs-linkcheck = let
|
||||
site = config.packages.docs;
|
||||
in
|
||||
pkgs.testers.lycheeLinkCheck {
|
||||
inherit site;
|
||||
|
||||
remap = {
|
||||
"https://notashelf.github.io/nvf/" = "${site}/share/doc/";
|
||||
"https://nvf.notashelf.dev/" = "${site}/share/doc/";
|
||||
};
|
||||
|
||||
extraConfig = {
|
||||
exclude = [
|
||||
# This is not an email, but just part of an SCM query inside a nix code block.
|
||||
# The leading escaped non breaking space is there on purpose.
|
||||
"%C2%A0@injection.content"
|
||||
];
|
||||
include_mail = true;
|
||||
include_verbatim = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Helper utility for building the HTML manual and opening it in the
|
||||
# browser with $BROWSER or using xdg-open as a fallback tool.
|
||||
# Adapted from Home-Manager, available under the MIT license.
|
||||
docs-html-wrapped = let
|
||||
xdg-open = lib.getExe' pkgs.xdg-utils "xdg-open";
|
||||
docs-html = docs.manual.html + /share/doc/nvf;
|
||||
in
|
||||
pkgs.writeShellScriptBin "docs-html-wrapped" ''
|
||||
set -euo pipefail
|
||||
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
for candidate in xdg-open open w3m; do
|
||||
BROWSER="$(type -P $candidate || true)"
|
||||
if [[ -x $BROWSER ]]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
for candidate in xdg-open open w3m; do
|
||||
BROWSER="$(type -P $candidate || true)"
|
||||
if [[ -x $BROWSER ]]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
echo "$0: unable to start a web browser; please set \$BROWSER"
|
||||
echo "$0: Trying xdg-open as a fallback"
|
||||
${xdg-open} ${docs-html}/index.xhtml
|
||||
else
|
||||
echo "\$BROWSER is set. Attempting to open manual"
|
||||
exec "$BROWSER" "${docs-html}/index.xhtml"
|
||||
fi
|
||||
'';
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
echo "$0: unable to start a web browser; please set \$BROWSER"
|
||||
echo "$0: Trying xdg-open as a fallback"
|
||||
${xdg-open} ${docs-html}/index.xhtml
|
||||
else
|
||||
echo "\$BROWSER is set. Attempting to open manual"
|
||||
exec "$BROWSER" "${docs-html}/index.xhtml"
|
||||
fi
|
||||
'';
|
||||
|
||||
# Exposed neovim configurations
|
||||
nix = buildPkg false;
|
||||
maximal = buildPkg true;
|
||||
default = config.packages.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
# Exposed neovim configurations
|
||||
nix = buildPkg false;
|
||||
maximal = buildPkg true;
|
||||
default = self.packages.${system}.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
{
|
||||
flake.templates = {
|
||||
standalone = {
|
||||
path = ./standalone;
|
||||
description = "Standalone flake template for nvf";
|
||||
welcomeText = ''
|
||||
Template flake.nix has been created in flake.nix!
|
||||
standalone = {
|
||||
path = ./standalone;
|
||||
description = "Standalone flake template for nvf";
|
||||
welcomeText = ''
|
||||
Template flake.nix has been created in flake.nix!
|
||||
|
||||
Note that this is a very basic example to bootstrap nvf for you. Please edit your
|
||||
configuration as described in the nvf manual before using this template. The
|
||||
configured packages will be ran with 'nix run .' or 'nix run .#neovimConfigured'
|
||||
Note that this is a very basic example to bootstrap nvf for you. Please edit your
|
||||
configuration as described in the nvf manual before using this template. The
|
||||
configured packages will be ran with 'nix run .' or 'nix run .#neovimConfigured'
|
||||
|
||||
Happy editing!
|
||||
'';
|
||||
};
|
||||
Happy editing!
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue