Home Explore Blog CI



nixpkgs

5th chunk of `nixos/doc/manual/development/settings-options.section.md`
38258e6b1f7ed8b41739fb97d402a09bcc7043f205f2d8cc0000000100000dc8
    :   Input format. Because XML can not be translated one-to-one, we have to use intermediate formats. Possible values:
      - `"badgerfish"`: Uses [badgerfish](http://www.sklar.com/badgerfish/) conversion.

    `withHeader`

    :   Outputs the xml with header.

`pkgs.formats.cdn` { }

:   A function taking an empty attribute set (for future extensibility)
    and returning a set with [CDN](https://github.com/dzikoysk/cdn)-specific
    attributes `type` and `generate` as specified [below](#pkgs-formats-result).

`pkgs.formats.elixirConf { elixir ? pkgs.elixir }`

:   A function taking an attribute set with values

    `elixir`

    :   The Elixir package which will be used to format the generated output

    It returns a set with Elixir-Config-specific attributes `type`, `lib`, and
    `generate` as specified [below](#pkgs-formats-result).

    The `lib` attribute contains functions to be used in settings, for
    generating special Elixir values:

    `mkRaw elixirCode`

    :   Outputs the given string as raw Elixir code

    `mkGetEnv { envVariable, fallback ? null }`

    :   Makes the configuration fetch an environment variable at runtime

    `mkAtom atom`

    :   Outputs the given string as an Elixir atom, instead of the default
        Elixir binary string. Note: lowercase atoms still needs to be prefixed
        with `:`

    `mkTuple array`

    :   Outputs the given array as an Elixir tuple, instead of the default
        Elixir list

    `mkMap attrset`

    :   Outputs the given attribute set as an Elixir map, instead of the
        default Elixir keyword list

`pkgs.formats.lua { asBindings ? false, multiline ? true, columnWidth ? 100, indentWidth ? 2, indentUsingTabs ? false }`

:   A function taking an attribute set with values

    `asBindings` (default `false`)

    :   Whether to treat attributes as variable bindings

    `multiline` (default `true`)

    :   Whether to produce a multiline output. The output may still wrap across
        multiple lines if it would otherwise exceed `columnWidth`.

    `columnWidth` (default `100`)

    :   The column width to use to attempt to wrap lines.

    `indentWidth` (default `2`)

    :   The width of a single indentation level.

    `indentUsingTabs` (default `false`)

    :   Whether the indentation should use tabs instead of spaces.

`pkgs.formats.php { finalVariable }` []{#pkgs-formats-php}

:   A function taking an attribute set with values

    `finalVariable`

    :   The variable that will store generated expression (usually `config`). If set to `null`, generated expression will contain `return`.

    It returns a set with PHP-Config-specific attributes `type`, `lib`, and
    `generate` as specified [below](#pkgs-formats-result).

    The `lib` attribute contains functions to be used in settings, for
    generating special PHP values:

    `mkRaw phpCode`

    :   Outputs the given string as raw PHP code

    `mkMixedArray list set`

    :   Creates PHP array that contains both indexed and associative values. For example, `lib.mkMixedArray [ "hello" "world" ] { "nix" = "is-great"; }` returns `['hello', 'world', 'nix' => 'is-great']`

[]{#pkgs-formats-result}
These functions all return an attribute set with these values:

`type`

:   A module system type representing a value of the format

`lib`

:   Utility functions for convenience, or special interactions with the format.
    This attribute is optional. It may contain inside a `types` attribute
    containing types specific to this format.

Title: More Format Functions: CDN, ElixirConf, Lua, and PHP
Summary
This section details additional format functions in Nix. It describes `pkgs.formats.cdn`, which takes an empty attribute set, and `pkgs.formats.elixirConf`, which uses an Elixir package for formatting, offering functions like `mkRaw`, `mkGetEnv`, `mkAtom`, `mkTuple`, and `mkMap` for special Elixir value generation. `pkgs.formats.lua` allows configuration for variable bindings, multiline output, column width, indentation width, and using tabs for indentation. Lastly, `pkgs.formats.php` defines a `finalVariable` and provides functions like `mkRaw` and `mkMixedArray` for PHP-specific formatting. All these functions return an attribute set with `type` and an optional `lib` attribute, including format-specific types.