I want to have thunar with flags and plugins overridden.
As of v24.11, plugins can be added to Thunar using programs.thunar.plugins
when enabled with programs.thunar.enable
. (NixOS Search)
But the build flags or package option are not exposed in the derivation used with programs.thunar
(nixpkgs/nixos/modules/programs/thunar.nix at 666e1b3f09c267afd66addebe80fb05a5ef2b554 · NixOS/nixpkgs · GitHub)
The build flags are present in the thunar
package (nixpkgs/pkgs/desktops/xfce/core/thunar/default.nix at 666e1b3f09c267afd66addebe80fb05a5ef2b554 · NixOS/nixpkgs · GitHub) and have to be overridden there.
To add flags, this is what I updated in the programs.thunar
derivation
--- a/thunar.nix
+++ b/thunar.nix
@@ -6,8 +6,8 @@
}:
let
- cfg = config.programs.thunar;
+ cfg = config.programs.thunar-with-flags;
in
{
meta = {
@@ -15,7 +15,7 @@ in
};
options = {
- programs.thunar = {
+ programs.thunar-with-flags = {
enable = lib.mkEnableOption "Thunar, the Xfce file manager";
plugins = lib.mkOption {
@@ -25,13 +25,25 @@ in
example = lib.literalExpression "with pkgs.xfce; [ thunar-archive-plugin thunar-volman ]";
};
+ configureFlags = lib.mkOption {
+ default = [ ];
+ type = lib.types.listOf lib.types.str;
+ description = "List of flags to pass to the Thunar build.";
+ example = lib.literalExpression ''
+ [ "--disable-wallpaper-plugin" ]
+ '';
+ };
};
};
config = lib.mkIf cfg.enable (
let
- package = pkgs.xfce.thunar.override { thunarPlugins = cfg.plugins; };
-
+ packageWithPlugins = pkgs.xfce.thunar.override {
+ thunarPlugins = cfg.plugins;
+ };
+ package = packageWithPlugins.overrideAttrs (oldAttrs: {
+ configureFlags = (oldAttrs.configureFlags or [ ]) ++ cfg.configureFlags;
+ });
in
{
environment.systemPackages = [
and updated my configuration.nix accordingly
programs.thunar-with-flags = {
enable = true;
plugins = with pkgs.xfce; [
thunar-archive-plugin
];
configureFlags = [ "--disable-wallpaper-plugin" ];
};
Sadly this doesn’t work. In the build, plugins are there, but thunar is not built against given flags.
But the strange behavior is if I do not try to override with plugins, it is built against the proper flags, and ofcourse plugins are not there.
--- b/thunar.nix
+++ c/thunar.nix
@@ -38,9 +38,7 @@ in
config = lib.mkIf cfg.enable (
let
- packageWithPlugins = pkgs.xfce.thunar.override {
- thunarPlugins = cfg.plugins;
- };
+ packageWithPlugins = pkgs.xfce.thunar;
package = packageWithPlugins.overrideAttrs (oldAttrs: {
configureFlags = (oldAttrs.configureFlags or [ ]) ++ cfg.configureFlags;
});
I want to build with both plugins and flags overridden, but can’t understand the behavior.
How I’m getting to know if the build flag is correct or not?
I pass the flag
--disable-wallpaper-plugin
using the above mentioned custom derivation, it is supposed to disable the context menu option “Set as wallpaper” for image files inside thunar. If the option is absent, build flags are working fine.
How I’m getting to know if plugins are there?
I use
thunar-archive-plugin
which adds a context menu to extract compressed file. If it is present plugins are working fine. (Also I can see a packagethunar-archive-plugin
andthunar-with-plugins
being added in nix log)