Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

wlib.wrapperModules.niri

wrapperModules/n/niri:

“config.kdl”

Configuration file for Niri. See https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction

Type: submodule

Default:

{
  path = <derivation niri.kdl>;
}

Example:

''
  input {
    keyboard {
        numlock
    }
  
    touchpad {
        tap
        natural-scroll
    }
  }
''

Declared by:

“config.kdl”.content

Content of the file. This can be a multi-line string that will be written to the Nix store and made available via the path option.

Type: strings concatenated with “\n”

Declared by:

“config.kdl”.path

The path to the file. By default, this is automatically generated using pkgs.writeText with the attribute name and content.

Type: str|path|drv

Default: "pkgs.writeText name <content>"

Declared by:

settings

Niri configuration settings. See https://yalter.github.io/niri/Configuration%3A-Introduction.html

Type: open submodule of (attribute set)

Default: { }

Declared by:

settings.binds

Bindings of niri

Type: attribute set

Default: { }

Example:

{
  "Mod+0" = {
    focus-workspace = 0;
  };
  "Mod+J" = {
    focus-column-or-monitor-left = null;
  };
  "Mod+N" = {
    spawn = [
      "alacritty"
      "msg"
      "create-windown"
    ];
  };
  "Mod+T" = {
    spawn-sh = "alacritty";
  };
}

Declared by:

settings.extraConfig

Escape hatch string option added to the config file for options that might not be representable otherwise

Type: string

Default: ""

Declared by:

settings.layer-rules

List of layer rules

Type: list of (attribute set)

Default: [ ]

Example:

[
  {
    block-out-from = "screen-capture";
    matches = [
      {
        namespace = "^notifications$";
      }
    ];
    opacity = 0.8;
  }
]

Declared by:

settings.layout

Layout definitions

Type: attribute set

Default: { }

Example:

{
  border = {
    active-color = "#f5c2e7";
    inactive-color = "#313244";
    width = 3;
  };
  focus-ring = {
    off = null;
  };
}

Declared by:

settings.outputs

Output configuration

Type: attribute set

Default: { }

Example:

{
  DP-3 = {
    background-color = "#003300";
    hot-corners = {
      off = null;
    };
  };
}

Declared by:

settings.spawn-at-startup

List of commands to run at startup. The first element in a passed list will be run with the following elements as arguments

Type: list of (string or list of string)

Default: [ ]

Example:

[
  "hello"
  [
    "nix"
    "build"
  ]
]

Declared by:

settings.window-rules

List of window rules

Type: list of (attribute set)

Default: [ ]

Example:

[
  {
    excludes = [
      {
        app-id = "org.keepassxc.KeePassXC";
      }
    ];
    matches = [
      {
        app-id = ".*";
      }
    ];
    open-floating = false;
    open-focused = false;
  }
]

Declared by:

settings.workspaces

Named workspace definitons

Type: attribute set of (null or anything)

Default: { }

Example:

{
  bar = null;
  foo = {
    open-on-output = "DP-3";
  };
}

Declared by:

modules/symlinkScript:

aliases

Aliases for the package to also be added to the PATH

Type: list of string

Default: [ ]

Declared by:

filesToExclude

List of file paths (glob patterns) relative to package root to exclude from the wrapped package. This allows filtering out unwanted binaries or files. Example: [ "bin/unwanted-tool" "share/applications/*.desktop" ]

Type: list of string

Default: [ ]

Declared by:

filesToPatch

List of file paths (glob patterns) relative to package root to patch for self-references. Desktop files are patched by default to update Exec= and Icon= paths.

Type: list of string

Default:

[
  "share/applications/*.desktop"
]

Declared by:

modules/makeWrapper:

addFlag

Wrapper for

–add-flag ARG

Prepend the single argument ARG to the invocation of the executable, before any command-line arguments.

This option takes a list. To group them more strongly, option may take a list of lists as well.

Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }

This will cause it to be added to the DAG.

If no name is provided, it cannot be targeted.

Type: list of spec with main field: `data` of (str|path|drv or list of str|path|drv)

Default: [ ]

Example:

[
  "-v"
  "-f"
  [
    "--config"
    "\${./storePath.cfg}"
  ]
  [
    "-s"
    "idk"
  ]
]

Declared by:

addFlag.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

appendFlag

–append-flag ARG

Append the single argument ARG to the invocation of the executable, after any command-line arguments.

This option takes a list. To group them more strongly, option may take a list of lists as well.

Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }

This will cause it to be added to the DAG.

If no name is provided, it cannot be targeted.

Type: list of spec with main field: `data` of (str|path|drv or list of str|path|drv)

Default: [ ]

Example:

[
  "-v"
  "-f"
  [
    "--config"
    "\${./storePath.cfg}"
  ]
  [
    "-s"
    "idk"
  ]
]

Declared by:

appendFlag.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

argv0

–argv0 NAME

Set the name of the executed process to NAME. If unset or null, defaults to EXECUTABLE.

overrides the setting from argv0type if set.

Type: null or string

Default: null

Declared by:

argv0type

argv0 overrides this option if not null or unset

Both shell and the nix implementations ignore this option, as the shell always resolves $0

However, the binary implementation will use this option

Values:

  • "inherit":

The executable inherits argv0 from the wrapper. Use instead of --argv0 '$0'.

  • "resolve":

If argv0 does not include a “/” character, resolve it against PATH.

  • Function form: str -> str

This one works only in the nix implementation. The others will treat it as inherit

Rather than calling exec, you get the command plus all its flags supplied, and you can choose how to run it.

e.g. command_string: "eval \"$(${command_string})\";

It will also be added to the end of the overall DAL, with the name NIX_RUN_MAIN_PACKAGE

Thus, you can make things run after it, but by default it is still last.

Type: one of “resolve”, “inherit” or function that evaluates to a(n) string

Default: "inherit"

Declared by:

chdir

–chdir DIR

Change working directory before running the executable. Use instead of --run "cd DIR".

Type: list of spec with main field: `data` of str|path|drv

Default: [ ]

Declared by:

chdir.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

env

Environment variables to set in the wrapper.

This option takes a set.

Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }

This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly

Type: attribute set of spec with main field: `data` of str|path|drv

Default: { }

Example:

{
  XDG_DATA_HOME = "/somewhere/on/your/machine";
}

Declared by:

env.<name>.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

envDefault

Environment variables to set in the wrapper.

Like env, but only adds the variable if not already set in the environment.

This option takes a set.

Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null }

This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly

Type: attribute set of spec with main field: `data` of str|path|drv

Default: { }

Example:

{
  XDG_DATA_HOME = "/only/if/not/set";
}

Declared by:

envDefault.<name>.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

escapingFunction

The function to use to escape shell values

Caution: When using shell or binary implementations, these will be expanded at BUILD time.

You should probably leave this as is when using either of those implementations.

However, when using the nix implementation, they will expand at runtime! Which means wlib.escapeShellArgWithEnv may prove to be a useful substitute!

Type: function that evaluates to a(n) string

Default: "lib.escapeShellArg"

Declared by:

extraPackages

Additional packages to add to the wrapper’s runtime PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.

Adds all its entries to the DAG under the name NIX_PATH_ADDITIONS

Type: list of package

Default: [ ]

Declared by:

flagSeparator

Separator between flag names and values when generating args from flags. " " for --flag value or "=" for --flag=value

Type: string

Default: " "

Declared by:

flags

Flags to pass to the wrapper. The key is the flag name, the value is the flag value. If the value is true, the flag will be passed without a value. If the value is false or null, the flag will not be passed. If the value is a list, the flag will be passed multiple times with each value.

This option takes a set.

Any entry can instead be of type { data, before ? [], after ? [], esc-fn ? null, sep ? null }

The sep field may be used to override the value of config.flagSeparator

This will cause it to be added to the DAG, which will cause the resulting wrapper argument to be sorted accordingly

Type: attribute set of spec with main field: `data` of (null or boolean or str|path|drv or list of str|path|drv)

Default: { }

Example:

{
  "--config" = "\${./nixPath}";
}

Declared by:

flags.<name>.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

flags.<name>.sep

A per-item override of the default separator used for flags and their values

Type: null or string

Default: null

Declared by:

prefixContent

[
  [ "ENV" "SEP" "FILE" ]
]

Prefix ENV with contents of FILE and SEP at build time.

Also accepts sets like the other options

[
  [ "ENV" "SEP" "FILE" ]
  { data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]

Type: list of spec with main field: `data` of (List of length 3)

Default: [ ]

Declared by:

prefixContent.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

prefixVar

–prefix ENV SEP VAL

Prefix ENV with VAL, separated by SEP.

Type: list of spec with main field: `data` of (List of length 3)

Default: [ ]

Example:

[
  [
    "LD_LIBRARY_PATH"
    ":"
    "\${lib.makeLibraryPath (with pkgs; [ ... ])}"
  ]
  [
    "PATH"
    ":"
    "\${lib.makeBinPath (with pkgs; [ ... ])}"
  ]
]

Declared by:

prefixVar.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

runShell

–run COMMAND

Run COMMAND before executing the main program.

This option takes a list.

Any entry can instead be of type { data, name ? null, before ? [], after ? [], esc-fn ? null }

This will cause it to be added to the DAG.

If no name is provided, it cannot be targeted.

Type: list of spec with main field: `data` of str|path|drv

Default: [ ]

Declared by:

runShell.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

runtimeLibraries

Additional libraries to add to the wrapper’s runtime LD_LIBRARY_PATH. This is useful if the wrapped program needs additional libraries or tools to function correctly.

Adds all its entries to the DAG under the name NIX_LIB_ADDITIONS

Type: list of package

Default: [ ]

Declared by:

suffixContent

[
  [ "ENV" "SEP" "FILE" ]
]

Suffix ENV with SEP and then the contents of FILE at build time.

Also accepts sets like the other options

[
  [ "ENV" "SEP" "FILE" ]
  { data = [ "ENV" "SEP" "FILE" ]; esc-fn = lib.escapeShellArg; /* name, before, after */ }
]

Type: list of spec with main field: `data` of (List of length 3)

Default: [ ]

Declared by:

suffixContent.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

suffixVar

–suffix ENV SEP VAL

Suffix ENV with VAL, separated by SEP.

Type: list of spec with main field: `data` of (List of length 3)

Default: [ ]

Example:

[
  [
    "LD_LIBRARY_PATH"
    ":"
    "\${lib.makeLibraryPath (with pkgs; [ ... ])}"
  ]
  [
    "PATH"
    ":"
    "\${lib.makeBinPath (with pkgs; [ ... ])}"
  ]
]

Declared by:

suffixVar.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

unsetVar

–unset VAR

Remove VAR from the environment.

Type: list of spec with main field: `data` of string

Default: [ ]

Declared by:

unsetVar.*.esc-fn

A per-item override of the default string escape function

Type: null or (function that evaluates to a(n) string)

Default: null

Declared by:

wrapperImplementation

the nix implementation is the default

It makes the escapingFunction most relevant.

This is because the shell and binary implementations use pkgs.makeWrapper or pkgs.makeBinaryWrapper, and arguments to these functions are passed at BUILD time.

So, generally, when not using the nix implementation, you should always prefer to have escapingFunction set to lib.escapeShellArg.

However, if you ARE using the nix implementation, using wlib.escapeShellArgWithEnv will allow you to use $ expansions, which will expand at runtime.

binary implementation is useful for programs which are likely to be used in “shebangs”, as macos will not allow scripts to be used for these.

However, it is more limited. It does not have access to runShell, prefixContent, and suffixContent options.

Chosing binary will thus cause values in those options to be ignored.

Type: one of “nix”, “shell”, “binary”

Default: "nix"

Declared by: