chore: reformat codebase
Some checks failed
Check test suite / Check outputs (push) Has been cancelled
Deploy documentation site / Build website (push) Has been cancelled
Deploy documentation site / Deploy website (push) Has been cancelled
Update Nix dependencies / update-nix-deps (push) Has been cancelled

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

@ -30,9 +30,8 @@ let
class = "wrapperManager";
}).options;
# Based from nixpkgs' and home-manager's code.
gitHubDeclaration = user: repo: subpath:
{
# Based from nixpkgs' and home-manager's code.
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

@ -1,339 +1,421 @@
{
asciidoctor = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1wyxgwmnz9bw377r3lba26b090hbsq9qnbw8575a1prpy83qh82j";
type = "gem";
};
version = "2.0.23";
};
asciidoctor-diagram = {
dependencies = ["asciidoctor" "asciidoctor-diagram-ditaamini" "asciidoctor-diagram-plantuml" "rexml"];
groups = ["default"];
platforms = [];
dependencies = [
"asciidoctor"
"asciidoctor-diagram-ditaamini"
"asciidoctor-diagram-plantuml"
"rexml"
];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1214scxm36k409gfy3wilfqx3akrm52r530zmra6cmmf6d22c5q4";
type = "gem";
};
version = "2.3.1";
};
asciidoctor-diagram-batik = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0220xqxmkmimxmhsqhlbr0hslijvnhzdds3s6h6fxbxqrrmm0jrl";
type = "gem";
};
version = "1.17";
};
asciidoctor-diagram-ditaamini = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "13h65bfbq7hc7z3kqn0m28w9c6ap7fikpjcvsdga6jg01slb4c56";
type = "gem";
};
version = "1.0.3";
};
asciidoctor-diagram-plantuml = {
dependencies = ["asciidoctor-diagram-batik"];
groups = ["default"];
platforms = [];
dependencies = [ "asciidoctor-diagram-batik" ];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1ppl5nsq40x11731ciahi89k5yvszlm12pml1pqaj0lwbi7ww6x0";
type = "gem";
};
version = "1.2024.5";
};
asciidoctor-foodogsquared-extensions = {
dependencies = ["asciidoctor" "rugged"];
groups = ["default"];
platforms = [];
dependencies = [
"asciidoctor"
"rugged"
];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0fm6shyysj51wi4s7nnb643j2mphp68fh44gmr83x8n613hg9a4l";
type = "gem";
};
version = "1.2.1";
};
ast = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "04nc8x27hlzlrr5c2gn7mar4vdr0apw5xg22wp6m8dx3wqr04a0y";
type = "gem";
};
version = "2.4.2";
};
concurrent-ruby = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0skwdasxq7mnlcccn6aqabl7n9r3jd7k19ryzlzzip64cn4x572g";
type = "gem";
};
version = "1.3.3";
};
json = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0b4qsi8gay7ncmigr0pnbxyb17y3h8kavdyhsh7nrlqwr35vb60q";
type = "gem";
};
version = "2.7.2";
};
language_server-protocol = {
groups = ["default" "development" "lint"];
platforms = [];
groups = [
"default"
"development"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0gvb1j8xsqxms9mww01rmdl78zkd72zgxaap56bhv8j45z05hp1x";
type = "gem";
};
version = "3.17.0.3";
};
logger = {
groups = ["default" "development"];
platforms = [];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0gpg8gzi0xwymw4aaq2iafcbx31i3xzkg3fb30mdxn1d4qhc3dqa";
type = "gem";
};
version = "1.6.0";
};
open-uri-cached = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "03v0if3jlvbclnd6jgjk94fbhf0h2fq1wxr0mbx7018sxzm0biwr";
type = "gem";
};
version = "1.0.0";
};
parallel = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "145bn5q7ysnjj02jdf1x4nc1f0xxrv7ihgz9yr1j7sinmawqkq0j";
type = "gem";
};
version = "1.25.1";
};
parser = {
dependencies = ["ast" "racc"];
groups = ["default" "lint"];
platforms = [];
dependencies = [
"ast"
"racc"
];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "10ly2wind06nylyqa5724ld2l0l46d3ag4fm04ifjgw7qdlpf94d";
type = "gem";
};
version = "3.3.4.0";
};
prism = {
groups = ["default" "development"];
platforms = [];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "05j9bcxdz6wfnrjn32zvdwj1qsbp88mwx3rv7g256gziya6avc2r";
type = "gem";
};
version = "0.30.0";
};
racc = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "021s7maw0c4d9a6s07vbmllrzqsj2sgmrwimlh8ffkvwqdjrld09";
type = "gem";
};
version = "1.8.0";
};
rainbow = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0smwg4mii0fm38pyb5fddbmrdpifwv22zv3d3px2xx497am93503";
type = "gem";
};
version = "3.1.1";
};
rake = {
groups = ["development"];
platforms = [];
groups = [ "development" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "17850wcwkgi30p7yqh60960ypn7yibacjjha0av78zaxwvd3ijs6";
type = "gem";
};
version = "13.2.1";
};
rbs = {
dependencies = ["logger"];
groups = ["default" "development"];
platforms = [];
dependencies = [ "logger" ];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1fzk0a3d68fglnkwpaz07npi929y1kh2hh1j63y04943vvshyjmc";
type = "gem";
};
version = "3.5.2";
};
regexp_parser = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0ik40vcv7mqigsfpqpca36hpmnx0536xa825ai5qlkv3mmkyf9ss";
type = "gem";
};
version = "2.9.2";
};
rexml = {
dependencies = ["strscan"];
groups = ["default" "lint"];
platforms = [];
dependencies = [ "strscan" ];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "09f3sw7f846fpcpwdm362ylqldwqxpym6z0qpld4av7zisrrzbrl";
type = "gem";
};
version = "3.3.1";
};
rouge = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "072qvvrcqj0yfr3b0j932mlhvn41i38bq37z7z07i3ikagndkqwy";
type = "gem";
};
version = "4.3.0";
};
rubocop = {
dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rexml" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
groups = ["lint"];
platforms = [];
dependencies = [
"json"
"language_server-protocol"
"parallel"
"parser"
"rainbow"
"regexp_parser"
"rexml"
"rubocop-ast"
"ruby-progressbar"
"unicode-display_width"
];
groups = [ "lint" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "18g462bccr0rvszc7kirr89laggdf6254p7pqsckk3izg901chv2";
type = "gem";
};
version = "1.65.0";
};
rubocop-ast = {
dependencies = ["parser"];
groups = ["default" "lint"];
platforms = [];
dependencies = [ "parser" ];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "063qgvqbyv354icl2sgx758z22wzq38hd9skc3n96sbpv0cdc1qv";
type = "gem";
};
version = "1.31.3";
};
ruby-lsp = {
dependencies = ["language_server-protocol" "prism" "rbs" "sorbet-runtime"];
groups = ["development"];
platforms = [];
dependencies = [
"language_server-protocol"
"prism"
"rbs"
"sorbet-runtime"
];
groups = [ "development" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1kvyk0cald1cw6fqxy5w68la1gnc1nv2mqx8myijjsbcf9npjbp8";
type = "gem";
};
version = "0.17.7";
};
ruby-progressbar = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0cwvyb7j47m7wihpfaq7rc47zwwx9k4v7iqd9s1xch5nm53rrz40";
type = "gem";
};
version = "1.13.0";
};
rugged = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1sccng15h8h3mcjxfgvxy85lfpswbj0nhmzwwsqdffbzqgsb2jch";
type = "gem";
};
version = "1.7.2";
};
slim = {
dependencies = ["temple" "tilt"];
groups = ["default"];
platforms = [];
dependencies = [
"temple"
"tilt"
];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1rqk7jn66wgx50b18ndhbppjq55rbcwgqg1rbhnhxwiggvzisdbj";
type = "gem";
};
version = "5.2.1";
};
sorbet-runtime = {
groups = ["default" "development"];
platforms = [];
groups = [
"default"
"development"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "122702d5cmrbaydcqfjksh1d78g0mq69h77zd4yljwjrc50jz70b";
type = "gem";
};
version = "0.5.11481";
};
strscan = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0mamrl7pxacbc79ny5hzmakc9grbjysm3yy6119ppgsg44fsif01";
type = "gem";
};
version = "3.1.0";
};
temple = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0fwia5hvc1xz9w7vprzjnsym3v9j5l9ggdvy70jixbvpcpz4acfz";
type = "gem";
};
version = "0.10.3";
};
tilt = {
groups = ["default"];
platforms = [];
groups = [ "default" ];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "0kds7wkxmb038cwp6ravnwn8k65ixc68wpm8j5jx5bhx8ndg4x6z";
type = "gem";
};
version = "2.4.0";
};
unicode-display_width = {
groups = ["default" "lint"];
platforms = [];
groups = [
"default"
"lint"
];
platforms = [ ];
source = {
remotes = ["https://rubygems.org"];
remotes = [ "https://rubygems.org" ];
sha256 = "1d0azx233nags5jx3fqyr23qa2rhgzbhv8pxp46dgbg1mpf82xky";
type = "gem";
};

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,37 +16,36 @@ rec {
another program. Several examples of this includes sudo, Bubblewrap, and
Gamescope.
*/
makeWraparound = {
arg0,
under,
underFlags ? [ ],
underSeparator ? "",
...
}@module:
makeWraparound =
{
arg0,
under,
underFlags ? [ ],
underSeparator ? "",
...
}@module:
let
# These are the attrnames that would be overtaken with the function and
# will be merged anyways so...
functionArgs = builtins.functionArgs makeWraparound;
module' = lib.removeAttrs module (lib.attrNames functionArgs);
in
lib.mkMerge [
{
arg0 = under;
lib.mkMerge [
{
arg0 = under;
# This should be the very first things to be in the arguments so
# we're just making sure that it is the case. The priority is chosen
# 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 ]
);
}
# This should be the very first things to be in the arguments so
# we're just making sure that it is the case. The priority is chosen
# 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 ]
);
}
# It's constructed like this to make it ergonomic to use. The user can
# simply delete the makeWraparound exclusive arguments and still work
# normally.
module'
];
# It's constructed like this to make it ergonomic to use. The user can
# simply delete the makeWraparound exclusive arguments and still work
# normally.
module'
];
}

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 ];
@ -39,7 +42,7 @@ in
let
validPackages = lib.filterAttrs (_: wrapper: wrapper.enableInstall) cfg.packages;
in
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages;
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages;
})
];
}

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 ];
@ -37,7 +40,7 @@ in
let
validPackages = lib.filterAttrs (_: wrapper: wrapper.enableInstall) cfg.packages;
in
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages;
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages;
})
];
}

View File

@ -8,9 +8,20 @@
let
envConfig = config;
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";
};
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 =
{
config,
@ -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:
@ -62,28 +68,35 @@
desktopEntries = mkDesktopEntries (lib.attrValues config.xdg.desktopEntries);
in
if lib.isList config.basePackages then
pkgs.symlinkJoin {
passthru = config.build.extraPassthru;
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 [ ];
postBuild = ''
${config.build.extraSetup}
${mkWrapBuild (lib.attrValues config.wrappers)}
'';
}
else
config.basePackages.overrideAttrs (final: prev: {
if lib.isList config.basePackages then
pkgs.symlinkJoin {
passthru = config.build.extraPassthru;
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
[ ];
postBuild = ''
${config.build.extraSetup}
${mkWrapBuild (lib.attrValues config.wrappers)}
'';
}
else
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 // {
unwrapped = config.basePackages;
});
});
passthru = lib.recursiveUpdate (prev.passthru or { }) (
config.build.extraPassthru
// {
unwrapped = config.basePackages;
}
);
}
);
};
};
}

View File

@ -1,55 +1,69 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.files;
filesModule = { name, lib, config, options, ... }: {
options = {
target = lib.mkOption {
type = lib.types.nonEmptyStr;
description = ''
Path of the file relative to the derivation output path.
'';
default = name;
example = "share/applications/org.example.App1.desktop";
filesModule =
{
name,
lib,
config,
options,
...
}:
{
options = {
target = lib.mkOption {
type = lib.types.nonEmptyStr;
description = ''
Path of the file relative to the derivation output path.
'';
default = name;
example = "share/applications/org.example.App1.desktop";
};
source = lib.mkOption {
type = lib.types.path;
description = "Path of the file to be linked.";
};
text = lib.mkOption {
type = with lib.types; nullOr lines;
description = ''
Text content of the given filesystem path.
'';
default = null;
example = ''
key=value
hello=world
'';
};
mode = lib.mkOption {
type = lib.types.strMatching "[0-7]{0,4}";
default = "0644";
example = "0600";
description = ''
Permissions to be given to the file. By default, it is given with a
symlink.
'';
};
};
source = lib.mkOption {
type = lib.types.path;
description = "Path of the file to be linked.";
};
text = lib.mkOption {
type = with lib.types; nullOr lines;
description = ''
Text content of the given filesystem path.
'';
default = null;
example = ''
key=value
hello=world
'';
};
mode = lib.mkOption {
type = lib.types.strMatching "[0-7]{0,4}";
default = "0644";
example = "0600";
description = ''
Permissions to be given to the file. By default, it is given with a
symlink.
'';
config = {
source = lib.mkIf (config.text != null) (
let
name' = "wrapper-manager-filesystem-${lib.replaceStrings [ "/" ] [ "-" ] name}";
in
lib.modules.mkDerivedConfig options.text (pkgs.writeText name')
);
};
};
config = {
source = lib.mkIf (config.text != null) (
let
name' = "wrapper-manager-filesystem-${lib.replaceStrings ["/"] ["-"] name}";
in lib.modules.mkDerivedConfig options.text (pkgs.writeText name')
);
};
};
in
{
options.files = lib.mkOption {
@ -79,27 +93,38 @@ in
};
config = lib.mkIf (cfg != { }) {
build.extraSetup = let
installFiles = acc: n: v: let
source = lib.escapeShellArg v.source;
target = lib.escapeShellArg v.target;
target' = "$out/${target}";
installFile = let
type = lib.filesystem.pathType v.source;
build.extraSetup =
let
installFiles =
acc: n: v:
let
source = lib.escapeShellArg v.source;
target = lib.escapeShellArg v.target;
target' = "$out/${target}";
installFile =
let
type = lib.filesystem.pathType v.source;
in
if type == "directory" then
''
mkdir -p $(basename ${target'}) && cp --recursive ${source} ${target'}
''
else if type == "symlink" then
''
ln --symbolic --force ${source} ${target'}
''
else
''
install -D --mode=${v.mode} ${source} ${target'}
'';
in
if type == "directory" then ''
mkdir -p $(basename ${target'}) && cp --recursive ${source} ${target'}
'' else if type == "symlink" then ''
ln --symbolic --force ${source} ${target'}
'' else ''
install -D --mode=${v.mode} ${source} ${target'}
''
${acc}
${installFile}
'';
in ''
${acc}
${installFile}
in
lib.mkBefore ''
${lib.foldlAttrs installFiles "" cfg}
'';
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; [
hello
]);
environment.pathAdd = wrapperManagerLib.getBin (
with pkgs;
[
hello
]
);
build.extraPassthru.wrapperManagerTests = {
actuallyBuilt =

View File

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

View File

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