treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -1,4 +1,5 @@
{inputs, ...}: {
{ inputs, ... }:
{
imports = [
./dev
./helpers.nix
@ -12,16 +13,14 @@
./wrappers.nix
];
perSystem = {
pkgs,
system,
...
}: {
_module.args = {
pkgsUnfree = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
perSystem =
{ pkgs, system, ... }:
{
_module.args = {
pkgsUnfree = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
};
};
};
}

View file

@ -1,22 +1,27 @@
{ inputs, ... }: {
imports = [ inputs.pre-commit-hooks.flakeModule ./devshell.nix ];
{ inputs, ... }:
{
imports = [
inputs.pre-commit-hooks.flakeModule
./devshell.nix
];
perSystem = { pkgs, ... }: {
formatter = pkgs.nixfmt-rfc-style;
perSystem =
{ pkgs, ... }:
{
formatter = pkgs.nixfmt-rfc-style;
pre-commit = {
settings.hooks = {
nixfmt = {
package = pkgs.nixfmt-rfc-style;
enable = true;
pre-commit = {
settings.hooks = {
nixfmt = {
package = pkgs.nixfmt-rfc-style;
enable = true;
};
statix = {
enable = true;
excludes = [ "plugins/lsp/language-servers/rust-analyzer-config.nix" ];
};
typos.enable = true;
};
statix = {
enable = true;
excludes =
[ "plugins/lsp/language-servers/rust-analyzer-config.nix" ];
};
typos.enable = true;
};
};
};
}

View file

@ -1,66 +1,69 @@
{inputs, ...}: {
imports = [
inputs.devshell.flakeModule
];
{ inputs, ... }:
{
imports = [ inputs.devshell.flakeModule ];
perSystem = {
pkgs,
config,
system,
...
}: {
devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
perSystem =
{
pkgs,
config,
system,
...
}:
{
devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
commands = let
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)";
in [
{
name = "checks";
help = "Run all nixvim checks";
command = "nix flake check";
}
{
name = "tests";
help = "Run nixvim tests";
command = ''
echo "=> Running nixvim tests for the '${system}' architecture..."
commands =
let
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)";
in
[
{
name = "checks";
help = "Run all nixvim checks";
command = "nix flake check";
}
{
name = "tests";
help = "Run nixvim tests";
command = ''
echo "=> Running nixvim tests for the '${system}' architecture..."
${nix} build .#checks.${system}.tests "$@"
'';
}
{
name = "format";
help = "Format the entire codebase";
command = "nix fmt";
}
{
name = "docs";
help = "Build nixvim documentation";
command = ''
echo "=> Building nixvim documentation..."
${nix} build .#checks.${system}.tests "$@"
'';
}
{
name = "format";
help = "Format the entire codebase";
command = "nix fmt";
}
{
name = "docs";
help = "Build nixvim documentation";
command = ''
echo "=> Building nixvim documentation..."
${nix} build .#docs "$@"
'';
}
{
name = "serve-docs";
help = "Build and serve documentation locally";
command = ''
echo -e "=> Building nixvim documentation...\n"
${nix} build .#docs "$@"
'';
}
{
name = "serve-docs";
help = "Build and serve documentation locally";
command = ''
echo -e "=> Building nixvim documentation...\n"
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
echo -e "\n=> Documentation successfully built ('$doc_derivation')"
port=8000
echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n"
port=8000
echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n"
${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc
'';
}
];
${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc
'';
}
];
};
};
};
}

View file

@ -1,15 +1,15 @@
{getHelpers, ...}: {
_module.args.getHelpers = pkgs: _nixvimTests:
{ getHelpers, ... }:
{
_module.args.getHelpers =
pkgs: _nixvimTests:
import ../lib/helpers.nix {
inherit pkgs _nixvimTests;
inherit (pkgs) lib;
};
perSystem = {
pkgs,
config,
...
}: {
_module.args.helpers = getHelpers pkgs false;
};
perSystem =
{ pkgs, config, ... }:
{
_module.args.helpers = getHelpers pkgs false;
};
}

View file

@ -1,18 +1,21 @@
{
perSystem = {
pkgs,
config,
makeNixvimWithModule,
...
}: {
legacyPackages = rec {
inherit makeNixvimWithModule;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
perSystem =
{
pkgs,
config,
makeNixvimWithModule,
...
}:
{
legacyPackages = rec {
inherit makeNixvimWithModule;
makeNixvim =
configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
};
};
};
};
}

View file

@ -3,18 +3,15 @@
lib,
withSystem,
...
}: {
}:
{
flake.lib = lib.genAttrs config.systems (
lib.flip withSystem (
{
pkgs,
config,
...
}:
import ../lib {
inherit pkgs lib;
inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
}
{ pkgs, config, ... }:
import ../lib {
inherit pkgs lib;
inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
}
)
);
}

View file

@ -1,37 +1,41 @@
{modules, ...}: {
{ modules, ... }:
{
_module.args = {
modules = pkgs: let
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix";
modules =
pkgs:
let
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix";
nixvimExtraArgsModule = rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = pkgs.lib.mkForce pkgs;
inherit (pkgs) lib;
nixvimExtraArgsModule = rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = pkgs.lib.mkForce pkgs;
inherit (pkgs) lib;
};
};
};
};
in [
../modules
nixpkgsMaintainersList
nixvimExtraArgsModule
({lib, ...}:
with lib; {
# Attribute may contain the following fields:
# - name: Name of the module
# - kind: Either colorschemes or plugins
# - description: A short description of the plugin
# - url: Url for the plugin
#
# [kind name] will identify the plugin
#
# We need to use an attrs instead of a submodule to handle the merge.
options.meta.nixvimInfo = mkOption {
type =
(types.nullOr types.attrs)
// {
in
[
../modules
nixpkgsMaintainersList
nixvimExtraArgsModule
(
{ lib, ... }:
with lib;
{
# Attribute may contain the following fields:
# - name: Name of the module
# - kind: Either colorschemes or plugins
# - description: A short description of the plugin
# - url: Url for the plugin
#
# [kind name] will identify the plugin
#
# We need to use an attrs instead of a submodule to handle the merge.
options.meta.nixvimInfo = mkOption {
type = (types.nullOr types.attrs) // {
# This will create an attrset of the form:
# {
# "path"."to"."plugin" = { "<name>" = <info>; };
@ -43,37 +47,41 @@
# description = null or "<DESCRIPTION>";
# url = null or "<URL>";
# }
merge = _: defs:
lib.foldl' (acc: def:
lib.recursiveUpdate acc {
"${def.value.kind}"."${def.value.name}" = {
inherit (def.value) url description;
inherit (def) file;
};
}) {
plugins = {};
colorschemes = {};
}
defs;
merge =
_: defs:
lib.foldl'
(
acc: def:
lib.recursiveUpdate acc {
"${def.value.kind}"."${def.value.name}" = {
inherit (def.value) url description;
inherit (def) file;
};
}
)
{
plugins = { };
colorschemes = { };
}
defs;
};
internal = true;
default = null;
description = ''
Nixvim related information on the module
'';
};
})
];
internal = true;
default = null;
description = ''
Nixvim related information on the module
'';
};
}
)
];
};
perSystem = {
pkgs,
config,
...
}: {
_module.args = {
modules = modules pkgs;
rawModules = modules;
perSystem =
{ pkgs, config, ... }:
{
_module.args = {
modules = modules pkgs;
rawModules = modules;
};
};
};
}

View file

@ -1,21 +1,18 @@
{inputs, ...}: {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
];
perSystem = {
config,
pkgs,
final,
...
}: {
overlayAttrs = {
nixvim = {
inherit
(config.legacyPackages)
makeNixvim
makeNixvimWithModule
;
{ inputs, ... }:
{
imports = [ inputs.flake-parts.flakeModules.easyOverlay ];
perSystem =
{
config,
pkgs,
final,
...
}:
{
overlayAttrs = {
nixvim = {
inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
};
};
};
};
}

View file

@ -1,16 +1,16 @@
{
perSystem = {
pkgs,
config,
rawModules,
helpers,
...
}: {
packages = import ../docs {
inherit rawModules pkgs helpers;
};
perSystem =
{
pkgs,
config,
rawModules,
helpers,
...
}:
{
packages = import ../docs { inherit rawModules pkgs helpers; };
# Test that all packages build fine when running `nix flake check`.
checks = config.packages;
};
# Test that all packages build fine when running `nix flake check`.
checks = config.packages;
};
}

View file

@ -1,8 +1,5 @@
{ self, inputs, ... }:
{
self,
inputs,
...
}: {
flake.templates = {
default = {
path = ../templates/simple;
@ -12,49 +9,48 @@
# The following adds the template flake's checks to the main (current) flake's checks.
# It ensures that the template's own checks are successful.
perSystem = {
pkgs,
system,
lib,
...
}: {
checks = let
# Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46
# s/flake.outputs/args.outputs/
callFlake = args @ {
inputs,
outputs,
sourceInfo,
}: let
outputs = args.outputs (inputs // {self = result;});
result =
outputs
// sourceInfo
// {
inherit inputs outputs sourceInfo;
_type = "flake";
perSystem =
{
pkgs,
system,
lib,
...
}:
{
checks =
let
# Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46
# s/flake.outputs/args.outputs/
callFlake =
args@{
inputs,
outputs,
sourceInfo,
}:
let
outputs = args.outputs (inputs // { self = result; });
result =
outputs
// sourceInfo
// {
inherit inputs outputs sourceInfo;
_type = "flake";
};
in
result;
templateFlakeOutputs = callFlake {
inputs = {
inherit (inputs) flake-parts nixpkgs;
nixvim = self;
};
# Import and read the `outputs` field of the template flake.
inherit (import ../templates/simple/flake.nix) outputs;
sourceInfo = { };
};
in
result;
templateFlakeOutputs = callFlake {
inputs = {
inherit (inputs) flake-parts nixpkgs;
nixvim = self;
};
# Import and read the `outputs` field of the template flake.
inherit (import ../templates/simple/flake.nix) outputs;
sourceInfo = {};
};
templateChecks = templateFlakeOutputs.checks.${system};
in
lib.concatMapAttrs
(
checkName: check: {
"template-${checkName}" = check;
}
)
templateChecks;
};
templateChecks = templateFlakeOutputs.checks.${system};
in
lib.concatMapAttrs (checkName: check: { "template-${checkName}" = check; }) templateChecks;
};
}

View file

@ -1,49 +1,51 @@
{self, ...}: {
perSystem = {
pkgs,
config,
system,
helpers,
makeNixvimWithModuleUnfree,
makeNixvimWithModule,
...
}: {
checks = {
tests = import ../tests {
inherit pkgs helpers makeNixvimWithModule;
inherit (pkgs) lib;
makeNixvim = configuration:
makeNixvimWithModuleUnfree {
module = {
config = configuration;
{ self, ... }:
{
perSystem =
{
pkgs,
config,
system,
helpers,
makeNixvimWithModuleUnfree,
makeNixvimWithModule,
...
}:
{
checks = {
tests = import ../tests {
inherit pkgs helpers makeNixvimWithModule;
inherit (pkgs) lib;
makeNixvim =
configuration:
makeNixvimWithModuleUnfree {
module = {
config = configuration;
};
};
};
};
};
extra-args-tests = import ../tests/extra-args.nix {
inherit pkgs;
inherit makeNixvimWithModule;
};
extra-args-tests = import ../tests/extra-args.nix {
inherit pkgs;
inherit makeNixvimWithModule;
};
extend = import ../tests/extend.nix {
inherit pkgs makeNixvimWithModule;
};
extend = import ../tests/extend.nix { inherit pkgs makeNixvimWithModule; };
enable-except-in-tests = import ../tests/enable-except-in-tests.nix {
inherit pkgs makeNixvimWithModule;
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
};
enable-except-in-tests = import ../tests/enable-except-in-tests.nix {
inherit pkgs makeNixvimWithModule;
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
};
no-flake = import ../tests/no-flake.nix {
inherit system;
inherit (self.lib.${system}.check) mkTestDerivationFromNvim;
nixvim = "${self}";
};
no-flake = import ../tests/no-flake.nix {
inherit system;
inherit (self.lib.${system}.check) mkTestDerivationFromNvim;
nixvim = "${self}";
};
lib-tests = import ../tests/lib-tests.nix {
inherit pkgs helpers;
inherit (pkgs) lib;
lib-tests = import ../tests/lib-tests.nix {
inherit pkgs helpers;
inherit (pkgs) lib;
};
};
};
};
}

View file

@ -4,64 +4,56 @@
getHelpers,
self,
...
}: let
}:
let
wrapperArgs = {
inherit modules;
inherit self;
inherit getHelpers;
};
in {
perSystem = {
system,
pkgs,
pkgsUnfree,
config,
...
}: {
_module.args = {
makeNixvimWithModule =
import ../wrappers/standalone.nix
pkgs
wrapperArgs;
in
{
perSystem =
{
system,
pkgs,
pkgsUnfree,
config,
...
}:
{
_module.args = {
makeNixvimWithModule = import ../wrappers/standalone.nix pkgs wrapperArgs;
makeNixvimWithModuleUnfree =
import ../wrappers/standalone.nix
pkgsUnfree
wrapperArgs;
};
checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
})
.activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
})
.config
.system
.build
.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
})
.system;
makeNixvimWithModuleUnfree = import ../wrappers/standalone.nix pkgsUnfree wrapperArgs;
};
};
checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
}).activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
}).config.system.build.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
}).system;
};
};
flake = {
nixosModules.nixvim = import ../wrappers/nixos.nix wrapperArgs;