Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: switch back to alejandra formatting #1629

Closed
wants to merge 4 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Git revisions added to this file will be ignored by GitHub's blame feature.
#
# This can also be used locally with `git blame` by configuring your "blame.ignoreRevsFile":
# git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# Or you can this on an ad-hock basis with the `--ignore-revs-file` argument:
# git blame --ignore-revs-file .git-blame-ignore-revs

# This commit reformatted from alejandra to nixfmt-rfc-style:
# 2024-05-05: treewide: Reformat with nixfmt
62f32bfc711f0a3c8a52af4c0790345b4b3d2346

# This commit reverted the formatting back to alejandra ~1 month later:
# 2024-06-04: treewide: reformat with alejandra
e9cab7f8e8ae3be7c952c109b37d34dd354d637e

13 changes: 7 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url =
lock.nodes.flake-compat.locked.url
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
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) {src = ./.;})
.defaultNix
138 changes: 72 additions & 66 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
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;
};
(pkgs.applyPatches {
name = "nixpkgs-nixvim-doc";
src = pkgs.path;
patches = [./either_recursive.patch];
})
{
inherit (pkgs) system;
config.allowUnfree = true;
};

inherit (pkgsDoc) lib;

Expand All @@ -25,21 +24,22 @@ let
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 @@ -49,51 +49,57 @@ let
# 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);
})
]
++ (rawModules pkgsDoc);

hmOptions = builtins.removeAttrs (lib.evalModules {
modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
}).options [ "_module" ];
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
;
rec {
options-json =
(pkgsDoc.nixosOptionsDoc {
inherit
(lib.evalModules {
modules = topLevelModules;
specialArgs.helpers = helpers;
})
options
;
inherit transformOptions;
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;
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;
};
}
modules = topLevelModules;
inherit helpers hmOptions;
};
}
42 changes: 20 additions & 22 deletions docs/man/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
installShellFiles,
nixos-render-docs,
pandoc,
}:
let
}: let
manualFilter = ''
local text = pandoc.text

Expand All @@ -24,28 +23,27 @@ let
end
'';

manHeader =
let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in
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} \
${mkMDSection ../user-guide/config-examples.md} \
${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
{
nativeBuildInputs = [pandoc];
inherit manualFilter;
}
''
mkdir -p $out
cat \
${./nixvim-header-start.5} \
${mkMDSection ../user-guide/helpers.md} \
${mkMDSection ../user-guide/faq.md} \
${mkMDSection ../user-guide/config-examples.md} \
${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
in
# FIXME add platform specific docs to manpage
runCommand "nixvim-configuration-reference-manpage"
# FIXME add platform specific docs to manpage
runCommand "nixvim-configuration-reference-manpage"
{
nativeBuildInputs = [
installShellFiles
Expand Down
Loading