aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-05-08configure: Look for gtestEelco Dolstra
2020-05-08Don't install unit testsEelco Dolstra
2020-05-08make check: Run unit testsEelco Dolstra
2020-05-08Fix warningEelco Dolstra
2020-05-08Move unit tests to sr/libutil/tests, use mk make rulesEelco Dolstra
2020-05-07Drop unnecessary std::stringTobias Pflug
2020-05-07Remove replaceInSetTobias Pflug
The function isn't being used anywhere so it seems safe to remove
2020-05-07Use ASSERT_EQ instead of ASSERT_STREQTobias Pflug
No need to use `c_str()` in combination with `ASSERT_STREQ`. It's possible to just use ASSERT_EQ on std::string
2020-05-06WIP: add unit tests for libutilTobias Pflug
This is a proof on concept to evaluate writing unit tests for Nix using google test (https://github.com/google/googletest). In order to execute tests: $ make unit-tests $ ./unit-tests The Makefile rules for `unit-tests` is a complete hack.
2020-05-06Merge pull request #3546 from guibou/nix_readfile_on_0_sized_filesEelco Dolstra
builtins.readFile: do not truncate content
2020-05-06Merge pull request #3557 from Ma27/nix-repl-helpEelco Dolstra
Improve help-message for nix-repl
2020-05-06Merge pull request #3562 from pikajude/masterEelco Dolstra
Use fragment size for autoGC capacity calculation
2020-05-06Revert "Merge pull request #3558 from LnL7/ssh-ng-stderr"Eelco Dolstra
This reverts commit 3ebfbecdd187002569257f7cb183bf9e0b39af1e, reversing changes made to c089c52d5f1cff888552f485775b74226dcbe618. https://github.com/NixOS/nix/pull/3558
2020-05-05nix doctor: ConsistencyEelco Dolstra
2020-05-05nix --help: Group commandsEelco Dolstra
2020-05-04nix auto-gc: use fragment sizeJude Taylor
2020-05-04Flag: Use designated initializersEelco Dolstra
2020-05-04precompiled-headers.h: Don't include our own headersEelco Dolstra
2020-05-04Merge pull request #3558 from LnL7/ssh-ng-stderrEelco Dolstra
remote-store: don't log raw stderr by default
2020-05-02logging: handle build log lines in simple loggerDaiderd Jordan
The raw stderr output isn't logged anymore so the build logs need to be printed by the default logger in order for the old commands like nix-build to still show build output.
2020-05-02remote-store: don't log raw stderr by defaultDaiderd Jordan
For remote stores the log messages are already forwarded as structured STDERR_RESULT messages so the old format is duplicate information. But still included with -vvv since it could be useful for debugging problems. $ nix build -L /nix/store/nl71b2niws857ffiaggyrkjwgx9jjzc0-foo.drv --store ssh-ng://localhost Hello World! foo> Hello World! [1/0/1 built] building foo Fixes #3556
2020-05-01Improve help-message for nix-replMaximilian Bosch
* Remove obsolete `printHelp` function * Add an example to demonstrate how to list all available commands within the REPL
2020-05-01Fix buildEelco Dolstra
2020-05-01rename run to shell in testsMatthew Kenigsberg
(cherry picked from commit f459ca547fda4b0ca477d895413e86b69a580ab0)
2020-05-01rename nix run to nix shell and nix app to nix runMatthew Kenigsberg
(cherry picked from commit 5d8504b9789ffebabe8226227c4061dd48354177)
2020-05-01Fix coverage jobEelco Dolstra
(cherry picked from commit bc5d4843a916dc4f99516e187a63108e8006f81f)
2020-05-01Tweak README.mdEelco Dolstra
2020-05-01Merge pull request #3552 from gilligan/revamp-readmeDomen Kožar
Revamp README.md
2020-05-01Update README.mdDomen Kožar
2020-05-01Update README.mdDomen Kožar
Co-authored-by: worldofpeace <worldofpeace@protonmail.ch>
2020-05-01Update README.mdDomen Kožar
Co-authored-by: worldofpeace <worldofpeace@protonmail.ch>
2020-04-30Revamp README.mdTobias Pflug
2020-04-30Update issue templatesDomen Kožar
2020-04-30Update issue templatesDomen Kožar
2020-04-30nix dev-shell: Unset shellHookEelco Dolstra
This avoids inheriting the caller's shellHook, which can happen when running a dev-shell inside a dev-shell.
2020-04-30nix dev-shell: Support structured attrsEelco Dolstra
Tested against https://github.com/NixOS/nixpkgs/pull/72074. Fixes #3540.
2020-04-30nix dev-shell: Refactor script for getting the environmentEelco Dolstra
2020-04-30Merge pull request #3548 from Ma27/fetchtarball-posDomen Kožar
Fix displaying error-position in `builtins.fetch{Tree,Tarball}`
2020-04-29Fix displaying error-position in `builtins.fetch{Tree,Tarball}`Maximilian Bosch
Without dereferencing this pointer, you'd get an error like this: ``` error: unsupported argument 'abc' to 'fetchTarball', at 0x13627e8 ```
2020-04-29StringSink pre allocateGuillaume Bouchard
When used with `readFile`, we have a pretty good heuristic of the file size, so `reserve` this in the `string`. This will save some allocation / copy when the string is growing.
2020-04-29Remove the `drain` argument from `readFile`Guillaume Bouchard
Now it is always `drain` (see previous commit).
2020-04-29Merge pull request #3547 from nlewo/grantptEelco Dolstra
Only call grantpt on MacOS systems
2020-04-29Only call grantpt on MacOS systemsAntoine Eiche
The commit 3cc1125595d97b4ab7369e37e4ad22f4cfecb8b2 adds a `grantpt` call on the builder pseudo terminal fd. This call is actually only required for MacOS, but it however requires a RW access to /dev/pts which is only RO bindmounted in the Bazel Linux sandbox. So, Nix can not be actually run in the Bazel Linux sandbox for unneeded reasons.
2020-04-29builtins.readFile: do not truncate contentGuillaume Bouchard
This closes #3026 by allowing `builtins.readFile` to read a file with a wrongly reported file size, for example, files in `/proc` may report a file size of 0. Reading file in `/proc` is not a good enough motivation, however I do think it just makes nix more robust by allowing more file to be read. Especially, I do considerer the previous behavior to be dangerous because nix was previously reading truncated files. Examples of file system which incorrectly report file size may be network file system or dynamic file system (for performance reason, a dynamic file system such as FUSE may generate the content of the file on demand). ``` nix-repl> builtins.readFile "/proc/version" "" ``` With this commit: ``` nix-repl> builtins.readFile "/proc/version" "Linux version 5.6.7 (nixbld@localhost) (gcc version 9.3.0 (GCC)) #1-NixOS SMP Thu Apr 23 08:38:27 UTC 2020\n" ``` Here is a summary of the behavior changes: - If the reported size is smaller, previous implementation was silently returning a truncated file content. The new implementation is returning the correct file content. - If a file had a bigger reported file size, previous implementation was failing with an exception, but the new implementation is returning the correct file content. This change of behavior is coherent with this pull request. Open questions - The behavior is unchanged for correctly reported file size, however performances may vary because it uses the more complex sink interface. Considering that sink is used a lot, I don't think this impacts the performance a lot. - `builtins.readFile` on an infinite file, such as `/dev/random` may fill the memory. - it does not support adding file to store, such as `${/proc/version}`.
2020-04-28Merge pull request #3542 from mkenigs/gcrootsEelco Dolstra
Set GCROOT to store path to prevent garbage collection
2020-04-28rename to NIX_GCROOTMatthew Kenigsberg
2020-04-28Tweak warning messageEelco Dolstra
2020-04-28Merge branch 'nix-env-warn-unmatched' of https://github.com/lheckemann/nixEelco Dolstra
2020-04-28Merge pull request #3541 from alyssais/gcdosEelco Dolstra
Fix long paths permanently breaking GC
2020-04-27Fix long paths permanently breaking GCAlyssa Ross
Suppose I have a path /nix/store/[hash]-[name]/a/a/a/a/a/[...]/a, long enough that everything after "/nix/store/" is longer than 4096 (MAX_PATH) bytes. Nix will happily allow such a path to be inserted into the store, because it doesn't look at all the nested structure. It just cares about the /nix/store/[hash]-[name] part. But, when the path is deleted, we encounter a problem. Nix will move the path to /nix/store/trash, but then when it's trying to recursively delete the trash directory, it will at some point try to unlink /nix/store/trash/[hash]-[name]/a/a/a/a/a/[...]/a. This will fail, because the path is too long. After this has failed, any store deletion operation will never work again, because Nix needs to delete the trash directory before recreating it to move new things to it. (I assume this is because otherwise a path being deleted could already exist in the trash, and then moving it would fail.) This means that if I can trick somebody into just fetching a tarball containing a path of the right length, they won't be able to delete store paths or garbage collect ever again, until the offending path is manually removed from /nix/store/trash. (And even fixing this manually is quite difficult if you don't understand the issue, because the absolute path that Nix says it failed to remove is also too long for rm(1).) This patch fixes the issue by making Nix's recursive delete operation use unlinkat(2). This function takes a relative path and a directory file descriptor. We ensure that the relative path is always just the name of the directory entry, and therefore its length will never exceed 255 bytes. This means that it will never even come close to AX_PATH, and Nix will therefore be able to handle removing arbitrarily deep directory hierachies. Since the directory file descriptor is used for recursion after being used in readDirectory, I made a variant of readDirectory that takes an already open directory stream, to avoid the directory being opened multiple times. As we have seen from this issue, the less we have to interact with paths, the better, and so it's good to reuse file descriptors where possible. I left _deletePath as succeeding even if the parent directory doesn't exist, even though that feels wrong to me, because without that early return, the linux-sandbox test failed. Reported-by: Alyssa Ross <hi@alyssa.is> Thanks-to: Puck Meerburg <puck@puckipedia.com> Tested-by: Puck Meerburg <puck@puckipedia.com> Reviewed-by: Puck Meerburg <puck@puckipedia.com>