linkIntoOwnPackage: allow passing extra named arguments

This commit is contained in:
2025-07-22 21:47:35 +00:00
parent 52261d5bc3
commit e32c9d42d9
5 changed files with 13 additions and 11 deletions

View File

@@ -2,10 +2,7 @@
# - `fftest /dev/input/by-path/platform-vibrator-event`
{ pkgs, ... }:
let
# fftestOnly = pkgs.linkIntoOwnPackage linuxConsoleTools [
# "bin/fftest"
# "share/man/man1/fftest.1.gz"
# ];
# fftestOnly = pkgs.linkBinIntoOwnPackage linuxConsoleTools "fftest";
#
# XXX(2025-03-24): upstream `linuxConsoleTools` depends on SDL, which doesn't cross compile.
# but `fftest` component doesn't use SDL, so if we build only that then it can cross compile:

View File

@@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
sane.programs.where-am-i = {
# packageUnwrapped = pkgs.linkIntoOwnPackage config.sane.programs.geoclue2.packageUnwrapped "libexec/geoclue-2.0/demos/where-am-i";
# packageUnwrapped = pkgs.linkIntoOwnPackage config.sane.programs.geoclue2.packageUnwrapped "libexec/geoclue-2.0/demos/where-am-i" {};
packageUnwrapped = (pkgs.linkFarm "where-am-i" [{
# bring the `where-am-i` tool into a `bin/` directory so it can be invokable via PATH
name = "bin/where-am-i";

View File

@@ -7,7 +7,7 @@
packageUnwrapped = pkgs.linkIntoOwnPackage pkgs.wireshark [
"bin/wireshark"
"share"
];
] {};
sandbox.autodetectCliPaths = "existingFile"; #< for loading pcap files on CLI
sandbox.whitelistWayland = true;

View File

@@ -8,7 +8,7 @@
"bin/Zelda64Recompiled"
"share/applications"
"share/icons"
];
] {};
sandbox.whitelistAudio = true;
sandbox.whitelistDri = true;
sandbox.whitelistWayland = true;

View File

@@ -15,6 +15,8 @@
dontUnpack = true;
buildPhase = lib.concatStringsSep "\n" [
"runHook preConfigure"
"runHook postConfigure"
"runHook preBuild"
buildPhase
"runHook postBuild"
@@ -37,16 +39,19 @@
done
'';
linkIntoOwnPackage = pkg: path: let
linkIntoOwnPackage = pkg: path: { wantMan ? null, ...}@args: let
paths = if lib.isList path then path else [ path ];
suffix = (lib.head paths) + (if paths != [ path ] then "-and-other-paths" else "");
bin = lib.getBin pkg;
man = lib.getMan pkg;
out = pkg;
wantMan = builtins.any (p: lib.hasPrefix "share/man" p || lib.hasPrefix "share/doc" p) paths;
wantMan' = if wantMan == null then
builtins.any (p: lib.hasPrefix "share/man" p || lib.hasPrefix "share/doc" p) paths
else
wantMan;
in
runCommandLocalOverridable "${pkg.pname or pkg.name}-${suffix}" {
outputs = [ "out" ] ++ lib.optionals wantMan [ "man" ];
outputs = [ "out" ] ++ lib.optionals wantMan' [ "man" ];
} ''
tryLink() {
local srcPath="$1/$2"
@@ -77,7 +82,7 @@
paths = if lib.isList path' then path else [ path' ]; #< coerce to list
paths' = (lib.map (p: "bin/${p}") paths) ++ [ "share/doc" "share/man" ];
in
linkIntoOwnPackage pkg paths'
linkIntoOwnPackage pkg paths' {}
;
deepLinkIntoOwnPackage = pkg: { outputs ? [ "out" ] }: symlinkJoin {