about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/writers/data.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-03-22 16:41:59 +0100
committerAlyssa Ross <hi@alyssa.is>2024-03-22 16:41:59 +0100
commit46a88117a05c3469af5d99433af140c3de8ca088 (patch)
treed7f0557756d8f07a3081b3498c05ddc5a8ad429d /nixpkgs/pkgs/build-support/writers/data.nix
parente97457545cea0b2ca421da257c83d8f1ef451d85 (diff)
parenta343533bccc62400e8a9560423486a3b6c11a23b (diff)
downloadnixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar.gz
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar.bz2
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar.lz
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar.xz
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.tar.zst
nixlib-46a88117a05c3469af5d99433af140c3de8ca088.zip
Merge commit 'a343533bccc62400e8a9560423486a3b6c11a23b'
Diffstat (limited to 'nixpkgs/pkgs/build-support/writers/data.nix')
-rw-r--r--nixpkgs/pkgs/build-support/writers/data.nix81
1 files changed, 51 insertions, 30 deletions
diff --git a/nixpkgs/pkgs/build-support/writers/data.nix b/nixpkgs/pkgs/build-support/writers/data.nix
index 45ed5360eaeb..02f08b9ca0b6 100644
--- a/nixpkgs/pkgs/build-support/writers/data.nix
+++ b/nixpkgs/pkgs/build-support/writers/data.nix
@@ -1,28 +1,34 @@
-{ lib, pkgs, formats, runCommand, dasel }:
+{ lib, pkgs, formats, runCommand }:
 let
-  daselBin = lib.getExe dasel;
-
   inherit (lib)
     last
     optionalString
     types
     ;
 in
-rec {
-  # Creates a transformer function that writes input data to disk, transformed
-  # by both the `input` and `output` arguments.
-  #
-  # Type: makeDataWriter :: input -> output -> nameOrPath -> data -> (any -> string) -> string -> string -> any -> derivation
-  #
-  #   input :: T -> string: function that takes the nix data and returns a string
-  #   output :: string: script that takes the $inputFile and write the result into $out
-  #   nameOrPath :: string: if the name contains a / the files gets written to a sub-folder of $out. The derivation name is the basename of this argument.
-  #   data :: T: the data that will be converted.
-  #
-  # Example:
-  #   writeJSON = makeDataWriter { input = builtins.toJSON; output = "cp $inputPath $out"; };
-  #   myConfig = writeJSON "config.json" { hello = "world"; }
-  #
+{
+  /**
+    Creates a transformer function that writes input data to disk, transformed
+    by both the `input` and `output` arguments.
+
+    # Example
+
+    ```nix
+    writeJSON = makeDataWriter { input = builtins.toJSON; output = "cp $inputPath $out"; };
+    myConfig = writeJSON "config.json" { hello = "world"; }
+    ```
+
+    # Type
+
+    ```
+    makeDataWriter :: input -> output -> nameOrPath -> data -> (any -> string) -> string -> string -> any -> derivation
+
+    input :: T -> string: function that takes the nix data and returns a string
+    output :: string: script that takes the $inputFile and write the result into $out
+    nameOrPath :: string: if the name contains a / the files gets written to a sub-folder of $out. The derivation name is the basename of this argument.
+    data :: T: the data that will be converted.
+    ```
+  */
   makeDataWriter = lib.warn "pkgs.writers.makeDataWriter is deprecated. Use pkgs.writeTextFile." ({ input ? lib.id, output ? "cp $inputPath $out" }: nameOrPath: data:
     assert lib.or (types.path.check nameOrPath) (builtins.match "([0-9A-Za-z._])[0-9A-Za-z._-]*" nameOrPath != null);
     let
@@ -44,21 +50,36 @@ rec {
 
   inherit (pkgs) writeText;
 
-  # Writes the content to a JSON file.
-  #
-  # Example:
-  #   writeJSON "data.json" { hello = "world"; }
+  /**
+    Writes the content to a JSON file.
+
+    # Example
+
+    ```nix
+    writeJSON "data.json" { hello = "world"; }
+    ```
+  */
   writeJSON = (pkgs.formats.json {}).generate;
 
-  # Writes the content to a TOML file.
-  #
-  # Example:
-  #   writeTOML "data.toml" { hello = "world"; }
+  /**
+    Writes the content to a TOML file.
+
+    # Example
+
+    ```nix
+    writeTOML "data.toml" { hello = "world"; }
+    ```
+  */
   writeTOML = (pkgs.formats.toml {}).generate;
 
-  # Writes the content to a YAML file.
-  #
-  # Example:
-  #   writeYAML "data.yaml" { hello = "world"; }
+  /**
+    Writes the content to a YAML file.
+
+    # Example
+
+    ```nix
+    writeYAML "data.yaml" { hello = "world"; }
+    ```
+  */
   writeYAML = (pkgs.formats.yaml {}).generate;
 }