Nix newbie here, first time posting.
How can I write a lambda which invoke symlinkJoin function and create a package ?
I use hyprland, my scenario is I have multiple electron apps, so I have to wrap every single of them to enable wayland support ( like fcitx5 support ). That brings a lot of duplicated code like:
environment.systemPackage = with pkgs; [
(symlinkJoin {
name = "obsidian";
paths = [ obsidian ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/obsidian \
--add-flags "--ozone-platform-hint=auto" \
--add-flags "--enable-webrtc-pipewire-capturer" \
--add-flags "--enable-features=WaylandWindowDecorations" \
--add-flags "--enable-wayland-ime"
'';
})
]
So I want to write a lambda which can invoke symlinkJoin and create package.
My thought is like this, but it just throws an error. So what’s the proper way to do this?
{ lib, pkgs, ... }:
let
wrap = { appName, appPkg }:
pkgs.symlinkJoin {
name = appName;
paths = [ appPkg ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = lib.strings.concatStrings [
"wrapProgram $out/bin/"
appName
" --add-flags \"--ozone-platform-hint=auto\""
" --add-flags \"--enable-webrtc-pipewire-capturer\""
" --add-flags \"--enable-features=WaylandWindowDecorations\""
" --add-flags \"--enable-wayland-ime\""
];
};
in
{
environment.systemPackages = [
wrap { appName = "ferdium"; appPkg = pkgs.ferdium; }
];
}
… while calling anonymous lambda
at /nix/store/lwyjz70qh12nq6cb7fixl85vryzxqm3c-source/lib/types.nix:538:14:
537| merge = loc: defs:
538| map (x: x.value) (filter (x: x ? value) (concatLists (imap1 (n: def:
| ^
539| imap1 (m: def':
error: A definition for option `environment.systemPackages."[definition 2-entry 1]"' is not of type `package'. Definition values:
- In `/nix/store/xinn8195gqw5h9fa5zlhbyrn2p0ah32d-source/nixos/module/electron.nix': <function, args: {appName, appPkg}>
Not native English speaker, I hope I have expressed myself clearly.