From 587fcc7b89cda8abbbd1f08722b2b3e1349869c8 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sat, 13 Feb 2021 23:30:40 +0100 Subject: pkgs/sternenseemann/temp: add tiny temporary file/dir crate The crate implements a safe wrapper around mkdtemp(3) and mkstemp(3) which provide decent temporary file and directory creation. The key feature we provide is that we wrap the resulting path in a TempFile / TempDir struct. This allows us to implement the Drop trait such that the temporary directory / file is automatically deleted when the value goes out of scope in Rust which saves the programmer from cleaning up temporary artifacts themselves. The API is indeed very tiny currently, only implementing creation and AsRef which should allow all necessary path / file manipulation. --- pkgs/sternenseemann/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pkgs/sternenseemann/default.nix') diff --git a/pkgs/sternenseemann/default.nix b/pkgs/sternenseemann/default.nix index 23845195..8ee48ce5 100644 --- a/pkgs/sternenseemann/default.nix +++ b/pkgs/sternenseemann/default.nix @@ -33,6 +33,12 @@ let }; }; + rust = callPackage ./rust { + inherit (profpatsch) + writeRustSimpleLib + ; + }; + in lib.fix (self: { @@ -75,6 +81,11 @@ lib.fix (self: { ''; }); + inherit (rust) + temp + temp-tests + ; + # don't bother hydra with trivial text substitution scripts = dontRecurseIntoAttrs (callPackage ./scripts { inherit (writers) writeBashBin; -- cgit 1.4.1