lol

writers/data.nix: Remove duplicate implementations

+9 -23
+6 -22
pkgs/build-support/writers/data.nix
··· 1 - { lib, runCommand, dasel }: 1 + { lib, pkgs, formats, runCommand, dasel }: 2 2 let 3 3 daselBin = lib.getExe dasel; 4 4 ··· 40 40 mkdir -p $out/$(dirname "${nameOrPath}") 41 41 mv tmp $out/${nameOrPath} 42 42 ''} 43 - ''; 43 + ''); 44 44 45 - # Writes the content to text. 46 - # 47 - # Example: 48 - # writeText "filename.txt" "file content" 49 - writeText = makeDataWriter { 50 - input = toString; 51 - output = "cp $inputPath $out"; 52 - }; 45 + inherit (pkgs) writeText; 53 46 54 47 # Writes the content to a JSON file. 55 48 # 56 49 # Example: 57 50 # writeJSON "data.json" { hello = "world"; } 58 - writeJSON = makeDataWriter { 59 - input = builtins.toJSON; 60 - output = "${daselBin} -f $inputPath -r json -w json > $out"; 61 - }; 51 + writeJSON = (pkgs.formats.json {}).generate; 62 52 63 53 # Writes the content to a TOML file. 64 54 # 65 55 # Example: 66 56 # writeTOML "data.toml" { hello = "world"; } 67 - writeTOML = makeDataWriter { 68 - input = builtins.toJSON; 69 - output = "${daselBin} -f $inputPath -r json -w toml > $out"; 70 - }; 57 + writeTOML = (pkgs.formats.toml {}).generate; 71 58 72 59 # Writes the content to a YAML file. 73 60 # 74 61 # Example: 75 62 # writeYAML "data.yaml" { hello = "world"; } 76 - writeYAML = makeDataWriter { 77 - input = builtins.toJSON; 78 - output = "${daselBin} -f $inputPath -r json -w yaml > $out"; 79 - }; 63 + writeYAML = (pkgs.formats.yaml {}).generate; 80 64 }
+3 -1
pkgs/build-support/writers/test.nix
··· 261 261 262 262 toml = expectDataEqual { 263 263 file = writeTOML "data.toml" { hello = "world"; }; 264 - expected = "hello = 'world'\n"; 264 + expected = '' 265 + hello = "world" 266 + ''; 265 267 }; 266 268 267 269 yaml = expectDataEqual {