Search code examples
archlinuxmanjaroxz

How to set default params for xz archiver?


By default xz compressor uses single thread (eg. to compress newly created packages from AUR). There's a --threads option for using more threads.

Where can I set global settings for xz so that threads option is set to my value? Could'nt find any info in man.


Solution

  • The man page does talk about the use of environment variables for this purpose:

    ENVIRONMENT
       xz parses space-separated lists of options from the environment variables XZ_DEFAULTS
       and XZ_OPT, in this order, before parsing the options from the  command  line.   Note
       that  only  options  are  parsed  from the environment variables; all non-options are
       silently ignored.  Parsing is done with getopt_long(3) which is  used  also  for  the
       command line arguments.
    
       XZ_DEFAULTS
              User-specific  or  system-wide  default  options.   Typically this is set in a
              shell initialization script to enable xz's memory usage  limiter  by  default.
              Excluding shell initialization scripts and similar special cases, scripts must
              never set or unset XZ_DEFAULTS.
    
       XZ_OPT This is for passing options to xz when it is not possible to set  the  options
              directly  on  the  xz command line.  This is the case e.g. when xz is run by a
              script or tool, e.g. GNU tar(1):
    
                     XZ_OPT=-2v tar caf foo.tar.xz foo
    
              Scripts may use XZ_OPT e.g. to set  script-specific  default  compression  op‐
              tions.   It  is still recommended to allow users to override XZ_OPT if that is
              reasonable, e.g. in sh(1) scripts one may use something like this:
    
                     XZ_OPT=${XZ_OPT-"-7e"}
                     export XZ_OPT
    

    It looks like XZ_DEFAULTS will do what you want.