chore: reformat codebase

This commit is contained in:
Gabriel Arazas 2025-01-12 17:58:39 +08:00
parent 2bb1dc66c7
commit c2625afbff
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
17 changed files with 458 additions and 269 deletions

View File

@ -31,8 +31,7 @@ let
}).options;
# Based from nixpkgs' and home-manager's code.
gitHubDeclaration = user: repo: subpath:
{
gitHubDeclaration = user: repo: subpath: {
url = "https://github.com/${user}/${repo}/blob/master/${subpath}";
name = "<${repo}/${subpath}>";
};
@ -42,16 +41,21 @@ let
{
options =
if includeModuleSystemOptions then options else builtins.removeAttrs options [ "_module" ];
transformOptions = opt:
opt // {
declarations = map (decl:
transformOptions =
opt:
opt
// {
declarations = map (
decl:
if lib.hasPrefix src (toString decl) then
gitHubDeclaration "foo-dogsquared" "nix-module-wrapper-manager-fds"
(lib.removePrefix "/" (lib.removePrefix src (toString decl)))
gitHubDeclaration "foo-dogsquared" "nix-module-wrapper-manager-fds" (
lib.removePrefix "/" (lib.removePrefix src (toString decl))
)
else if decl == "lib/modules.nix" then
gitHubDeclaration "NixOS" "nixpkgs" decl
else
decl) opt.declarations;
decl
) opt.declarations;
};
}
// builtins.removeAttrs args [
@ -106,7 +110,9 @@ in
];
};
in
{ baseUrl ? "https://foo-dogsquared.github.io/nix-module-wrapper-manager-fds" }:
{
baseUrl ? "https://foo-dogsquared.github.io/nix-module-wrapper-manager-fds",
}:
buildHugoSite {
pname = "wrapper-manager-docs";
@ -126,7 +132,10 @@ in
vendorHash = "sha256-UDDCYQB/kdYT63vRlRzL6lOePl9F7j3eUIHX/m6rwEs=";
buildFlags = [ "--baseURL" baseUrl ];
buildFlags = [
"--baseURL"
baseUrl
];
nativeBuildInputs = [
asciidoctorWrapped

View File

@ -10,7 +10,12 @@
version = "2.0.23";
};
asciidoctor-diagram = {
dependencies = ["asciidoctor" "asciidoctor-diagram-ditaamini" "asciidoctor-diagram-plantuml" "rexml"];
dependencies = [
"asciidoctor"
"asciidoctor-diagram-ditaamini"
"asciidoctor-diagram-plantuml"
"rexml"
];
groups = [ "default" ];
platforms = [ ];
source = {
@ -52,7 +57,10 @@
version = "1.2024.5";
};
asciidoctor-foodogsquared-extensions = {
dependencies = ["asciidoctor" "rugged"];
dependencies = [
"asciidoctor"
"rugged"
];
groups = [ "default" ];
platforms = [ ];
source = {
@ -63,7 +71,10 @@
version = "1.2.1";
};
ast = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -83,7 +94,10 @@
version = "1.3.3";
};
json = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -93,7 +107,11 @@
version = "2.7.2";
};
language_server-protocol = {
groups = ["default" "development" "lint"];
groups = [
"default"
"development"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -103,7 +121,10 @@
version = "3.17.0.3";
};
logger = {
groups = ["default" "development"];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -123,7 +144,10 @@
version = "1.0.0";
};
parallel = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -133,8 +157,14 @@
version = "1.25.1";
};
parser = {
dependencies = ["ast" "racc"];
groups = ["default" "lint"];
dependencies = [
"ast"
"racc"
];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -144,7 +174,10 @@
version = "3.3.4.0";
};
prism = {
groups = ["default" "development"];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -154,7 +187,10 @@
version = "0.30.0";
};
racc = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -164,7 +200,10 @@
version = "1.8.0";
};
rainbow = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -185,7 +224,10 @@
};
rbs = {
dependencies = [ "logger" ];
groups = ["default" "development"];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -195,7 +237,10 @@
version = "3.5.2";
};
regexp_parser = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -206,7 +251,10 @@
};
rexml = {
dependencies = [ "strscan" ];
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -226,7 +274,18 @@
version = "4.3.0";
};
rubocop = {
dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rexml" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
dependencies = [
"json"
"language_server-protocol"
"parallel"
"parser"
"rainbow"
"regexp_parser"
"rexml"
"rubocop-ast"
"ruby-progressbar"
"unicode-display_width"
];
groups = [ "lint" ];
platforms = [ ];
source = {
@ -238,7 +297,10 @@
};
rubocop-ast = {
dependencies = [ "parser" ];
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -248,7 +310,12 @@
version = "1.31.3";
};
ruby-lsp = {
dependencies = ["language_server-protocol" "prism" "rbs" "sorbet-runtime"];
dependencies = [
"language_server-protocol"
"prism"
"rbs"
"sorbet-runtime"
];
groups = [ "development" ];
platforms = [ ];
source = {
@ -259,7 +326,10 @@
version = "0.17.7";
};
ruby-progressbar = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -279,7 +349,10 @@
version = "1.7.2";
};
slim = {
dependencies = ["temple" "tilt"];
dependencies = [
"temple"
"tilt"
];
groups = [ "default" ];
platforms = [ ];
source = {
@ -290,7 +363,10 @@
version = "5.2.1";
};
sorbet-runtime = {
groups = ["default" "development"];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -300,7 +376,10 @@
version = "0.5.11481";
};
strscan = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];
@ -330,7 +409,10 @@
version = "2.4.0";
};
unicode-display_width = {
groups = ["default" "lint"];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = [ "https://rubygems.org" ];

View File

@ -61,9 +61,9 @@
website = docs.website { };
};
checks =
{ inherit (tests) lib; }
// lib.mapAttrs' (n: v: lib.nameValuePair "config-test-${n}" v) tests.configs;
checks = {
inherit (tests) lib;
} // lib.mapAttrs' (n: v: lib.nameValuePair "config-test-${n}" v) tests.configs;
}
));
}

View File

@ -25,7 +25,12 @@ pkgs.lib.makeExtensible (
modules = callLibs ./modules.nix;
inherit (self.env) build eval;
inherit (self.utils) getBin getLibexec getXdgDataDirs getXdgConfigDirs;
inherit (self.utils)
getBin
getLibexec
getXdgDataDirs
getXdgConfigDirs
;
inherit (self.modules) makeWraparound;
}
)

View File

@ -16,7 +16,8 @@ rec {
another program. Several examples of this includes sudo, Bubblewrap, and
Gamescope.
*/
makeWraparound = {
makeWraparound =
{
arg0,
under,
underFlags ? [ ],
@ -38,9 +39,7 @@ rec {
# arbitrarily just in case the user already has `prependArgs` values
# with `lib.mkBefore` for the original arg0.
prependArgs = lib.mkOrder 250 (
underFlags
++ lib.optionals (underSeparator != "") [ underSeparator ]
++ [ arg0 ]
underFlags ++ lib.optionals (underSeparator != "") [ underSeparator ] ++ [ arg0 ]
);
}

View File

@ -23,7 +23,8 @@ let
)
(
{ lib, ... }: {
{ lib, ... }:
{
options.enableInstall = lib.mkOption {
type = lib.types.bool;
default = cfg.enableInstall;

View File

@ -7,7 +7,10 @@
let
cfg = config.wrapper-manager;
wmDocs = import ../../../docs { inherit pkgs; inherit (cfg.documentation) extraModules; };
wmDocs = import ../../../docs {
inherit pkgs;
inherit (cfg.documentation) extraModules;
};
in
{
imports = [ ../common.nix ];

View File

@ -7,7 +7,10 @@
let
cfg = config.wrapper-manager;
wmDocs = import ../../../docs { inherit pkgs; inherit (cfg.documentation) extraModules; };
wmDocs = import ../../../docs {
inherit pkgs;
inherit (cfg.documentation) extraModules;
};
in
{
imports = [ ../common.nix ];

View File

@ -8,7 +8,18 @@
let
envConfig = config;
toStringType = (with lib.types; coercedTo (oneOf [str path int float bool]) (x: "${x}") str) // {
toStringType =
(
with lib.types;
coercedTo (oneOf [
str
path
int
float
bool
]) (x: "${x}") str
)
// {
description = "string and select types (numbers, boolean, and path) convertible to it";
};
envSubmodule =
@ -174,7 +185,12 @@ let
n: v:
if v.action == "unset" then
"--${v.action} ${lib.escapeShellArg n}"
else if lib.elem v.action [ "prefix" "suffix" ] then
else if
lib.elem v.action [
"prefix"
"suffix"
]
then
"--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.separator} ${lib.escapeShellArg (lib.concatStringsSep v.separator v.value)}"
else
"--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.value}"

View File

@ -8,7 +8,10 @@
{
options.build = {
variant = lib.mkOption {
type = lib.types.enum [ "binary" "shell" ];
type = lib.types.enum [
"binary"
"shell"
];
description = ''
Indicates the type of wrapper to be made. By default, wrapper-manager
sets this to `binary`.
@ -48,9 +51,12 @@
let
inherit (config.build) variant;
makeWrapperArg0 =
if variant == "binary" then "makeBinaryWrapper"
else if variant == "shell" then "makeShellWrapper"
else "makeWrapper";
if variant == "binary" then
"makeBinaryWrapper"
else if variant == "shell" then
"makeShellWrapper"
else
"makeWrapper";
mkWrapBuild =
wrappers:
@ -68,22 +74,29 @@
name = "wrapper-manager-fds-wrapped-package";
paths = desktopEntries ++ config.basePackages;
nativeBuildInputs =
if variant == "binary" then [ pkgs.makeBinaryWrapper ]
else if variant == "shell" then [ pkgs.makeShellWrapper ]
else [ ];
if variant == "binary" then
[ pkgs.makeBinaryWrapper ]
else if variant == "shell" then
[ pkgs.makeShellWrapper ]
else
[ ];
postBuild = ''
${config.build.extraSetup}
${mkWrapBuild (lib.attrValues config.wrappers)}
'';
}
else
config.basePackages.overrideAttrs (final: prev: {
config.basePackages.overrideAttrs (
final: prev: {
nativeBuildInputs =
(prev.nativeBuildInputs or [ ])
++ (
if variant == "binary" then [ pkgs.makeBinaryWrapper ]
else if variant == "shell" then [ pkgs.makeShellWrapper ]
else [ ]
if variant == "binary" then
[ pkgs.makeBinaryWrapper ]
else if variant == "shell" then
[ pkgs.makeShellWrapper ]
else
[ ]
)
++ lib.optionals (config.xdg.desktopEntries != { }) [ pkgs.copyDesktopItems ];
desktopItems = (prev.desktopItems or [ ]) ++ desktopEntries;
@ -91,10 +104,14 @@
${prev.postFixup or ""}
${mkWrapBuild (lib.attrValues config.wrappers)}
'';
passthru = lib.recursiveUpdate (prev.passthru or { }) (config.build.extraPassthru // {
passthru = lib.recursiveUpdate (prev.passthru or { }) (
config.build.extraPassthru
// {
unwrapped = config.basePackages;
});
});
}
);
}
);
};
};
}

View File

@ -1,9 +1,22 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.files;
filesModule = { name, lib, config, options, ... }: {
filesModule =
{
name,
lib,
config,
options,
...
}:
{
options = {
target = lib.mkOption {
type = lib.types.nonEmptyStr;
@ -46,7 +59,8 @@ let
source = lib.mkIf (config.text != null) (
let
name' = "wrapper-manager-filesystem-${lib.replaceStrings [ "/" ] [ "-" ] name}";
in lib.modules.mkDerivedConfig options.text (pkgs.writeText name')
in
lib.modules.mkDerivedConfig options.text (pkgs.writeText name')
);
};
};
@ -79,26 +93,37 @@ in
};
config = lib.mkIf (cfg != { }) {
build.extraSetup = let
installFiles = acc: n: v: let
build.extraSetup =
let
installFiles =
acc: n: v:
let
source = lib.escapeShellArg v.source;
target = lib.escapeShellArg v.target;
target' = "$out/${target}";
installFile = let
installFile =
let
type = lib.filesystem.pathType v.source;
in
if type == "directory" then ''
if type == "directory" then
''
mkdir -p $(basename ${target'}) && cp --recursive ${source} ${target'}
'' else if type == "symlink" then ''
''
else if type == "symlink" then
''
ln --symbolic --force ${source} ${target'}
'' else ''
''
else
''
install -D --mode=${v.mode} ${source} ${target'}
'';
in ''
in
''
${acc}
${installFile}
'';
in lib.mkBefore ''
in
lib.mkBefore ''
${lib.foldlAttrs installFiles "" cfg}
'';
};

View File

@ -1,4 +1,10 @@
{ config, lib, pkgs, wrapperManagerLib, ... }:
{
config,
lib,
pkgs,
wrapperManagerLib,
...
}:
let
inherit (wrapperManagerLib) makeWraparound;
@ -7,7 +13,10 @@ in
build.variant = "shell";
wrappers.tmux = makeWraparound {
under = lib.getExe' pkgs.boxxy "boxxy";
underFlags = [ "--rule" "~/.tmux.conf:~/.config/tmux/tmux.conf" ];
underFlags = [
"--rule"
"~/.tmux.conf:~/.config/tmux/tmux.conf"
];
underSeparator = "--";
arg0 = lib.getExe' pkgs.tmux "tmux";

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
wrappers.neofetch = {

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
basePackages = pkgs.fastfetch;

View File

@ -19,9 +19,12 @@
xdg.desktopEntry.enable = true;
};
environment.pathAdd = wrapperManagerLib.getBin (with pkgs; [
environment.pathAdd = wrapperManagerLib.getBin (
with pkgs;
[
hello
]);
]
);
build.extraPassthru.wrapperManagerTests = {
actuallyBuilt =

View File

@ -22,19 +22,23 @@
);
wrappers.xdg-config-dirs-script = {
arg0 = let
arg0 =
let
app = pkgs.writeShellScript "xdg-dirs-script" ''
echo "$XDG_CONFIG_DIRS" | tr ':' '\n'
'';
in builtins.toString app;
in
builtins.toString app;
};
wrappers.xdg-data-dirs-script = {
arg0 = let
arg0 =
let
app = pkgs.writeShellScript "xdg-dirs-script" ''
echo "$XDG_DATA_DIRS" | tr ':' '\n'
'';
in builtins.toString app;
in
builtins.toString app;
};
build.extraPassthru.wrapperManagerTests = {

View File

@ -10,9 +10,12 @@ let
inherit (pkgs) lib;
in
{
configs = let
configs =
let
configs' = import ./configs { inherit pkgs; };
updateTestName = configName: package: lib.mapAttrs' (n: v: lib.nameValuePair "${configName}-${n}" v) package.wrapperManagerTests;
updateTestName =
configName: package:
lib.mapAttrs' (n: v: lib.nameValuePair "${configName}-${n}" v) package.wrapperManagerTests;
in
lib.concatMapAttrs updateTestName configs';