wrapper-manager-fds: reformat codebase

This commit is contained in:
Gabriel Arazas 2024-07-31 21:51:40 +08:00
parent 6eed3dbaea
commit d4a8025d06
24 changed files with 1083 additions and 717 deletions

View File

@ -1,26 +1,42 @@
let let
sources = import ../npins; sources = import ../npins;
in in
{ pkgs ? import sources.nixos-unstable { } }: {
pkgs ? import sources.nixos-unstable { },
}:
let let
inherit (pkgs) nixosOptionsDoc lib; inherit (pkgs) nixosOptionsDoc lib;
# Pretty much inspired from home-manager's documentation build process. # Pretty much inspired from home-manager's documentation build process.
evalDoc = args@{ modules, includeModuleSystemOptions ? false, ... }: evalDoc =
args@{
modules,
includeModuleSystemOptions ? false,
...
}:
let let
options = (pkgs.lib.evalModules { options =
modules = modules ++ [ { _module.check = false; _module.args.pkgs = pkgs; } ]; (pkgs.lib.evalModules {
modules = modules ++ [
{
_module.check = false;
_module.args.pkgs = pkgs;
}
];
class = "wrapperManager"; class = "wrapperManager";
}).options; }).options;
in in
nixosOptionsDoc ({ nixosOptionsDoc (
{
options = options =
if includeModuleSystemOptions if includeModuleSystemOptions then options else builtins.removeAttrs options [ "_module" ];
then options
else builtins.removeAttrs options [ "_module" ];
} }
// builtins.removeAttrs args [ "modules" "includeModuleSystemOptions" ]); // builtins.removeAttrs args [
"modules"
"includeModuleSystemOptions"
]
);
releaseConfig = lib.importJSON ../release.json; releaseConfig = lib.importJSON ../release.json;
wrapperManagerLib = (import ../. { }).lib; wrapperManagerLib = (import ../. { }).lib;
@ -48,18 +64,26 @@ in
buildHugoSite = pkgs.callPackage ./hugo-build-module.nix { }; buildHugoSite = pkgs.callPackage ./hugo-build-module.nix { };
# Now this is some dogfooding. # Now this is some dogfooding.
asciidoctorWrapped = asciidoctorWrapped = wrapperManagerLib.build {
wrapperManagerLib.build {
inherit pkgs; inherit pkgs;
modules = [ modules = [
({ config, lib, pkgs, ... }: { (
{
config,
lib,
pkgs,
...
}:
{
wrappers.asciidoctor = { wrappers.asciidoctor = {
arg0 = lib.getExe' gems "asciidoctor"; arg0 = lib.getExe' gems "asciidoctor";
appendArgs = [ appendArgs = [
"-T" "${sources.website}/templates" "-T"
"${sources.website}/templates"
]; ];
}; };
}) }
)
]; ];
}; };
in in
@ -106,9 +130,16 @@ in
inherit releaseConfig; inherit releaseConfig;
outputs = { outputs = {
manpage = pkgs.runCommand "wrapper-manager-reference-manpage" { manpage =
nativeBuildInputs = with pkgs; [ nixos-render-docs gems gems.wrappedRuby ]; pkgs.runCommand "wrapper-manager-reference-manpage"
} '' {
nativeBuildInputs = with pkgs; [
nixos-render-docs
gems
gems.wrappedRuby
];
}
''
mkdir -p $out/share/man/man5 mkdir -p $out/share/man/man5
asciidoctor --backend manpage ${./manpages/header.adoc} --out-file header.5 asciidoctor --backend manpage ${./manpages/header.adoc} --out-file header.5
nixos-render-docs options manpage --revision ${releaseConfig.version} \ nixos-render-docs options manpage --revision ${releaseConfig.version} \
@ -117,9 +148,15 @@ in
$out/share/man/man5/wrapper-manager.nix.5 $out/share/man/man5/wrapper-manager.nix.5
''; '';
html = pkgs.runCommand "wrapper-manager-reference-html" { html =
nativeBuildInputs = [ gems gems.wrappedRuby ]; pkgs.runCommand "wrapper-manager-reference-html"
} '' {
nativeBuildInputs = [
gems
gems.wrappedRuby
];
}
''
mkdir -p $out/share/wrapper-manager mkdir -p $out/share/wrapper-manager
asciidoctor --backend html ${wmOptionsDoc.optionsAsciiDoc} --out-file $out/share/wrapper-manager/options-reference.html asciidoctor --backend html ${wmOptionsDoc.optionsAsciiDoc} --out-file $out/share/wrapper-manager/options-reference.html
''; '';

View File

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

View File

@ -1,73 +1,93 @@
{ hugo, go, cacert, git, lib, stdenv }: {
hugo,
go,
cacert,
git,
lib,
stdenv,
}:
{ name ? "${args'.pname}-${args'.version}" {
, src name ? "${args'.pname}-${args'.version}",
, nativeBuildInputs ? [ ] src,
, passthru ? { } nativeBuildInputs ? [ ],
, patches ? [ ] passthru ? { },
patches ? [ ],
# A function to override the goModules derivation # A function to override the goModules derivation
, overrideModAttrs ? (_oldAttrs: { }) overrideModAttrs ? (_oldAttrs: { }),
# path to go.mod and go.sum directory # path to go.mod and go.sum directory
, modRoot ? "./" modRoot ? "./",
# vendorHash is the SRI hash of the vendored dependencies # vendorHash is the SRI hash of the vendored dependencies
# #
# if vendorHash is null, then we won't fetch any dependencies and # if vendorHash is null, then we won't fetch any dependencies and
# rely on the vendor folder within the source. # rely on the vendor folder within the source.
, vendorHash ? throw ( vendorHash ? throw (
if args'?vendorSha256 then if args' ? vendorSha256 then
"buildGoModule: Expect vendorHash instead of vendorSha256" "buildGoModule: Expect vendorHash instead of vendorSha256"
else else
"buildGoModule: vendorHash is missing" "buildGoModule: vendorHash is missing"
) ),
# Whether to delete the vendor folder supplied with the source. # Whether to delete the vendor folder supplied with the source.
, deleteVendor ? false deleteVendor ? false,
# Whether to fetch (go mod download) and proxy the vendor directory. # Whether to fetch (go mod download) and proxy the vendor directory.
# This is useful if your code depends on c code and go mod tidy does not # This is useful if your code depends on c code and go mod tidy does not
# include the needed sources to build or if any dependency has case-insensitive # include the needed sources to build or if any dependency has case-insensitive
# conflicts which will produce platform dependant `vendorHash` checksums. # conflicts which will produce platform dependant `vendorHash` checksums.
, proxyVendor ? false proxyVendor ? false,
# We want parallel builds by default # We want parallel builds by default
, enableParallelBuilding ? true enableParallelBuilding ? true,
# Do not enable this without good reason # Do not enable this without good reason
# IE: programs coupled with the compiler # IE: programs coupled with the compiler
, allowGoReference ? false allowGoReference ? false,
, CGO_ENABLED ? go.CGO_ENABLED CGO_ENABLED ? go.CGO_ENABLED,
, meta ? { } meta ? { },
# Not needed with buildGoModule # Not needed with buildGoModule
, goPackagePath ? "" goPackagePath ? "",
, ldflags ? [ ] ldflags ? [ ],
, GOFLAGS ? [ ] GOFLAGS ? [ ],
# needed for buildFlags{,Array} warning # needed for buildFlags{,Array} warning
, buildFlags ? "" buildFlags ? "",
, buildFlagsArray ? "" buildFlagsArray ? "",
, ... ...
}@args': }@args':
assert goPackagePath != "" -> throw "`goPackagePath` is not needed with `buildGoModule`"; assert goPackagePath != "" -> throw "`goPackagePath` is not needed with `buildGoModule`";
let let
args = removeAttrs args' [ "overrideModAttrs" "vendorSha256" "vendorHash" ]; args = removeAttrs args' [
"overrideModAttrs"
"vendorSha256"
"vendorHash"
];
GO111MODULE = "on"; GO111MODULE = "on";
GOTOOLCHAIN = "local"; GOTOOLCHAIN = "local";
hugoModules = if (vendorHash == null) then "" else hugoModules =
if (vendorHash == null) then
""
else
(stdenv.mkDerivation { (stdenv.mkDerivation {
name = "${name}-hugo-modules"; name = "${name}-hugo-modules";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ hugo go git cacert ]; nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
hugo
go
git
cacert
];
inherit (args) src; inherit (args) src;
inherit (go) GOOS GOARCH; inherit (go) GOOS GOARCH;
@ -93,7 +113,8 @@ let
"GOPROXY" "GOPROXY"
]; ];
configurePhase = args.modConfigurePhase or '' configurePhase =
args.modConfigurePhase or ''
runHook preConfigure runHook preConfigure
export GOCACHE=$TMPDIR/go-cache export GOCACHE=$TMPDIR/go-cache
export GOPATH="$TMPDIR/go" export GOPATH="$TMPDIR/go"
@ -101,45 +122,61 @@ let
runHook postConfigure runHook postConfigure
''; '';
buildPhase = args.modBuildPhase or ('' buildPhase =
args.modBuildPhase or (
''
runHook preBuild runHook preBuild
'' + lib.optionalString deleteVendor '' ''
+ lib.optionalString deleteVendor ''
if [ ! -d _vendor ]; then if [ ! -d _vendor ]; then
echo "_vendor folder does not exist, 'deleteVendor' is not needed" echo "_vendor folder does not exist, 'deleteVendor' is not needed"
exit 10 exit 10
else else
rm -rf _vendor rm -rf _vendor
fi fi
'' + '' ''
+ ''
if [ -d _vendor ]; then if [ -d _vendor ]; then
echo "_vendor folder exists, please set 'vendorHash = null;' in your expression" echo "_vendor folder exists, please set 'vendorHash = null;' in your expression"
exit 10 exit 10
fi fi
${if proxyVendor then '' ${
if proxyVendor then
''
mkdir -p "''${GOPATH}/pkg/mod/cache/download" mkdir -p "''${GOPATH}/pkg/mod/cache/download"
hugo mod vendor hugo mod vendor
'' else '' ''
else
''
if (( "''${NIX_DEBUG:-0}" >= 1 )); then if (( "''${NIX_DEBUG:-0}" >= 1 )); then
hugoModVendorFlags+=(-v) hugoModVendorFlags+=(-v)
fi fi
hugo mod vendor "''${hugoModVendorFlags[@]}" hugo mod vendor "''${hugoModVendorFlags[@]}"
''} ''
}
mkdir -p _vendor mkdir -p _vendor
runHook postBuild runHook postBuild
''); ''
);
installPhase = args.modInstallPhase or '' installPhase =
args.modInstallPhase or ''
runHook preInstall runHook preInstall
${if proxyVendor then '' ${
if proxyVendor then
''
rm -rf "''${GOPATH}/pkg/mod/cache/download/sumdb" rm -rf "''${GOPATH}/pkg/mod/cache/download/sumdb"
cp -r --reflink=auto "''${GOPATH}/pkg/mod/cache/download" $out cp -r --reflink=auto "''${GOPATH}/pkg/mod/cache/download" $out
'' else '' ''
else
''
cp -r --reflink=auto _vendor $out cp -r --reflink=auto _vendor $out
''} ''
}
if ! [ "$(ls -A $out)" ]; then if ! [ "$(ls -A $out)" ]; then
echo "_vendor folder is empty, please set 'vendorHash = null;' in your expression" echo "_vendor folder is empty, please set 'vendorHash = null;' in your expression"
@ -156,24 +193,43 @@ let
# Handle empty vendorHash; avoid # Handle empty vendorHash; avoid
# error: empty hash requires explicit hash algorithm # error: empty hash requires explicit hash algorithm
outputHashAlgo = if vendorHash == "" then "sha256" else null; outputHashAlgo = if vendorHash == "" then "sha256" else null;
}).overrideAttrs overrideModAttrs; }).overrideAttrs
overrideModAttrs;
package = stdenv.mkDerivation (args // { package = stdenv.mkDerivation (
nativeBuildInputs = [ hugo git go ] ++ nativeBuildInputs; args
// {
nativeBuildInputs = [
hugo
git
go
] ++ nativeBuildInputs;
inherit (go) GOOS GOARCH; inherit (go) GOOS GOARCH;
GOFLAGS = GOFLAGS GOFLAGS =
++ lib.warnIf (lib.any (lib.hasPrefix "-mod=") GOFLAGS) "use `proxyVendor` to control Go module/vendor behavior instead of setting `-mod=` in GOFLAGS" GOFLAGS
++
lib.warnIf (lib.any (lib.hasPrefix "-mod=") GOFLAGS)
"use `proxyVendor` to control Go module/vendor behavior instead of setting `-mod=` in GOFLAGS"
(lib.optional (!proxyVendor) "-mod=vendor") (lib.optional (!proxyVendor) "-mod=vendor")
++ lib.warnIf (builtins.elem "-trimpath" GOFLAGS) "`-trimpath` is added by default to GOFLAGS by buildGoModule when allowGoReference isn't set to true" ++
lib.warnIf (builtins.elem "-trimpath" GOFLAGS)
"`-trimpath` is added by default to GOFLAGS by buildGoModule when allowGoReference isn't set to true"
(lib.optional (!allowGoReference) "-trimpath"); (lib.optional (!allowGoReference) "-trimpath");
inherit CGO_ENABLED enableParallelBuilding GO111MODULE GOTOOLCHAIN; inherit
CGO_ENABLED
enableParallelBuilding
GO111MODULE
GOTOOLCHAIN
;
# If not set to an explicit value, set the buildid empty for reproducibility. # If not set to an explicit value, set the buildid empty for reproducibility.
ldflags = ldflags ++ lib.optional (!lib.any (lib.hasPrefix "-buildid=") ldflags) "-buildid="; ldflags = ldflags ++ lib.optional (!lib.any (lib.hasPrefix "-buildid=") ldflags) "-buildid=";
configurePhase = args.configurePhase or ('' configurePhase =
args.configurePhase or (
''
runHook preConfigure runHook preConfigure
export GOCACHE=$TMPDIR/go-cache export GOCACHE=$TMPDIR/go-cache
@ -181,14 +237,21 @@ let
export GOPROXY=off export GOPROXY=off
export GOSUMDB=off export GOSUMDB=off
cd "$modRoot" cd "$modRoot"
'' + lib.optionalString (vendorHash != null) '' ''
${if proxyVendor then '' + lib.optionalString (vendorHash != null) ''
${
if proxyVendor then
''
export GOPROXY=file://${hugoModules} export GOPROXY=file://${hugoModules}
'' else '' ''
else
''
rm -rf _vendor rm -rf _vendor
cp -r --reflink=auto ${hugoModules} _vendor cp -r --reflink=auto ${hugoModules} _vendor
''} ''
'' + '' }
''
+ ''
# currently pie is only enabled by default in pkgsMusl # currently pie is only enabled by default in pkgsMusl
# this will respect the `hardening{Disable,Enable}` flags if set # this will respect the `hardening{Disable,Enable}` flags if set
@ -197,12 +260,15 @@ let
fi fi
runHook postConfigure runHook postConfigure
''); ''
);
buildPhase = args.buildPhase or ( buildPhase =
args.buildPhase or (
lib.warnIf (buildFlags != "" || buildFlagsArray != "") lib.warnIf (buildFlags != "" || buildFlagsArray != "")
"`buildFlags`/`buildFlagsArray` are deprecated and will be removed in the 24.11 release. Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`" "`buildFlags`/`buildFlagsArray` are deprecated and will be removed in the 24.11 release. Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
lib.warnIf (builtins.elem "-buildid=" ldflags) lib.warnIf
(builtins.elem "-buildid=" ldflags)
"`-buildid=` is set by default as ldflag by buildGoModule" "`-buildid=` is set by default as ldflag by buildGoModule"
'' ''
runHook preBuild runHook preBuild
@ -265,7 +331,8 @@ let
echo "Building subPackage $pkg" echo "Building subPackage $pkg"
buildGoDir install "$pkg" buildGoDir install "$pkg"
done done
'' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' ''
+ lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
# normalize cross-compiled builds w.r.t. native builds # normalize cross-compiled builds w.r.t. native builds
( (
dir=$GOPATH/bin/${go.GOOS}_${go.GOARCH} dir=$GOPATH/bin/${go.GOOS}_${go.GOARCH}
@ -276,12 +343,15 @@ let
rmdir $dir rmdir $dir
fi fi
) )
'' + '' ''
+ ''
runHook postBuild runHook postBuild
''); ''
);
doCheck = args.doCheck or true; doCheck = args.doCheck or true;
checkPhase = args.checkPhase or '' checkPhase =
args.checkPhase or ''
runHook preCheck runHook preCheck
# We do not set trimpath for tests, in case they reference test assets # We do not set trimpath for tests, in case they reference test assets
export GOFLAGS=''${GOFLAGS//-trimpath/} export GOFLAGS=''${GOFLAGS//-trimpath/}
@ -293,7 +363,8 @@ let
runHook postCheck runHook postCheck
''; '';
installPhase = args.installPhase or '' installPhase =
args.installPhase or ''
runHook preInstall runHook preInstall
mkdir -p $out mkdir -p $out
@ -307,12 +378,20 @@ let
disallowedReferences = lib.optional (!allowGoReference) go; disallowedReferences = lib.optional (!allowGoReference) go;
passthru = passthru // { inherit go hugo hugoModules vendorHash; }; passthru = passthru // {
inherit
go
hugo
hugoModules
vendorHash
;
};
meta = { meta = {
# Add default meta information # Add default meta information
platforms = go.meta.platforms or lib.platforms.all; platforms = go.meta.platforms or lib.platforms.all;
} // meta; } // meta;
}); }
);
in in
package package

View File

@ -1,7 +1,9 @@
let let
sources = import ../../npins; sources = import ../../npins;
in in
{ pkgs ? import sources.nixos-unstable { } }: {
pkgs ? import sources.nixos-unstable { },
}:
let let
docs = import ../. { inherit pkgs; }; docs = import ../. { inherit pkgs; };

View File

@ -2,38 +2,53 @@
# We're already using the Nix projects through pinning with npins. # We're already using the Nix projects through pinning with npins.
{ {
description = "wrapper-manager-fds flake"; description = "wrapper-manager-fds flake";
outputs = { ... }: let outputs =
{ ... }:
let
sources = import ./npins; sources = import ./npins;
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [
eachSystem = systems: f: "x86_64-linux"
"aarch64-linux"
];
eachSystem =
systems: f:
let let
# Merge together the outputs for all systems. # Merge together the outputs for all systems.
op = attrs: system: op =
attrs: system:
let let
ret = f system; ret = f system;
op = attrs: key: attrs // op =
{ attrs: key:
${key} = (attrs.${key} or { }) attrs
// { ${system} = ret.${key}; }; // {
} ${key} = (attrs.${key} or { }) // {
; ${system} = ret.${key};
};
};
in in
builtins.foldl' op attrs (builtins.attrNames ret); builtins.foldl' op attrs (builtins.attrNames ret);
in in
builtins.foldl' op { } builtins.foldl' op { } (
(systems systems
++ # add the current system if --impure is used # add the current system if --impure is used
(if builtins?currentSystem then ++ (
if builtins.elem builtins.currentSystem systems if builtins ? currentSystem then
then [] if builtins.elem builtins.currentSystem systems then [ ] else [ builtins.currentSystem ]
else [ builtins.currentSystem ]
else else
[])); [ ]
in import ./. { } // (eachSystem systems (system: let )
);
in
import ./. { }
// (eachSystem systems (
system:
let
pkgs = import sources.nixos-unstable { inherit system; }; pkgs = import sources.nixos-unstable { inherit system; };
tests = import ./tests { inherit pkgs; }; tests = import ./tests { inherit pkgs; };
docs = import ./docs { inherit pkgs; }; docs = import ./docs { inherit pkgs; };
in { in
{
devShells = { devShells = {
default = import ./shell.nix { inherit pkgs; }; default = import ./shell.nix { inherit pkgs; };
website = import ./docs/website/shell.nix { inherit pkgs; }; website = import ./docs/website/shell.nix { inherit pkgs; };
@ -46,5 +61,6 @@
}; };
checks.wrapperManagerLibrarySetPkg = tests.libTestPkg; checks.wrapperManagerLibrarySetPkg = tests.libTestPkg;
})); }
));
} }

View File

@ -9,10 +9,15 @@
# module. # module.
{ pkgs }: { pkgs }:
pkgs.lib.makeExtensible pkgs.lib.makeExtensible (
(self: self:
let let
callLibs = file: import file { inherit (pkgs) lib; inherit pkgs self; }; callLibs =
file:
import file {
inherit (pkgs) lib;
inherit pkgs self;
};
in in
{ {
env = import ./env.nix; env = import ./env.nix;
@ -20,5 +25,5 @@ pkgs.lib.makeExtensible
inherit (self.env) build eval; inherit (self.env) build eval;
inherit (self.utils) getBin getLibexec; inherit (self.utils) getBin getLibexec;
}) }
)

View File

@ -1,12 +1,13 @@
rec { rec {
/* Given the attrset for evaluating a wrapper-manager module, return a /*
Given the attrset for evaluating a wrapper-manager module, return a
derivation containing the wrapper. derivation containing the wrapper.
*/ */
build = args: build = args: (eval args).config.build.toplevel;
(eval args).config.build.toplevel;
/* Evaluate a wrapper-manager configuration. */ # Evaluate a wrapper-manager configuration.
eval = { eval =
{
pkgs, pkgs,
lib ? pkgs.lib, lib ? pkgs.lib,
modules ? [ ], modules ? [ ],
@ -20,9 +21,12 @@ rec {
# Setting pkgs modularly. This would make setting up wrapper-manager # Setting pkgs modularly. This would make setting up wrapper-manager
# with different nixpkgs instances possible but it isn't something that # with different nixpkgs instances possible but it isn't something that
# is explicitly supported. # is explicitly supported.
({ lib, ... }: { (
{ lib, ... }:
{
config._module.args.pkgs = lib.mkDefault pkgs; config._module.args.pkgs = lib.mkDefault pkgs;
}) }
)
] ++ modules; ] ++ modules;
}; };
} }

View File

@ -1,31 +1,31 @@
{ pkgs, lib, self }: {
pkgs,
lib,
self,
}:
rec { rec {
/* /*
Given a list of derivations, return a list of the store path with the `bin` Given a list of derivations, return a list of the store path with the `bin`
output (or at least with "/bin" in each of the paths). output (or at least with "/bin" in each of the paths).
*/ */
getBin = drvs: getBin = drvs: builtins.map (v: lib.getBin v) drvs;
builtins.map (v: lib.getBin v) drvs;
/* /*
Given a list of derivations, return a list of the store paths with the Given a list of derivations, return a list of the store paths with the
`libexec` appended. `libexec` appended.
*/ */
getLibexec = drvs: getLibexec = drvs: builtins.map (v: "${v}/libexec") drvs;
builtins.map (v: "${v}/libexec") drvs;
/* /*
Given a list of derivations, return a list of the store paths appended with Given a list of derivations, return a list of the store paths appended with
`/etc/xdg` suitable as part of the XDG_CONFIG_DIRS environment variable. `/etc/xdg` suitable as part of the XDG_CONFIG_DIRS environment variable.
*/ */
getXdgConfigDirs = drvs: getXdgConfigDirs = drvs: builtins.map (v: "${v}/etc/xdg") drvs;
builtins.map (v: "${v}/etc/xdg") drvs;
/* /*
Given a list of derivations, return a list of store paths appended with Given a list of derivations, return a list of store paths appended with
`/share` suitable as part of the XDG_DATA_DIRS environment variable. `/share` suitable as part of the XDG_DATA_DIRS environment variable.
*/ */
getXdgDataDirs = drvs: getXdgDataDirs = drvs: builtins.map (v: "${v}/share") drvs;
builtins.map (v: "${v}/share") drvs;
} }

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.wrapper-manager; cfg = config.wrapper-manager;
@ -10,9 +15,12 @@ let
modules = [ modules = [
../wrapper-manager ../wrapper-manager
({ lib, ... }: { (
{ lib, ... }:
{
config._module.args.pkgs = lib.mkDefault pkgs; config._module.args.pkgs = lib.mkDefault pkgs;
}) }
)
] ++ cfg.sharedModules; ] ++ cfg.sharedModules;
}; };
in in

View File

@ -1,13 +1,16 @@
{ config, lib, pkgs, ... }@moduleArgs: {
config,
lib,
pkgs,
...
}@moduleArgs:
let let
cfg = config.wrapper-manager; cfg = config.wrapper-manager;
wmDocs = import ../../../docs { inherit pkgs; }; wmDocs = import ../../../docs { inherit pkgs; };
in in
{ {
imports = [ imports = [ ../common.nix ];
../common.nix
];
config = lib.mkMerge [ config = lib.mkMerge [
{ {
@ -20,17 +23,19 @@ in
(lib.mkIf (moduleArgs ? nixosConfig) { (lib.mkIf (moduleArgs ? nixosConfig) {
wrapper-manager.sharedModules = [ wrapper-manager.sharedModules = [
({ lib, ... }: { (
{ lib, ... }:
{
# NixOS already has the option to set the locale so we don't need to # NixOS already has the option to set the locale so we don't need to
# have this. # have this.
config.locale.enable = lib.mkDefault false; config.locale.enable = lib.mkDefault false;
}) }
)
]; ];
}) })
(lib.mkIf (cfg.packages != {}) { (lib.mkIf (cfg.packages != { }) {
home.packages = home.packages = lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) cfg.packages;
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) cfg.packages;
}) })
] ; ];
} }

View File

@ -1,13 +1,16 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.wrapper-manager; cfg = config.wrapper-manager;
wmDocs = import ../../../docs { inherit pkgs; }; wmDocs = import ../../../docs { inherit pkgs; };
in in
{ {
imports = [ imports = [ ../common.nix ];
../common.nix
];
config = lib.mkMerge [ config = lib.mkMerge [
{ {
@ -18,17 +21,19 @@ in
wrapper-manager.extraSpecialArgs.nixosConfig = config; wrapper-manager.extraSpecialArgs.nixosConfig = config;
wrapper-manager.sharedModules = [ wrapper-manager.sharedModules = [
({ lib, ... }: { (
{ lib, ... }:
{
# NixOS already has the option to set the locale so we don't need to # NixOS already has the option to set the locale so we don't need to
# have this. # have this.
config.locale.enable = lib.mkDefault false; config.locale.enable = lib.mkDefault false;
}) }
)
]; ];
} }
(lib.mkIf (cfg.packages != {}) { (lib.mkIf (cfg.packages != { }) {
environment.systemPackages = environment.systemPackages = lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) cfg.packages;
lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) cfg.packages;
}) })
]; ];
} }

View File

@ -1,13 +1,29 @@
{ config, lib, options, ... }: {
config,
lib,
options,
...
}:
let let
envConfig = config; envConfig = config;
toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str; toStringType = with lib.types; coercedTo anything (x: builtins.toString x) str;
envSubmodule = { config, lib, name, ... }: { envSubmodule =
{
config,
lib,
name,
...
}:
{
options = { options = {
action = lib.mkOption { action = lib.mkOption {
type = lib.types.enum [ "unset" "set" "set-default" ]; type = lib.types.enum [
"unset"
"set"
"set-default"
];
description = '' description = ''
Sets the appropriate action for the environment variable. Sets the appropriate action for the environment variable.
@ -34,7 +50,14 @@ let
}; };
}; };
wrapperType = { name, lib, config, pkgs, ... }: wrapperType =
{
name,
lib,
config,
pkgs,
...
}:
let let
flagType = with lib.types; listOf toStringType; flagType = with lib.types; listOf toStringType;
in in
@ -118,28 +141,36 @@ let
env = envConfig.environment.variables; env = envConfig.environment.variables;
pathAdd = envConfig.environment.pathAdd; pathAdd = envConfig.environment.pathAdd;
makeWrapperArgs = [ makeWrapperArgs =
"--argv0" config.arg0 [
"--argv0"
config.arg0
] ]
++ (lib.mapAttrsToList ++ (lib.mapAttrsToList (
(n: v: n: v:
if v.action == "unset" if v.action == "unset" then
then "--${v.action} ${lib.escapeShellArg n}" "--${v.action} ${lib.escapeShellArg n}"
else "--${v.action} ${lib.escapeShellArg n} ${if v.isEscaped then lib.escapeShellArg v.value else v.value}") else
config.env) "--${v.action} ${lib.escapeShellArg n} ${
if v.isEscaped then lib.escapeShellArg v.value else v.value
}"
) config.env)
++ (builtins.map (v: "--add-flags ${lib.escapeShellArg v}") config.prependArgs) ++ (builtins.map (v: "--add-flags ${lib.escapeShellArg v}") config.prependArgs)
++ (builtins.map (v: "--append-flags ${lib.escapeShellArg v}") config.appendArgs) ++ (builtins.map (v: "--append-flags ${lib.escapeShellArg v}") config.appendArgs)
++ (lib.optionals (!envConfig.build.isBinary && config.preScript != "") ( ++ (lib.optionals (!envConfig.build.isBinary && config.preScript != "") (
let let
preScript = preScript =
pkgs.runCommand "wrapper-script-prescript-${config.executableName}" { } config.preScript; pkgs.runCommand "wrapper-script-prescript-${config.executableName}" { }
config.preScript;
in in
[ "--run" preScript ])); [
"--run"
preScript
]
));
} }
(lib.mkIf (config.pathAdd != [ ]) { (lib.mkIf (config.pathAdd != [ ]) { env.PATH.value = lib.concatStringsSep ":" config.pathAdd; })
env.PATH.value = lib.concatStringsSep ":" config.pathAdd;
})
]; ];
}; };
in in

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ {
options.build = { options.build = {
@ -48,25 +53,22 @@
build = { build = {
toplevel = toplevel =
let let
mkWrapBuild = wrappers: mkWrapBuild =
wrappers:
lib.concatMapStrings (v: '' lib.concatMapStrings (v: ''
makeWrapper "${v.arg0}" "${builtins.placeholder "out"}/bin/${v.executableName}" ${lib.concatStringsSep " " v.makeWrapperArgs} makeWrapper "${v.arg0}" "${builtins.placeholder "out"}/bin/${v.executableName}" ${lib.concatStringsSep " " v.makeWrapperArgs}
'') wrappers; '') wrappers;
mkDesktopEntries = desktopEntries: mkDesktopEntries = desktopEntries: builtins.map (entry: pkgs.makeDesktopItem entry) desktopEntries;
builtins.map (entry: pkgs.makeDesktopItem entry) desktopEntries;
desktopEntries = desktopEntries = mkDesktopEntries (lib.attrValues config.xdg.desktopEntries);
mkDesktopEntries (lib.attrValues config.xdg.desktopEntries);
in in
pkgs.symlinkJoin { pkgs.symlinkJoin {
passthru = config.build.extraPassthru; passthru = config.build.extraPassthru;
name = "wrapper-manager-fds-wrapped-package"; name = "wrapper-manager-fds-wrapped-package";
paths = desktopEntries ++ config.basePackages; paths = desktopEntries ++ config.basePackages;
nativeBuildInputs = nativeBuildInputs =
if config.build.isBinary if config.build.isBinary then [ pkgs.makeBinaryWrapper ] else [ pkgs.makeWrapper ];
then [ pkgs.makeBinaryWrapper ]
else [ pkgs.makeWrapper ];
postBuild = '' postBuild = ''
${config.build.extraSetup} ${config.build.extraSetup}
${mkWrapBuild (lib.attrValues config.wrappers)} ${mkWrapBuild (lib.attrValues config.wrappers)}

View File

@ -1,17 +1,30 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.locale; cfg = config.locale;
localeModuleFactory = { isGlobal ? false }: { localeModuleFactory =
{
isGlobal ? false,
}:
{
enable = lib.mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = if isGlobal then true else cfg.enable; default = if isGlobal then true else cfg.enable;
example = false; example = false;
description = if isGlobal then '' description =
if isGlobal then
''
Whether to enable explicit glibc locale support. This is recommended Whether to enable explicit glibc locale support. This is recommended
for Nix-built applications. for Nix-built applications.
'' else '' ''
else
''
Whether to enable locale support for this wrapper. Recommended for Whether to enable locale support for this wrapper. Recommended for
Nix-built applications. Nix-built applications.
''; '';
@ -19,10 +32,7 @@ let
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = default = if isGlobal then (pkgs.glibcLocales.override { allLocales = true; }) else cfg.package;
if isGlobal
then (pkgs.glibcLocales.override { allLocales = true; })
else cfg.package;
description = '' description = ''
The package containing glibc locales. The package containing glibc locales.
''; '';
@ -34,9 +44,17 @@ in
options.wrappers = options.wrappers =
let let
localeSubmodule = { config, lib, name, ... }: let localeSubmodule =
{
config,
lib,
name,
...
}:
let
submoduleCfg = config.locale; submoduleCfg = config.locale;
in { in
{
options.locale = localeModuleFactory { isGlobal = false; }; options.locale = localeModuleFactory { isGlobal = false; };
config = lib.mkIf submoduleCfg.enable { config = lib.mkIf submoduleCfg.enable {
@ -44,7 +62,5 @@ in
}; };
}; };
in in
lib.mkOption { lib.mkOption { type = with lib.types; attrsOf (submodule localeSubmodule); };
type = with lib.types; attrsOf (submodule localeSubmodule);
};
} }

View File

@ -1,10 +1,22 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
# We're only setting up options for the most common keys typically used to # We're only setting up options for the most common keys typically used to
# set up a desktop entry. Everything else is acceptable under a freeform # set up a desktop entry. Everything else is acceptable under a freeform
# module anyways. # module anyways.
xdgDesktopEntry = { name, lib, pkgs, ... }: { xdgDesktopEntry =
{
name,
lib,
pkgs,
...
}:
{
freeformType = with lib.types; attrsOf anything; freeformType = with lib.types; attrsOf anything;
options = { options = {
@ -47,14 +59,20 @@ let
type = with lib.types; listOf nonEmptyStr; type = with lib.types; listOf nonEmptyStr;
description = "List of categories should the application be shown in a menu."; description = "List of categories should the application be shown in a menu.";
default = [ ]; default = [ ];
example = [ "Applications" "Network" ]; example = [
"Applications"
"Network"
];
}; };
mimeTypes = lib.mkOption { mimeTypes = lib.mkOption {
type = with lib.types; listOf nonEmptyStr; type = with lib.types; listOf nonEmptyStr;
description = "The MIME types supported by the application."; description = "The MIME types supported by the application.";
default = [ ]; default = [ ];
example = [ "text/html" "text/xml" ]; example = [
"text/html"
"text/xml"
];
}; };
}; };
}; };
@ -89,10 +107,16 @@ in
options.wrappers = lib.mkOption { options.wrappers = lib.mkOption {
type = type =
let let
xdgDesktopEntryWrapperSubmodule = { name, config, lib, ... }: { xdgDesktopEntryWrapperSubmodule =
{
name,
config,
lib,
...
}:
{
options.xdg.desktopEntry = { options.xdg.desktopEntry = {
enable = enable = lib.mkEnableOption "automatic creation of a desktop entry for the wrapper";
lib.mkEnableOption "automatic creation of a desktop entry for the wrapper";
settings = lib.mkOption { settings = lib.mkOption {
type = lib.types.submodule xdgDesktopEntry; type = lib.types.submodule xdgDesktopEntry;
description = '' description = ''
@ -126,7 +150,8 @@ in
}; };
}; };
in in
with lib.types; attrsOf (submodule xdgDesktopEntryWrapperSubmodule); with lib.types;
attrsOf (submodule xdgDesktopEntryWrapperSubmodule);
}; };
config = { config = {

View File

@ -41,7 +41,14 @@ in
options.wrappers = lib.mkOption { options.wrappers = lib.mkOption {
type = type =
let let
xdgDirsType = { name, lib, config, ... }: { xdgDirsType =
{
name,
lib,
config,
...
}:
{
options.xdg = xdgDirsOption; options.xdg = xdgDirsOption;
config = lib.mkMerge [ config = lib.mkMerge [
@ -61,6 +68,7 @@ in
]; ];
}; };
in in
with lib.types; attrsOf (submodule xdgDirsType); with lib.types;
attrsOf (submodule xdgDirsType);
}; };
} }

View File

@ -1,7 +1,9 @@
let let
sources = import ./npins; sources = import ./npins;
in in
{ pkgs ? import sources.nixos-unstable { } }: {
pkgs ? import sources.nixos-unstable { },
}:
let let
docs = import ./docs { inherit pkgs; }; docs = import ./docs { inherit pkgs; };
@ -12,7 +14,7 @@ pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
npins npins
treefmt treefmt
nixpkgs-fmt nixfmt-rfc-style
# For easy validation of the test suite. # For easy validation of the test suite.
yajsv yajsv

View File

@ -1,13 +1,13 @@
let let
sources = import ../../npins; sources = import ../../npins;
in in
{ pkgs ? import sources.nixos-unstable { } }: {
pkgs ? import sources.nixos-unstable { },
}:
let let
wmLib = (import ../../. { }).lib; wmLib = (import ../../. { }).lib;
build = modules: wmLib.build { build = modules: wmLib.build { inherit pkgs modules; };
inherit pkgs modules;
};
in in
{ {
fastfetch = build [ ./wrapper-fastfetch.nix ]; fastfetch = build [ ./wrapper-fastfetch.nix ];

View File

@ -1,17 +1,27 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ {
wrappers.fastfetch = { wrappers.fastfetch = {
arg0 = lib.getExe' pkgs.fastfetch "fastfetch"; arg0 = lib.getExe' pkgs.fastfetch "fastfetch";
appendArgs = [ "--logo" "Guix" ]; appendArgs = [
"--logo"
"Guix"
];
env.NO_COLOR.value = "1"; env.NO_COLOR.value = "1";
xdg.desktopEntry.enable = true; xdg.desktopEntry.enable = true;
}; };
build.extraPassthru.tests = { build.extraPassthru.tests = {
actuallyBuilt = let actuallyBuilt =
let
wrapper = config.build.toplevel; wrapper = config.build.toplevel;
in pkgs.runCommand "wrapper-manager-fastfetch-actually-built" { } '' in
pkgs.runCommand "wrapper-manager-fastfetch-actually-built" { } ''
[ -e "${wrapper}/share/applications/fastfetch.desktop" ] && [ -x "${wrapper}/bin/${config.wrappers.fastfetch.executableName}" ] && touch $out [ -e "${wrapper}/share/applications/fastfetch.desktop" ] && [ -x "${wrapper}/bin/${config.wrappers.fastfetch.executableName}" ] && touch $out
''; '';
}; };

View File

@ -1,20 +1,31 @@
{ config, lib, pkgs, yourMomName, ... }: {
config,
lib,
pkgs,
yourMomName,
...
}:
{ {
wrappers.neofetch = { wrappers.neofetch = {
arg0 = lib.getExe' pkgs.neofetch "neofetch"; arg0 = lib.getExe' pkgs.neofetch "neofetch";
executableName = yourMomName; executableName = yourMomName;
appendArgs = [ appendArgs = [
"--ascii_distro" "guix" "--ascii_distro"
"--title_fqdn" "off" "guix"
"--os_arch" "off" "--title_fqdn"
"off"
"--os_arch"
"off"
]; ];
}; };
build.extraPassthru.tests = { build.extraPassthru.tests = {
actuallyBuilt = let actuallyBuilt =
let
wrapper = config.build.toplevel; wrapper = config.build.toplevel;
in pkgs.runCommand "wrapper-manager-neofetch-actually-built" { } '' in
pkgs.runCommand "wrapper-manager-neofetch-actually-built" { } ''
[ -x "${wrapper}/bin/${config.wrappers.fastfetch.executableName}" ] && touch $out [ -x "${wrapper}/bin/${config.wrappers.fastfetch.executableName}" ] && touch $out
''; '';
}; };

View File

@ -1,7 +1,9 @@
let let
sources = import ../npins; sources = import ../npins;
in in
{ pkgs ? import sources.nixos-unstable { } }: {
pkgs ? import sources.nixos-unstable { },
}:
let let
lib = import ./lib { inherit pkgs; }; lib = import ./lib { inherit pkgs; };
@ -9,11 +11,16 @@ in
{ {
inherit lib; inherit lib;
libTestPkg = libTestPkg =
pkgs.runCommand "wrapper-manager-fds-lib-test" { pkgs.runCommand "wrapper-manager-fds-lib-test"
{
testData = builtins.toJSON lib; testData = builtins.toJSON lib;
passAsFile = [ "testData" ]; passAsFile = [ "testData" ];
nativeBuildInputs = with pkgs; [ yajsv jq ]; nativeBuildInputs = with pkgs; [
} '' yajsv
jq
];
}
''
yajsv -s "${./lib/tests.schema.json}" "$testDataPath" && touch $out || jq . "$testDataPath" yajsv -s "${./lib/tests.schema.json}" "$testDataPath" && touch $out || jq . "$testDataPath"
''; '';
} }

View File

@ -2,8 +2,11 @@
let let
lib = import ../../lib { inherit pkgs; }; lib = import ../../lib { inherit pkgs; };
callLib = file: import file { callLib =
inherit (pkgs) lib; inherit pkgs; file:
import file {
inherit (pkgs) lib;
inherit pkgs;
self = lib; self = lib;
}; };
in in

View File

@ -1,4 +1,8 @@
{ pkgs, lib, self }: {
pkgs,
lib,
self,
}:
let let
neofetchWrapper = ../../configs/wrapper-neofetch.nix; neofetchWrapper = ../../configs/wrapper-neofetch.nix;

View File

@ -1,4 +1,8 @@
{ pkgs, lib, self }: {
pkgs,
lib,
self,
}:
lib.runTests { lib.runTests {
testsUtilsGetBin = { testsUtilsGetBin = {