Skip to content

Commit

Permalink
treewide: Reformat with nixfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
traxys committed May 5, 2024
1 parent c628126 commit 62f32bf
Show file tree
Hide file tree
Showing 459 changed files with 28,030 additions and 26,268 deletions.
25 changes: 11 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{src = ./.;}
)
.defaultNix
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url =
lock.nodes.flake-compat.locked.url
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix
141 changes: 66 additions & 75 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
rawModules,
helpers,
pkgs,
}: let
}:
let
pkgsDoc =
import (pkgs.applyPatches {
name = "nixpkgs-nixvim-doc";
src = pkgs.path;
patches = [
./either_recursive.patch
];
}) {
inherit (pkgs) system;
config.allowUnfree = true;
};
import
(pkgs.applyPatches {
name = "nixpkgs-nixvim-doc";
src = pkgs.path;
patches = [ ./either_recursive.patch ];
})
{
inherit (pkgs) system;
config.allowUnfree = true;
};

inherit (pkgsDoc) lib;

Expand All @@ -24,21 +25,21 @@
name = "<${repo}/${subpath}>";
};

transformOptions = opt:
transformOptions =
opt:
opt
// {
declarations =
map (
decl:
if lib.hasPrefix nixvimPath (toString decl)
then
gitHubDeclaration "nix-community" "nixvim" "main"
(lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl)))
else if decl == "lib/modules.nix"
then gitHubDeclaration "NixOS" "nixpkgs" "master" decl
else decl
)
opt.declarations;
declarations = map (
decl:
if lib.hasPrefix nixvimPath (toString decl) then
gitHubDeclaration "nix-community" "nixvim" "main" (
lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl))
)
else if decl == "lib/modules.nix" then
gitHubDeclaration "NixOS" "nixpkgs" "master" decl
else
decl
) opt.declarations;
};

nixvmConfigType = lib.mkOptionType {
Expand All @@ -48,61 +49,51 @@
# Evaluation is irrelevant, only used for documentation.
};

topLevelModules =
[
../wrappers/modules/output.nix
# Fake module to avoid a duplicated documentation
(lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" {
options.files = lib.mkOption {
type = lib.types.attrsOf nixvmConfigType;
description = "Extra files to add to the runtimepath";
example = {
"ftplugin/nix.lua" = {
options = {
tabstop = 2;
shiftwidth = 2;
expandtab = true;
};
topLevelModules = [
../wrappers/modules/output.nix
# Fake module to avoid a duplicated documentation
(lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" {
options.files = lib.mkOption {
type = lib.types.attrsOf nixvmConfigType;
description = "Extra files to add to the runtimepath";
example = {
"ftplugin/nix.lua" = {
options = {
tabstop = 2;
shiftwidth = 2;
expandtab = true;
};
};
};
})
]
++ (rawModules pkgsDoc);

hmOptions =
builtins.removeAttrs
(lib.evalModules {
modules = [
(import ../wrappers/modules/hm.nix {inherit lib;})
];
};
})
.options
["_module"];
] ++ (rawModules pkgsDoc);

hmOptions = builtins.removeAttrs (lib.evalModules {
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
}).options [ "_module" ];
in
rec {
options-json =
(pkgsDoc.nixosOptionsDoc
{
inherit
(lib.evalModules {
modules = topLevelModules;
specialArgs.helpers = helpers;
})
options
;
inherit transformOptions;
warningsAreErrors = false;
rec {
options-json =
(pkgsDoc.nixosOptionsDoc {
inherit
(lib.evalModules {
modules = topLevelModules;
specialArgs.helpers = helpers;
})
.optionsJSON;
man-docs = pkgsDoc.callPackage ./man {inherit options-json;};
}
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
docs = pkgsDoc.callPackage ./mdbook {
options
;
inherit transformOptions;
modules = topLevelModules;
inherit helpers hmOptions;
};
}
warningsAreErrors = false;
}).optionsJSON;
man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
}
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
docs = pkgsDoc.callPackage ./mdbook {
inherit transformOptions;
modules = topLevelModules;
inherit helpers hmOptions;
};
}
49 changes: 29 additions & 20 deletions docs/man/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
installShellFiles,
nixos-render-docs,
pandoc,
}: let
}:
let
manualFilter = ''
local text = pandoc.text
Expand All @@ -23,26 +24,34 @@
end
'';

manHeader = let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in
runCommand "nixvim-general-doc-manpage" {
nativeBuildInputs = [pandoc];
inherit manualFilter;
} ''
mkdir -p $out
cat \
${./nixvim-header-start.5} \
${mkMDSection ../user-guide/helpers.md} \
${mkMDSection ../user-guide/faq.md} \
${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
# FIXME add platform specific docs to manpage
manHeader =
let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in
runCommand "nixvim-general-doc-manpage"
{
nativeBuildInputs = [ pandoc ];
inherit manualFilter;
}
''
mkdir -p $out
cat \
${./nixvim-header-start.5} \
${mkMDSection ../user-guide/helpers.md} \
${mkMDSection ../user-guide/faq.md} \
${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
in
runCommand "nixvim-configuration-reference-manpage" {
nativeBuildInputs = [installShellFiles nixos-render-docs];
} ''
# FIXME add platform specific docs to manpage
runCommand "nixvim-configuration-reference-manpage"
{
nativeBuildInputs = [
installShellFiles
nixos-render-docs
];
}
''
# Generate man-pages
mkdir -p $out/share/man/man5
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
Expand Down
Loading

0 comments on commit 62f32bf

Please sign in to comment.