aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
AgeCommit message (Collapse)Author
2019-12-19tarfile.cc: Restore timestampsEelco Dolstra
This is needed to get the lastModified attribute of GitHub flakes.
2019-12-19tarfile.cc: Don't change the cwdEelco Dolstra
Nix is multithreaded so it's not safe to change the cwd.
2019-12-19tarfile.cc: Style fixesEelco Dolstra
2019-12-19Merge branch 'libarchive' of https://github.com/yorickvP/nixEelco Dolstra
2019-12-17Add priority setting to storesEelco Dolstra
This allows overriding the priority of substituters, e.g. $ nix-store --store ~/my-nix/ -r /nix/store/df3m4da96d84ljzxx4mygfshm1p0r2n3-geeqie-1.4 \ --substituters 'http://cache.nixos.org?priority=100 daemon?priority=10' Fixes #3264.
2019-12-16nix-store -r: Handle symlinks to store pathsEelco Dolstra
Fixes #3270.
2019-12-13Move some codeEelco Dolstra
2019-12-13Don't leak exceptionsEelco Dolstra
2019-12-13Improve gzip error messageEelco Dolstra
2019-12-13Get rid of CBoxEelco Dolstra
2019-12-13Remove FIXMEEelco Dolstra
2019-12-13Initial gzip supportTom Bereknyei
Closes #3256
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-09further clean up libarchive codeYorick van Pelt
2019-12-07Clean up libarchive supportPuck Meerburg
2019-12-07remove rust unpack_tarfile ffiYorick van Pelt
2019-12-07code 'cleanup'Yorick van Pelt
2019-12-07add wrapper function around libarchive to c++ errorsYorick van Pelt
2019-12-07fixup! libarchive proof of conceptYorick van Pelt
2019-12-07libarchive proof of conceptYorick van Pelt
2019-12-05Initialize Command::_nameEelco Dolstra
(cherry picked from commit d0a769cb061a13ad880c76e5ea69a76150439853)
2019-12-05Make subcommand construction in MultiCommand lazyEelco Dolstra
(cherry picked from commit a0de58f471c9087d8e6cc60a6078f9940a125b15)
2019-12-05Move Command and MultiCommand to libutilEelco Dolstra
(cherry picked from commit f70434b1fbbdb0e188718f0c55a8156a7aa08744)
2019-12-05Eliminate more pass-by-value in variadic callsEelco Dolstra
2019-12-05Revert "Make fmt() non-recursive"Eelco Dolstra
This reverts commit 2b761d5f50b7dc17dc55c31980c2253c37b3c920. Also *really* make fmt() take arguments by reference.
2019-12-05fmt(): Pass arguments by reference rather than by valueEelco Dolstra
2019-11-27Fix segfault on i686-linuxEelco Dolstra
https://hydra.nixos.org/build/107467517 Seems that on i686-linux, gcc and rustc disagree on how to return 1-word structs: gcc has the caller pass a pointer to the result, while rustc has the callee return the result in a register. Work around this by using a bare pointer.
2019-11-26Drop remaining uses of external "tar"Eelco Dolstra
Also, fetchGit now runs in O(1) memory since we pipe the output of 'git archive' directly into unpackTarball() (rather than first reading it all into memory).
2019-11-26Move code aroundEelco Dolstra
2019-11-26Move code aroundEelco Dolstra
2019-11-22getEnv(): Return std::optionalEelco Dolstra
This allows distinguishing between an empty value and no value.
2019-11-11Merge pull request #3219 from Ericson2314/semicolonsEelco Dolstra
Fix extra semicolons warnings
2019-11-10Remove unneeded semicolonsJohn Ericson
2019-11-10Fix extra ; warnings involving MakeErrorJohn Ericson
2019-11-08Move editorFor srom libutil to nixEelco Dolstra
libutil should not depend on libexpr.
2019-11-06CleanupEelco Dolstra
2019-11-05Merge branch 'nix-repl-e' of https://github.com/zimbatm/nixEelco Dolstra
2019-11-05Don't use SOCK_CLOEXEC on macOSEelco Dolstra
https://hydra.nixos.org/build/105428308
2019-11-03Fix progress bar when nix-prefetch-url is piped.Harald van Dijk
The intent of the code was that if the window size cannot be determined, it would be treated as having the maximum possible size. Because of a missing assignment, it was actually treated as having a width of 0. The reason the width could not be determined was because it was obtained from stdout, not stderr, even though the printing was done to stderr. This commit addresses both issues.
2019-10-29Move Unix domain socket creation to libutilEelco Dolstra
Also drop multithread-unfriendly hacks like doing a temporary chmod/umask.
2019-10-28editorFor: take a pos object insteadzimbatm
2019-10-27Add O(1)-memory copyPath() functionEelco Dolstra
2019-10-23libutil: add editorFor heuristiczimbatm
2019-10-21Allow content-addressable paths to have referencesEelco Dolstra
This adds a command 'nix make-content-addressable' that rewrites the specified store paths into content-addressable paths. The advantage of such paths is that 1) they can be imported without signatures; 2) they can enable deduplication in cases where derivation changes do not cause output changes (apart from store path hashes). For example, $ nix make-content-addressable -r nixpkgs.cowsay rewrote '/nix/store/g1g31ah55xdia1jdqabv1imf6mcw0nb1-glibc-2.25-49' to '/nix/store/48jfj7bg78a8n4f2nhg269rgw1936vj4-glibc-2.25-49' ... rewrote '/nix/store/qbi6rzpk0bxjw8lw6azn2mc7ynnn455q-cowsay-3.03+dfsg1-16' to '/nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16' We can then copy the resulting closure to another store without signatures: $ nix copy --trusted-public-keys '' ---to ~/my-nix /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 In order to support self-references in content-addressable paths, these paths are hashed "modulo" self-references, meaning that self-references are zeroed out during hashing. Somewhat annoyingly, this means that the NAR hash stored in the Nix database is no longer necessarily equal to the output of "nix hash-path"; for content-addressable paths, you need to pass the --modulo flag: $ nix path-info --json /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 | jq -r .[].narHash sha256:0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 1ggznh07khq0hz6id09pqws3a8q9pn03ya3c03nwck1kwq8rclzs $ nix hash-path --type sha256 --base32 /nix/store/iq6g2x4q62xp7y7493bibx0qn5w7xz67-cowsay-3.03+dfsg1-16 --modulo iq6g2x4q62xp7y7493bibx0qn5w7xz67 0ri611gdilz2c9rsibqhsipbfs9vwcqvs811a52i2bnkhv7w9mgw
2019-10-09nix-env: Create ~/.nix-profile automaticallyEelco Dolstra
2019-10-09Make std::uncaught_exception warning less noisyEelco Dolstra
2019-10-04Revert "std::uncaught_exception() -> std::uncaught_exceptions()"Eelco Dolstra
This reverts commit 6b83174ffffbdfc3f876d94d5178e0b83f675cae because it doesn't work on macOS yet. https://hydra.nixos.org/build/102617587
2019-09-13std::uncaught_exception() -> std::uncaught_exceptions()Eelco Dolstra
The former is deprecated in C++17. Fixes a clang warning.
2019-09-03Add some noexceptsEelco Dolstra
This is to assert that callback functions should never throw (since the context in which they're called may not be able to handle the exception).
2019-09-03Ensure that Callback is called only onceEelco Dolstra
Also, make Callback movable but uncopyable.