mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-26 02:05:02 +00:00
writers.makeDataWriter: remove
This writer was deprecated in 2023 (e64f987fd6)
and is unused in nixpkgs. Time to remove it.
This commit is contained in:
@@ -72,6 +72,8 @@
|
||||
|
||||
- `alps` has been rewritten upstream, see [upstream repository](https://github.com/migadu/alps) for documentation.
|
||||
|
||||
- `writers.makeDataWriter` has been removed. It has been deprecated since 2023. Use `pkgs.writeTextFile` instead.
|
||||
|
||||
- `bosun` has been removed as it is no longer maintained upstream. the corresponding monitoring options has been removed.
|
||||
|
||||
- `uhttpmock` providing 0.0 ABI was removed. `uhttpmock_1_0` providing 1.0 ABI was renamed to `uhttpmock` and `uhttpmock_1_0` was kept as an alias.
|
||||
|
||||
@@ -12,55 +12,7 @@ let
|
||||
;
|
||||
in
|
||||
{
|
||||
/**
|
||||
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
|
||||
(types.path.check nameOrPath)
|
||||
|| (builtins.match "([0-9A-Za-z._])[0-9A-Za-z._-]*" nameOrPath != null);
|
||||
let
|
||||
name = last (builtins.split "/" nameOrPath);
|
||||
in
|
||||
runCommand name
|
||||
{
|
||||
input = input data;
|
||||
passAsFile = [ "input" ];
|
||||
}
|
||||
''
|
||||
${output}
|
||||
|
||||
${optionalString (types.path.check nameOrPath) ''
|
||||
mv $out tmp
|
||||
mkdir -p $out/$(dirname "${nameOrPath}")
|
||||
mv tmp $out/${nameOrPath}
|
||||
''}
|
||||
''
|
||||
);
|
||||
makeDataWriter = throw "pkgs.writers.makeDataWriter has been removed. Use pkgs.writeTextFile instead.";
|
||||
|
||||
inherit (pkgs) writeText;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user