Unverified Commit 30358ab7 authored by Felix Bühler's avatar Felix Bühler Committed by GitHub
Browse files

formats.lua: init; types.luaInline: init (#390120)

parents a84ebe20 2611d5bd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ let
      makeScope makeScopeWithSplicing makeScopeWithSplicing'
      extendMkDerivation;
    inherit (self.derivations) lazyDerivation optionalDrvAttr warnOnInstantiate;
    inherit (self.generators) mkLuaInline;
    inherit (self.meta) addMetaAttrs dontDistribute setName updateName
      appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
      hiPrioSet licensesSpdx getLicenseFromSpdxId getLicenseFromSpdxIdOr
+2 −2
Original line number Diff line number Diff line
@@ -743,6 +743,8 @@ in rec {
      "nil"
    else if isInt v || isFloat v || isString v || isBool v then
      toJSON v
    else if isPath v || isDerivation v then
      toJSON "${v}"
    else if isList v then
      (if v == [ ] then "{}" else
      "{${introSpace}${concatItems (map (value: "${toLua innerArgs value}") v)}${outroSpace}}")
@@ -752,8 +754,6 @@ in rec {
          "(${v.expr})"
        else if v == { } then
          "{}"
        else if isDerivation v then
          ''"${toString v}"''
        else
          "{${introSpace}${concatItems (
            mapAttrsToList (key: value: "[${toJSON key}] = ${toLua innerArgs value}") v
+9 −0
Original line number Diff line number Diff line
@@ -834,6 +834,15 @@ rec {
        };
      };

    # A value produced by `lib.mkLuaInline`
    luaInline = mkOptionType {
      name = "luaInline";
      description = "inline lua";
      descriptionClass = "noun";
      check = x: x._type or null == "lua-inline";
      merge = mergeEqualOption;
    };

    uniq = unique { message = ""; };

    unique = { message }: type: mkOptionType rec {
+7 −0
Original line number Diff line number Diff line
@@ -232,6 +232,13 @@ merging is handled.
    definitions cannot be merged. The regular expression is processed
    using `builtins.match`.

### Specialised types {#sec-option-types-specialised}

`types.luaInline`

:   A string wrapped using `lib.mkLuaInline`. Allows embedding lua expressions
    inline within generated lua. Multiple definitions cannot be merged.

## Submodule types {#sec-option-types-submodule}

Submodules are detailed in [Submodule](#section-option-types-submodule).
+25 −0
Original line number Diff line number Diff line
@@ -402,6 +402,31 @@ have a predefined type and string generator already declared under
    :   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 procude 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
Loading