mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
parent
5df48c4255
commit
cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions
232
docs/default.nix
232
docs/default.nix
|
|
@ -1,9 +1,12 @@
|
|||
{ pkgs
|
||||
{
|
||||
pkgs,
|
||||
|
||||
# Note, this should be "the standard library" + HM extensions.
|
||||
, lib ? import ../modules/lib/stdlib-extended.nix pkgs.lib
|
||||
# Note, this should be "the standard library" + HM extensions.
|
||||
lib ? import ../modules/lib/stdlib-extended.nix pkgs.lib,
|
||||
|
||||
, release, isReleaseBranch }:
|
||||
release,
|
||||
isReleaseBranch,
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
|
|
@ -19,86 +22,124 @@ let
|
|||
# Caveat: even if the package is reached by a different means, the
|
||||
# path above will be shown and not e.g.
|
||||
# `${config.services.foo.package}`.
|
||||
scrubDerivations = prefixPath: attrs:
|
||||
scrubDerivations =
|
||||
prefixPath: attrs:
|
||||
let
|
||||
scrubDerivation = name: value:
|
||||
let pkgAttrName = prefixPath + "." + name;
|
||||
in if lib.isAttrs value then
|
||||
scrubDerivation =
|
||||
name: value:
|
||||
let
|
||||
pkgAttrName = prefixPath + "." + name;
|
||||
in
|
||||
if lib.isAttrs value then
|
||||
scrubDerivations pkgAttrName value
|
||||
// lib.optionalAttrs (lib.isDerivation value) {
|
||||
outPath = "\${${pkgAttrName}}";
|
||||
}
|
||||
else
|
||||
value;
|
||||
in lib.mapAttrs scrubDerivation attrs;
|
||||
in
|
||||
lib.mapAttrs scrubDerivation attrs;
|
||||
|
||||
# Make sure the used package is scrubbed to avoid actually
|
||||
# instantiating derivations.
|
||||
scrubbedPkgsModule = {
|
||||
imports = [{
|
||||
_module.args = {
|
||||
pkgs = lib.mkForce (scrubDerivations "pkgs" pkgs);
|
||||
pkgs_i686 = lib.mkForce { };
|
||||
};
|
||||
}];
|
||||
imports = [
|
||||
{
|
||||
_module.args = {
|
||||
pkgs = lib.mkForce (scrubDerivations "pkgs" pkgs);
|
||||
pkgs_i686 = lib.mkForce { };
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
dontCheckDefinitions = { _module.check = false; };
|
||||
dontCheckDefinitions = {
|
||||
_module.check = false;
|
||||
};
|
||||
|
||||
gitHubDeclaration = user: repo: subpath:
|
||||
let urlRef = if isReleaseBranch then "release-${release}" else "master";
|
||||
in {
|
||||
gitHubDeclaration =
|
||||
user: repo: subpath:
|
||||
let
|
||||
urlRef = if isReleaseBranch then "release-${release}" else "master";
|
||||
in
|
||||
{
|
||||
url = "https://github.com/${user}/${repo}/blob/${urlRef}/${subpath}";
|
||||
name = "<${repo}/${subpath}>";
|
||||
};
|
||||
|
||||
hmPath = toString ./..;
|
||||
|
||||
buildOptionsDocs = args@{ modules, includeModuleSystemOptions ? true, ... }:
|
||||
buildOptionsDocs =
|
||||
args@{
|
||||
modules,
|
||||
includeModuleSystemOptions ? true,
|
||||
...
|
||||
}:
|
||||
let
|
||||
options = (lib.evalModules {
|
||||
inherit modules;
|
||||
class = "homeManager";
|
||||
}).options;
|
||||
in pkgs.buildPackages.nixosOptionsDoc ({
|
||||
options = if includeModuleSystemOptions then
|
||||
options
|
||||
else
|
||||
builtins.removeAttrs options [ "_module" ];
|
||||
transformOptions = opt:
|
||||
opt // {
|
||||
# Clean up declaration sites to not refer to the Home Manager
|
||||
# source tree.
|
||||
declarations = map (decl:
|
||||
if lib.hasPrefix hmPath (toString decl) then
|
||||
gitHubDeclaration "nix-community" "home-manager"
|
||||
(lib.removePrefix "/" (lib.removePrefix hmPath (toString decl)))
|
||||
else if decl == "lib/modules.nix" then
|
||||
# TODO: handle this in a better way (may require upstream
|
||||
# changes to nixpkgs)
|
||||
gitHubDeclaration "NixOS" "nixpkgs" decl
|
||||
else
|
||||
decl) opt.declarations;
|
||||
};
|
||||
} // builtins.removeAttrs args [ "modules" "includeModuleSystemOptions" ]);
|
||||
options =
|
||||
(lib.evalModules {
|
||||
inherit modules;
|
||||
class = "homeManager";
|
||||
}).options;
|
||||
in
|
||||
pkgs.buildPackages.nixosOptionsDoc (
|
||||
{
|
||||
options =
|
||||
if includeModuleSystemOptions then options else builtins.removeAttrs options [ "_module" ];
|
||||
transformOptions =
|
||||
opt:
|
||||
opt
|
||||
// {
|
||||
# Clean up declaration sites to not refer to the Home Manager
|
||||
# source tree.
|
||||
declarations = map (
|
||||
decl:
|
||||
if lib.hasPrefix hmPath (toString decl) then
|
||||
gitHubDeclaration "nix-community" "home-manager" (
|
||||
lib.removePrefix "/" (lib.removePrefix hmPath (toString decl))
|
||||
)
|
||||
else if decl == "lib/modules.nix" then
|
||||
# TODO: handle this in a better way (may require upstream
|
||||
# changes to nixpkgs)
|
||||
gitHubDeclaration "NixOS" "nixpkgs" decl
|
||||
else
|
||||
decl
|
||||
) opt.declarations;
|
||||
};
|
||||
}
|
||||
// builtins.removeAttrs args [
|
||||
"modules"
|
||||
"includeModuleSystemOptions"
|
||||
]
|
||||
);
|
||||
|
||||
hmOptionsDocs = buildOptionsDocs {
|
||||
modules = import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
check = false;
|
||||
} ++ [ scrubbedPkgsModule ];
|
||||
modules =
|
||||
import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
check = false;
|
||||
}
|
||||
++ [ scrubbedPkgsModule ];
|
||||
variablelistId = "home-manager-options";
|
||||
};
|
||||
|
||||
nixosOptionsDocs = buildOptionsDocs {
|
||||
modules = [ ../nixos scrubbedPkgsModule dontCheckDefinitions ];
|
||||
modules = [
|
||||
../nixos
|
||||
scrubbedPkgsModule
|
||||
dontCheckDefinitions
|
||||
];
|
||||
includeModuleSystemOptions = false;
|
||||
variablelistId = "nixos-options";
|
||||
optionIdPrefix = "nixos-opt-";
|
||||
};
|
||||
|
||||
nixDarwinOptionsDocs = buildOptionsDocs {
|
||||
modules = [ ../nix-darwin scrubbedPkgsModule dontCheckDefinitions ];
|
||||
modules = [
|
||||
../nix-darwin
|
||||
scrubbedPkgsModule
|
||||
dontCheckDefinitions
|
||||
];
|
||||
includeModuleSystemOptions = false;
|
||||
variablelistId = "nix-darwin-options";
|
||||
optionIdPrefix = "nix-darwin-opt-";
|
||||
|
|
@ -108,22 +149,26 @@ let
|
|||
revision = "release-${release-config.release}";
|
||||
# Generate the `man home-configuration.nix` package
|
||||
home-configuration-manual =
|
||||
pkgs.runCommand "home-configuration-reference-manpage" {
|
||||
nativeBuildInputs =
|
||||
[ pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs ];
|
||||
allowedReferences = [ "out" ];
|
||||
} ''
|
||||
# Generate manpages.
|
||||
mkdir -p $out/share/man/man5
|
||||
mkdir -p $out/share/man/man1
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
||||
--revision ${revision} \
|
||||
--header ${./home-configuration-nix-header.5} \
|
||||
--footer ${./home-configuration-nix-footer.5} \
|
||||
${hmOptionsDocs.optionsJSON}/share/doc/nixos/options.json \
|
||||
$out/share/man/man5/home-configuration.nix.5
|
||||
cp ${./home-manager.1} $out/share/man/man1/home-manager.1
|
||||
'';
|
||||
pkgs.runCommand "home-configuration-reference-manpage"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.buildPackages.installShellFiles
|
||||
pkgs.nixos-render-docs
|
||||
];
|
||||
allowedReferences = [ "out" ];
|
||||
}
|
||||
''
|
||||
# Generate manpages.
|
||||
mkdir -p $out/share/man/man5
|
||||
mkdir -p $out/share/man/man1
|
||||
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
||||
--revision ${revision} \
|
||||
--header ${./home-configuration-nix-header.5} \
|
||||
--footer ${./home-configuration-nix-footer.5} \
|
||||
${hmOptionsDocs.optionsJSON}/share/doc/nixos/options.json \
|
||||
$out/share/man/man5/home-configuration.nix.5
|
||||
cp ${./home-manager.1} $out/share/man/man1/home-manager.1
|
||||
'';
|
||||
# Generate the HTML manual pages
|
||||
home-manager-manual = pkgs.callPackage ./home-manager-manual.nix {
|
||||
home-manager-options = {
|
||||
|
|
@ -135,22 +180,26 @@ let
|
|||
};
|
||||
html = home-manager-manual;
|
||||
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix { } { inherit html; };
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
|
||||
# `nixosOptionsDoc` is more customizable.
|
||||
json = pkgs.runCommand "options.json" {
|
||||
meta.description = "List of Home Manager options in JSON format";
|
||||
} ''
|
||||
mkdir -p $out/{share/doc,nix-support}
|
||||
cp -a ${hmOptionsDocs.optionsJSON}/share/doc/nixos $out/share/doc/home-manager
|
||||
substitute \
|
||||
${hmOptionsDocs.optionsJSON}/nix-support/hydra-build-products \
|
||||
$out/nix-support/hydra-build-products \
|
||||
--replace-fail \
|
||||
'${hmOptionsDocs.optionsJSON}/share/doc/nixos' \
|
||||
"$out/share/doc/home-manager"
|
||||
'';
|
||||
json =
|
||||
pkgs.runCommand "options.json"
|
||||
{
|
||||
meta.description = "List of Home Manager options in JSON format";
|
||||
}
|
||||
''
|
||||
mkdir -p $out/{share/doc,nix-support}
|
||||
cp -a ${hmOptionsDocs.optionsJSON}/share/doc/nixos $out/share/doc/home-manager
|
||||
substitute \
|
||||
${hmOptionsDocs.optionsJSON}/nix-support/hydra-build-products \
|
||||
$out/nix-support/hydra-build-products \
|
||||
--replace-fail \
|
||||
'${hmOptionsDocs.optionsJSON}/share/doc/nixos' \
|
||||
"$out/share/doc/home-manager"
|
||||
'';
|
||||
};
|
||||
|
||||
manPages = home-configuration-manual;
|
||||
|
|
@ -158,13 +207,18 @@ in {
|
|||
manual = { inherit html htmlOpenTool; };
|
||||
|
||||
# Unstable, mainly for CI.
|
||||
jsonModuleMaintainers = pkgs.writeText "hm-module-maintainers.json" (let
|
||||
result = lib.evalModules {
|
||||
modules = import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
check = false;
|
||||
} ++ [ scrubbedPkgsModule ];
|
||||
class = "homeManager";
|
||||
};
|
||||
in builtins.toJSON result.config.meta.maintainers);
|
||||
jsonModuleMaintainers = pkgs.writeText "hm-module-maintainers.json" (
|
||||
let
|
||||
result = lib.evalModules {
|
||||
modules =
|
||||
import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
check = false;
|
||||
}
|
||||
++ [ scrubbedPkgsModule ];
|
||||
class = "homeManager";
|
||||
};
|
||||
in
|
||||
builtins.toJSON result.config.meta.maintainers
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, scss-reset }:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
scss-reset,
|
||||
}:
|
||||
let
|
||||
supportedSystems = [
|
||||
"aarch64-darwin"
|
||||
|
|
@ -28,7 +33,12 @@
|
|||
p-build = pkgs.writeShellScriptBin "p-build" ''
|
||||
set -euo pipefail
|
||||
|
||||
export PATH=${lib.makeBinPath [ pkgs.coreutils pkgs.rsass ]}
|
||||
export PATH=${
|
||||
lib.makeBinPath [
|
||||
pkgs.coreutils
|
||||
pkgs.rsass
|
||||
]
|
||||
}
|
||||
|
||||
tmpfile=$(mktemp -d)
|
||||
trap "rm -r $tmpfile" EXIT
|
||||
|
|
@ -42,20 +52,25 @@
|
|||
};
|
||||
|
||||
releaseInfo = lib.importJSON ../release.json;
|
||||
in {
|
||||
devShells = forAllSystems (system:
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
fpkgs = flakePkgs pkgs;
|
||||
in {
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
name = "hm-docs";
|
||||
packages = [ fpkgs.p-build ];
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
# Expose the docs outputs
|
||||
packages = forAllSystems (system:
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
docs = import ./default.nix {
|
||||
|
|
@ -63,10 +78,12 @@
|
|||
release = releaseInfo.release;
|
||||
isReleaseBranch = releaseInfo.isReleaseBranch;
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit (docs) manPages jsonModuleMaintainers;
|
||||
inherit (docs.manual) html htmlOpenTool;
|
||||
inherit (docs.options) json;
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
{ stdenv, lib, documentation-highlighter, revision, home-manager-options
|
||||
, nixos-render-docs }:
|
||||
let outputPath = "share/doc/home-manager";
|
||||
in stdenv.mkDerivation {
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
documentation-highlighter,
|
||||
revision,
|
||||
home-manager-options,
|
||||
nixos-render-docs,
|
||||
}:
|
||||
let
|
||||
outputPath = "share/doc/home-manager";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "home-manager-manual";
|
||||
|
||||
nativeBuildInputs = [ nixos-render-docs ];
|
||||
|
|
@ -61,5 +69,7 @@ in stdenv.mkDerivation {
|
|||
|
||||
passthru = { inherit home-manager-options; };
|
||||
|
||||
meta = { maintainers = [ lib.maintainers.considerate ]; };
|
||||
meta = {
|
||||
maintainers = [ lib.maintainers.considerate ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
{ writeShellScriptBin, makeDesktopItem, symlinkJoin }:
|
||||
{ html, pathName ? "home-manager", projectName ? pathName
|
||||
, name ? "${pathName}-help" }:
|
||||
{
|
||||
writeShellScriptBin,
|
||||
makeDesktopItem,
|
||||
symlinkJoin,
|
||||
}:
|
||||
{
|
||||
html,
|
||||
pathName ? "home-manager",
|
||||
projectName ? pathName,
|
||||
name ? "${pathName}-help",
|
||||
}:
|
||||
let
|
||||
helpScript = writeShellScriptBin name ''
|
||||
set -euo pipefail
|
||||
|
|
@ -30,7 +38,11 @@ let
|
|||
exec = "${helpScript}/bin/${name}";
|
||||
categories = [ "System" ];
|
||||
};
|
||||
in symlinkJoin {
|
||||
in
|
||||
symlinkJoin {
|
||||
inherit name;
|
||||
paths = [ helpScript desktopItem ];
|
||||
paths = [
|
||||
helpScript
|
||||
desktopItem
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue