Commit graph

16021 commits

Author SHA1 Message Date
Robert Hensing e838ac98d4 doc/glossary: Nix expression can be language expression 2024-01-13 19:42:05 +01:00
Qyriad cbd5553d57
doc: provide context in glossary definitions (#9378) 2024-01-13 12:20:08 +01:00
John Ericson e739a5002d Avoid Windows macros in the parser and lexer
`FLOAT`, `INT`, and `IN` are identifers taken by macros.

The name `IN_KW` is chosen to match `OR_KW`, which is presumably named
that way for the same reason of dodging macros.
2024-01-12 19:51:36 -05:00
John Ericson 381df7b9c9
Merge pull request #9756 from obsidiansystems/readline-on-windows
Newer Nixpkgs, get `readline` on Windows
2024-01-12 19:49:50 -05:00
John Ericson dd7e7b0a30 Newer Nixpkgs, get readline on Windows
Now `nix repl` an, in principle, work on that platform too.

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/2c9c58e98243930f8cb70387934daa4bc8b00373' (2023-12-31)
  → 'github:NixOS/nixpkgs/86501af7f1d51915e6c335f90f2cab73d7704ef3' (2024-01-11)
2024-01-12 19:19:21 -05:00
John Ericson 3bc1f8f22f
Merge pull request #9752 from 9999years/hacking-filter-tests
Document unit tests in hacking.md
2024-01-12 19:00:19 -05:00
Robert Hensing 15f7bdaf27 CanonPath: Add rel_c_str()
Defensively because isRoot() is also defensive.
2024-01-12 22:55:37 +01:00
Rebecca Turner f73e50144f
Clarify ambiguity in nix-instantiate man page 2024-01-12 13:53:45 -08:00
Rebecca Turner 2d96c7a51f
Remove outdated reference to y in nix-instantiate man page 2024-01-12 11:27:31 -08:00
Rebecca Turner b29be1ff57
Document unit tests in hacking.md 2024-01-12 10:47:49 -08:00
John Ericson c58da62a06
Merge pull request #9737 from obsidiansystems/sys-error-split
Separate `SystemError` from `SysError`
2024-01-12 12:41:36 -05:00
Mel Zuser 1996105e91 added test for empty substring special case 2024-01-12 09:40:21 -08:00
John Ericson 6208ca7209 Separate SystemError from SysError
Most of this is a `catch SysError` -> `catch SystemError` sed. This
is a rather pure-churn change I would like to get out of the way. **The
intersting part is `src/libutil/error.hh`.**

On Unix, we will only throw the `SysError` concrete class, which has
the same constructors that `SystemError` used to have.

On Windows, we will throw `WinError` *and* `SysError`. `WinError`
(which will be created in a later PR), will use a `DWORD` instead of
`int` error value, and `GetLastError()`, which is the Windows equivalent
of the `errno` machinery. Windows will *also* use `SysError` because
Window's "libc" (MSVCRT) implements the POSIX interface, and we use it
too.

As the docs describe, while we *throw* one of the 3 choices above (2
concrete classes or the alias), we should always *catch* `SystemError`.
This ensures no matter how the implementation changes for Windows (e.g.
between `SysError` and `WinError`) the catching logic stays the same
and stays correct.

Co-Authored-By volth <volth@volth.com>
Co-Authored-By Eugene Butler <eugene@eugene4.com>
2024-01-12 12:00:33 -05:00
Mel Zuser 25c889baac Fix performance of builtins.substring for empty substrings
When returning a 0-length substring, avoid calling coerceToString,
since it returns a string_view with the string's length, which is
expensive to compute for large strings.
2024-01-12 08:37:04 -08:00
Robert Hensing 274d887fee fetchTree/git: Cache export-ignore filter 2024-01-12 17:18:56 +01:00
Robert Hensing d80c582b78 libfetchers: Add CachingFilteringInputAccessor
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2024-01-12 17:16:59 +01:00
Eelco Dolstra 52f949bbf5
Merge pull request #9656 from edolstra/nix-profile-stable-names
Make profile element names stable
2024-01-12 16:59:36 +01:00
Eelco Dolstra 72560f7bbe Add profile migration test 2024-01-12 16:33:15 +01:00
Eelco Dolstra 8c7e2ed77c Update release notes 2024-01-12 16:21:07 +01:00
Robert Hensing f68ad5acbb fetchTree/git: Don't expose exportIgnore attr 2024-01-12 16:05:36 +01:00
Robert Hensing 469cf263c7 Format 2024-01-12 15:31:53 +01:00
Robert Hensing 692e9197bc fetchTree: Disallow combination of submodules and exportIgnore for now 2024-01-12 15:31:53 +01:00
Robert Hensing 71d08af15b rl-next: Add *general* note about git fetcher reimpl 2024-01-12 15:31:53 +01:00
Robert Hensing 99bd12f0b1 fetchGit/fetchTree: Improve exportIgnore, submodule interaction
Also fingerprint and some preparatory improvements.

Testing is still not up to scratch because lots of logic is duplicated
between the workdir and commit cases.
2024-01-12 15:31:53 +01:00
Robert Hensing 1bbe837184 fetchTree: Add isFetchGit exportIgnore 2024-01-12 15:31:53 +01:00
Robert Hensing 7774eff10e libfetchers/git: Move workdir accessor into GitRepo::getAccessor 2024-01-12 15:31:53 +01:00
Robert Hensing 8024b954d7 fetchTree: Recommend against exportIgnore 2024-01-12 15:31:53 +01:00
Robert Hensing 467c62a96e GitRepoImpl: Move exportIgnore into a filtering accessor 2024-01-12 15:31:53 +01:00
Robert Hensing cd5e752fa7 GitRepoImpl::getSubmodules: Access getSubmoduleRev without cast
This will be needed because the accessor will be wrapped, and therefore
not be an instance of GitInputAccessor anymore.
2024-01-12 15:31:53 +01:00
Robert Hensing f6b1d15580 MakeNotAllowedError: Touch up doc 2024-01-12 15:31:53 +01:00
Robert Hensing 1c6bb609af fetchTree: allow larger output attrsets
Intentionally dumb change ahead of architectural improvements.
2024-01-12 15:31:53 +01:00
Robert Hensing ce6d58a97c git fetcher: Add exportIgnore parameter
Enabled for fetchGit, which historically had this behavior,
among other behaviors we do not want in fetchGit.

fetchTree disables this parameter by default. It can choose the
simpler behavior, as it is still experimental.

I am not confident that the filtering implementation is future
proof. It should reuse a source filtering wrapper, which I believe
Eelco has already written, but not merged yet.
2024-01-12 15:31:52 +01:00
DavHau 4d0ecda33e fetchTree/fetchGit: add test for .gitattributes
...with the intention to prevent future regressions in fetchGit
2024-01-12 15:31:52 +01:00
Eelco Dolstra 0d55d660d5
Merge pull request #8043 from bobvanderlinden/pr-shell-env
nix: develop: use SHELL from rc script
2024-01-12 13:42:42 +01:00
Eelco Dolstra e21b3cf9db Merge remote-tracking branch 'origin/master' into nix-profile-stable-names 2024-01-12 13:36:27 +01:00
Robert Hensing be6c86038b
Merge pull request #9606 from 9999years/printer
Support limiting attributes and list items in value printing to support detailed errors
2024-01-12 13:27:56 +01:00
Eelco Dolstra 7c6f093abc .data() -> .c_str() to be on the safe side 2024-01-12 13:00:53 +01:00
Eelco Dolstra 66bd1b0298 Merge remote-tracking branch 'origin/master' into pr-shell-env 2024-01-12 12:56:26 +01:00
Eelco Dolstra 3e23759834 gc-non-blocking.sh: Add explanation
Also name the _NIX_TEST_GC_SYNC environment variables logically.
2024-01-12 12:38:55 +01:00
Eelco Dolstra 5703c31325 Merge remote-tracking branch 'origin/master' into handle-missing-gc-socket 2024-01-12 12:26:25 +01:00
Eelco Dolstra cd5fd5cbf3
Merge pull request #9719 from jlesquembre/clang-format-config
Add clang format configuration
2024-01-12 12:19:00 +01:00
Eelco Dolstra 1acb1e0ca3
Merge pull request #9742 from obsidiansystems/mingw-makefiles
More makefile preparations for Windows
2024-01-12 12:11:48 +01:00
John Ericson 90fdbfc601 Build Windows DLLs with -Wl,--export-all-symbols
This is not the most elegant, but will match the SOs in exporting
everything for now. Later we can refine what is public/private to clean
up the interface.
2024-01-11 23:34:37 -05:00
John Ericson af0345df36 makefiles: Do some HOST_CYGWIN -> HOST_WINDOWS
These bits are not Cygwin-specific.
2024-01-11 23:28:11 -05:00
John Ericson 34bb6dcab1 makefiles: Support .exe executable prefix on Windows 2024-01-11 23:28:11 -05:00
Rebecca Turner df84dd4d8d
Restore ambiguous value printer for nix-instantiate
The Nix team has requested that this output format remain unchanged.
I've added a warning to the man page explaining that `nix-instantiate
--eval` output will not parse correctly in many situations.
2024-01-11 16:34:36 -08:00
Rebecca Turner 0fa08b4516
Unify and refactor value printing
Previously, there were two mostly-identical value printers -- one in
`libexpr/eval.cc` (which didn't force values) and one in
`libcmd/repl.cc` (which did force values and also printed ANSI color
codes).

This PR unifies both of these printers into `print.cc` and provides a
`PrintOptions` struct for controlling the output, which allows for
toggling whether values are forced, whether repeated values are tracked,
and whether ANSI color codes are displayed.

Additionally, `PrintOptions` allows tuning the maximum number of
attributes, list items, and bytes in a string that will be displayed;
this makes it ideal for contexts where printing too much output (e.g.
all of Nixpkgs) is distracting. (As requested by @roberth in
https://github.com/NixOS/nix/pull/9554#issuecomment-1845095735)

Please read the tests for example output.

Future work:
- It would be nice to provide this function as a builtin, perhaps
  `builtins.toStringDebug` -- a printing function that never fails would
  be useful when debugging Nix code.
- It would be nice to support customizing `PrintOptions` members on the
  command line, e.g. `--option to-string-max-attrs 1000`.
2024-01-11 16:34:36 -08:00
Rebecca Turner c9125603a5
Unindent print.hh declarations 2024-01-11 16:07:01 -08:00
John Ericson a38e6b9087
Merge pull request #9745 from obsidiansystems/fix-install-unit-tests-cond
packages.nix: Fix `installUnitTests` condition
2024-01-11 17:11:27 -05:00
John Ericson a923444a94 packages.nix: Fix installUnitTests condition
The intent was we install the tests when we can *not* run them. Instead,
we were installing them when we can.
2024-01-11 16:39:56 -05:00