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

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

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
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.
*/
build = args:
(eval args).config.build.toplevel;
build = args: (eval args).config.build.toplevel;
/* Evaluate a wrapper-manager configuration. */
eval = {
# Evaluate a wrapper-manager configuration.
eval =
{
pkgs,
lib ? pkgs.lib,
modules ? [ ],
@ -20,9 +21,12 @@ rec {
# Setting pkgs modularly. This would make setting up wrapper-manager
# with different nixpkgs instances possible but it isn't something that
# is explicitly supported.
({ lib, ... }: {
(
{ lib, ... }:
{
config._module.args.pkgs = lib.mkDefault pkgs;
})
}
)
] ++ modules;
};
}

View File

@ -1,31 +1,31 @@
{ pkgs, lib, self }:
{
pkgs,
lib,
self,
}:
rec {
/*
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).
*/
getBin = drvs:
builtins.map (v: lib.getBin v) drvs;
getBin = drvs: builtins.map (v: lib.getBin v) drvs;
/*
Given a list of derivations, return a list of the store paths with the
`libexec` appended.
*/
getLibexec = drvs:
builtins.map (v: "${v}/libexec") drvs;
getLibexec = drvs: builtins.map (v: "${v}/libexec") drvs;
/*
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.
*/
getXdgConfigDirs = drvs:
builtins.map (v: "${v}/etc/xdg") drvs;
getXdgConfigDirs = drvs: builtins.map (v: "${v}/etc/xdg") drvs;
/*
Given a list of derivations, return a list of store paths appended with
`/share` suitable as part of the XDG_DATA_DIRS environment variable.
*/
getXdgDataDirs = drvs:
builtins.map (v: "${v}/share") drvs;
getXdgDataDirs = drvs: builtins.map (v: "${v}/share") drvs;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,22 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
# 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
# module anyways.
xdgDesktopEntry = { name, lib, pkgs, ... }: {
xdgDesktopEntry =
{
name,
lib,
pkgs,
...
}:
{
freeformType = with lib.types; attrsOf anything;
options = {
@ -47,14 +59,20 @@ let
type = with lib.types; listOf nonEmptyStr;
description = "List of categories should the application be shown in a menu.";
default = [ ];
example = [ "Applications" "Network" ];
example = [
"Applications"
"Network"
];
};
mimeTypes = lib.mkOption {
type = with lib.types; listOf nonEmptyStr;
description = "The MIME types supported by the application.";
default = [ ];
example = [ "text/html" "text/xml" ];
example = [
"text/html"
"text/xml"
];
};
};
};
@ -89,10 +107,16 @@ in
options.wrappers = lib.mkOption {
type =
let
xdgDesktopEntryWrapperSubmodule = { name, config, lib, ... }: {
xdgDesktopEntryWrapperSubmodule =
{
name,
config,
lib,
...
}:
{
options.xdg.desktopEntry = {
enable =
lib.mkEnableOption "automatic creation of a desktop entry for the wrapper";
enable = lib.mkEnableOption "automatic creation of a desktop entry for the wrapper";
settings = lib.mkOption {
type = lib.types.submodule xdgDesktopEntry;
description = ''
@ -126,7 +150,8 @@ in
};
};
in
with lib.types; attrsOf (submodule xdgDesktopEntryWrapperSubmodule);
with lib.types;
attrsOf (submodule xdgDesktopEntryWrapperSubmodule);
};
config = {

View File

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

View File

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

View File

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

View File

@ -1,17 +1,27 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
wrappers.fastfetch = {
arg0 = lib.getExe' pkgs.fastfetch "fastfetch";
appendArgs = [ "--logo" "Guix" ];
appendArgs = [
"--logo"
"Guix"
];
env.NO_COLOR.value = "1";
xdg.desktopEntry.enable = true;
};
build.extraPassthru.tests = {
actuallyBuilt = let
actuallyBuilt =
let
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
'';
};

View File

@ -1,20 +1,31 @@
{ config, lib, pkgs, yourMomName, ... }:
{
config,
lib,
pkgs,
yourMomName,
...
}:
{
wrappers.neofetch = {
arg0 = lib.getExe' pkgs.neofetch "neofetch";
executableName = yourMomName;
appendArgs = [
"--ascii_distro" "guix"
"--title_fqdn" "off"
"--os_arch" "off"
"--ascii_distro"
"guix"
"--title_fqdn"
"off"
"--os_arch"
"off"
];
};
build.extraPassthru.tests = {
actuallyBuilt = let
actuallyBuilt =
let
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
'';
};

View File

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

View File

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

View File

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

View File

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