mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
wrapper-manager-fds/modules: change basePackages to accept a bare package
This will allow us to make changes to `programs.<name>.package`-type of options found in NixOS, home-manager, etc. but it is expensive at the cost of a rebuild which depends on the package.
This commit is contained in:
parent
d69e61f2a8
commit
7009462c3c
@ -196,14 +196,18 @@ in
|
||||
};
|
||||
|
||||
basePackages = lib.mkOption {
|
||||
type = with lib.types; listOf package;
|
||||
type = with lib.types; either package (listOf package);
|
||||
description = ''
|
||||
A list of packages to be included in the wrapper package.
|
||||
Packages to be included in the wrapper package. However, there are
|
||||
differences in behavior when given certain values.
|
||||
|
||||
::: {.note}
|
||||
This can override some of the binaries included in this list which is
|
||||
typically intended to be used as a wrapped package.
|
||||
:::
|
||||
* When the value is a bare package, the build process will use
|
||||
`$PACKAGE.overrideAttrs` to create the package. This makes it suitable
|
||||
to be used as part of `programs.<name>.package` typically found on
|
||||
other environments (e.g., NixOS).
|
||||
|
||||
* When the value is a list of packages, the build process will use
|
||||
`symlinkJoin` as the builder to create the derivation.
|
||||
'';
|
||||
default = [ ];
|
||||
example = lib.literalExpression ''
|
||||
|
@ -63,17 +63,33 @@
|
||||
|
||||
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 ];
|
||||
postBuild = ''
|
||||
${config.build.extraSetup}
|
||||
${mkWrapBuild (lib.attrValues config.wrappers)}
|
||||
'';
|
||||
};
|
||||
if lib.isList config.basePackages then
|
||||
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 ];
|
||||
postBuild = ''
|
||||
${config.build.extraSetup}
|
||||
${mkWrapBuild (lib.attrValues config.wrappers)}
|
||||
'';
|
||||
}
|
||||
else
|
||||
config.basePackages.overrideAttrs (final: prev: {
|
||||
nativeBuildInputs =
|
||||
(prev.nativeBuildInputs or [ ])
|
||||
++ (if config.build.isBinary then [ pkgs.makeBinaryWrapper ] else [ pkgs.makeWrapper ])
|
||||
++ lib.optionals (config.xdg.desktopEntries != { }) [ pkgs.copyDesktopItems ];
|
||||
desktopItems = (prev.desktopItems or [ ]) ++ desktopEntries;
|
||||
postFixup = ''
|
||||
${prev.postFixup or ""}
|
||||
${mkWrapBuild (lib.attrValues config.wrappers)}
|
||||
'';
|
||||
passthru = lib.recursiveUpdate (prev.passthru or { }) (config.build.extraPassthru // {
|
||||
unwrapped = config.basePackages;
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -12,4 +12,5 @@ in
|
||||
{
|
||||
fastfetch = build [ ./wrapper-fastfetch.nix ];
|
||||
neofetch = build [ ./wrapper-neofetch.nix ];
|
||||
single-basepackage = build [ ./single-basepackage.nix ];
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
basePackages = pkgs.fastfetch;
|
||||
|
||||
wrappers.fastfetch-guix = {
|
||||
arg0 = lib.getExe' pkgs.fastfetch "fastfetch";
|
||||
appendArgs = [
|
||||
"--logo"
|
||||
"Guix"
|
||||
];
|
||||
env.NO_COLOR.value = "1";
|
||||
xdg.desktopEntry.enable = true;
|
||||
};
|
||||
|
||||
build.extraPassthru.tests = {
|
||||
singleBasePackage =
|
||||
let
|
||||
wrapper = config.build.toplevel;
|
||||
in
|
||||
pkgs.runCommand "wrapper-manager-fastfetch-actually-built" { } ''
|
||||
[ -e "${wrapper}/share/applications/fastfetch-guix.desktop" ] && [ -x "${wrapper}/bin/${config.wrappers.fastfetch-guix.executableName}" ] && touch $out
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user