forked from lix-project/lix
Merge changes I0fc80718,Ia182b86f,I355f82cb,I8a9b58fa,Id89f8a1f, ... into main
* changes: tree-wide: fix various lint warnings flake & doxygen: update tagline nix flake metadata: print modified dates for input flakes cli: eat terminal codes from stdout also Implement forcing CLI colour on, and document it better manual: fix a syntax error in redirects.js that made it not do anything misc docs/meson tidying build: implement clang-tidy using our plugin
This commit is contained in:
commit
529eed74c4
|
@ -1,13 +0,0 @@
|
||||||
project('lix-clang-tidy', ['cpp', 'c'],
|
|
||||||
version : '0.1',
|
|
||||||
default_options : ['warning_level=3', 'cpp_std=c++20'])
|
|
||||||
|
|
||||||
llvm = dependency('Clang', version: '>= 14', modules: ['libclang'])
|
|
||||||
sources = files(
|
|
||||||
'HasPrefixSuffix.cc',
|
|
||||||
'LixClangTidyChecks.cc',
|
|
||||||
'FixIncludes.cc',
|
|
||||||
)
|
|
||||||
|
|
||||||
shared_module('lix-clang-tidy', sources,
|
|
||||||
dependencies: llvm)
|
|
|
@ -20,7 +20,7 @@ OUTPUT_DIRECTORY = @docdir@
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
# quick idea about the purpose of the project. Keep the description short.
|
# quick idea about the purpose of the project. Keep the description short.
|
||||||
|
|
||||||
PROJECT_BRIEF = "Nix, the purely functional package manager; unstable internal interfaces"
|
PROJECT_BRIEF = "Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces"
|
||||||
|
|
||||||
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
|
@ -345,7 +345,7 @@ const redirects = {
|
||||||
"linux": "uninstall.html#linux",
|
"linux": "uninstall.html#linux",
|
||||||
"macos": "uninstall.html#macos",
|
"macos": "uninstall.html#macos",
|
||||||
"uninstalling": "uninstall.html",
|
"uninstalling": "uninstall.html",
|
||||||
}
|
},
|
||||||
"contributing/hacking.html": {
|
"contributing/hacking.html": {
|
||||||
"nix-with-flakes": "#building-nix-with-flakes",
|
"nix-with-flakes": "#building-nix-with-flakes",
|
||||||
"classic-nix": "#building-nix",
|
"classic-nix": "#building-nix",
|
||||||
|
|
10
doc/manual/rl-next/clang-tidy-sorta.md
Normal file
10
doc/manual/rl-next/clang-tidy-sorta.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
synopsis: "clang-tidy support"
|
||||||
|
cls: 1697
|
||||||
|
issues: fj#147
|
||||||
|
credits: jade
|
||||||
|
category: Development
|
||||||
|
---
|
||||||
|
|
||||||
|
`clang-tidy` can be used to lint Lix with a limited set of lints using `ninja -C build clang-tidy` and `ninja -C build clang-tidy-fix`.
|
||||||
|
In practice, this fixes the built-in meson rule that was used the same as above being broken ever since precompiled headers were introduced.
|
26
doc/manual/rl-next/clicolor-clarity.md
Normal file
26
doc/manual/rl-next/clicolor-clarity.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
synopsis: "Better usage of colour control environment variables"
|
||||||
|
cls: [1699, 1702]
|
||||||
|
credits: [jade]
|
||||||
|
category: Improvements
|
||||||
|
---
|
||||||
|
|
||||||
|
Lix now heeds `NO_COLOR`/`NOCOLOR` for more output types, such as that used in `nix search`, `nix flake metadata` and similar.
|
||||||
|
|
||||||
|
It also now supports `CLICOLOR_FORCE`/`FORCE_COLOR` to force colours regardless of whether there is a terminal on the other side.
|
||||||
|
|
||||||
|
It now follows rules compatible with those described on <https://bixense.com/clicolors/> with `CLICOLOR` defaulted to enabled.
|
||||||
|
|
||||||
|
That is to say, the following procedure is followed in order:
|
||||||
|
- NO_COLOR or NOCOLOR set
|
||||||
|
|
||||||
|
Always disable colour
|
||||||
|
- CLICOLOR_FORCE or FORCE_COLOR set
|
||||||
|
|
||||||
|
Enable colour
|
||||||
|
- The output is a tty; TERM != "dumb"
|
||||||
|
|
||||||
|
Enable colour
|
||||||
|
- Otherwise
|
||||||
|
|
||||||
|
Disable colour
|
28
doc/manual/rl-next/flake-metadata-time.md
Normal file
28
doc/manual/rl-next/flake-metadata-time.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
synopsis: "`nix flake metadata` prints modified date"
|
||||||
|
cls: 1700
|
||||||
|
credits: jade
|
||||||
|
category: Improvements
|
||||||
|
---
|
||||||
|
|
||||||
|
Ever wonder "gee, when *did* I update nixpkgs"?
|
||||||
|
Wonder no more, because `nix flake metadata` now simply tells you the times every locked flake input was updated:
|
||||||
|
|
||||||
|
```
|
||||||
|
<...>
|
||||||
|
Description: The purely functional package manager
|
||||||
|
Path: /nix/store/c91yi8sxakc2ry7y4ac1smzwka4l5p78-source
|
||||||
|
Revision: c52cff582043838bbe29768e7da232483d52b61d-dirty
|
||||||
|
Last modified: 2024-07-31 22:15:54
|
||||||
|
Inputs:
|
||||||
|
├───flake-compat: github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33
|
||||||
|
│ Last modified: 2023-10-04 06:37:54
|
||||||
|
├───nix2container: github:nlewo/nix2container/3853e5caf9ad24103b13aa6e0e8bcebb47649fe4
|
||||||
|
│ Last modified: 2024-07-10 13:15:56
|
||||||
|
├───nixpkgs: github:NixOS/nixpkgs/e21630230c77140bc6478a21cd71e8bb73706fce
|
||||||
|
│ Last modified: 2024-07-25 11:26:27
|
||||||
|
├───nixpkgs-regression: github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2
|
||||||
|
│ Last modified: 2022-01-24 11:20:45
|
||||||
|
└───pre-commit-hooks: github:cachix/git-hooks.nix/f451c19376071a90d8c58ab1a953c6e9840527fd
|
||||||
|
Last modified: 2024-07-15 04:21:09
|
||||||
|
```
|
|
@ -427,6 +427,7 @@ I grepped `src/` for `get[eE]nv\("` to find the mentions in Lix code.
|
||||||
- `NIX_SHOW_STATS_PATH` - Writes those statistics into a file at the given path instead of stdout. Undocumented.
|
- `NIX_SHOW_STATS_PATH` - Writes those statistics into a file at the given path instead of stdout. Undocumented.
|
||||||
- `NIX_SHOW_SYMBOLS` - Dumps the symbol table into the show-stats json output.
|
- `NIX_SHOW_SYMBOLS` - Dumps the symbol table into the show-stats json output.
|
||||||
- `TERM` - If `dumb` or unset, disables ANSI colour output.
|
- `TERM` - If `dumb` or unset, disables ANSI colour output.
|
||||||
|
- `FORCE_COLOR`, `CLICOLOR_FORCE` - Enables ANSI colour output if `NO_COLOR`/`NOCOLOR` not set.
|
||||||
- `NO_COLOR`, `NOCOLOR` - Disables ANSI colour output.
|
- `NO_COLOR`, `NOCOLOR` - Disables ANSI colour output.
|
||||||
- `_NIX_DEVELOPER_SHOW_UNKNOWN_LOCATIONS` - Highlights unknown locations in errors.
|
- `_NIX_DEVELOPER_SHOW_UNKNOWN_LOCATIONS` - Highlights unknown locations in errors.
|
||||||
- `NIX_PROFILE` - Selects which profile `nix-env` will operate on. Documented elsewhere.
|
- `NIX_PROFILE` - Selects which profile `nix-env` will operate on. Documented elsewhere.
|
||||||
|
|
|
@ -326,7 +326,6 @@ Derivations can declare some infrequently used optional attributes.
|
||||||
```
|
```
|
||||||
|
|
||||||
- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
|
- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
|
||||||
|
|
||||||
When using [structured attributes](#adv-attr-structuredAttrs), the
|
When using [structured attributes](#adv-attr-structuredAttrs), the
|
||||||
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
|
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
|
||||||
If set to `true`, it disables scanning the output for runtime dependencies.
|
If set to `true`, it disables scanning the output for runtime dependencies.
|
||||||
|
|
24
flake.nix
24
flake.nix
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
description = "The purely functional package manager";
|
description = "Lix: A modern, delicious implementation of the Nix package manager";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small";
|
||||||
|
@ -197,6 +197,8 @@
|
||||||
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
|
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lix-clang-tidy = final.callPackage ./subprojects/lix-clang-tidy { };
|
||||||
|
|
||||||
# Export the patched version of boehmgc that Lix uses into the overlay
|
# Export the patched version of boehmgc that Lix uses into the overlay
|
||||||
# for consumers of this flake.
|
# for consumers of this flake.
|
||||||
boehmgc-nix = final.nix.passthru.boehmgc-nix;
|
boehmgc-nix = final.nix.passthru.boehmgc-nix;
|
||||||
|
@ -290,6 +292,24 @@
|
||||||
werror = true;
|
werror = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Although this might be nicer to do with pre-commit, that would
|
||||||
|
# require adding 12MB of nodejs to the dev shell, whereas building it
|
||||||
|
# in CI with Nix avoids that at a cost of slower feedback on rarely
|
||||||
|
# touched files.
|
||||||
|
jsSyntaxCheck =
|
||||||
|
let
|
||||||
|
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||||
|
inherit (nixpkgs) pkgs;
|
||||||
|
docSources = lib.fileset.toSource {
|
||||||
|
root = ./doc;
|
||||||
|
fileset = lib.fileset.fileFilter (f: f.hasExt "js") ./doc;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.runCommand "js-syntax-check" { } ''
|
||||||
|
find ${docSources} -type f -print -exec ${pkgs.nodejs-slim}/bin/node --check '{}' ';'
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
# Make sure that nix-env still produces the exact same result
|
# Make sure that nix-env still produces the exact same result
|
||||||
# on a particular version of Nixpkgs.
|
# on a particular version of Nixpkgs.
|
||||||
evalNixpkgs =
|
evalNixpkgs =
|
||||||
|
@ -384,6 +404,8 @@
|
||||||
rec {
|
rec {
|
||||||
inherit (nixpkgsFor.${system}.native) nix;
|
inherit (nixpkgsFor.${system}.native) nix;
|
||||||
default = nix;
|
default = nix;
|
||||||
|
|
||||||
|
inherit (nixpkgsFor.${system}.native) lix-clang-tidy;
|
||||||
}
|
}
|
||||||
// (
|
// (
|
||||||
lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
lib.optionalAttrs (builtins.elem system linux64BitSystems) {
|
||||||
|
|
10
justfile
10
justfile
|
@ -25,3 +25,13 @@ install *OPTIONS: (build OPTIONS)
|
||||||
# Run tests
|
# Run tests
|
||||||
test *OPTIONS:
|
test *OPTIONS:
|
||||||
meson test -C build --print-errorlogs {{ OPTIONS }}
|
meson test -C build --print-errorlogs {{ OPTIONS }}
|
||||||
|
|
||||||
|
alias clang-tidy := lint
|
||||||
|
|
||||||
|
lint:
|
||||||
|
ninja -C build clang-tidy
|
||||||
|
|
||||||
|
alias clang-tidy-fix := lint-fix
|
||||||
|
|
||||||
|
lint-fix:
|
||||||
|
ninja -C build clang-tidy-fix
|
||||||
|
|
|
@ -548,3 +548,5 @@ if enable_tests
|
||||||
subdir('tests/unit')
|
subdir('tests/unit')
|
||||||
subdir('tests/functional')
|
subdir('tests/functional')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
subdir('meson/clang-tidy')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# vim: filetype=meson
|
# vim: filetype=meson
|
||||||
|
|
||||||
option('enable-build', type : 'boolean', value : true,
|
option('enable-build', type : 'boolean', value : true,
|
||||||
description : 'Set to false to not actually build. Only really makes sense with -Dinternal-api-docs=true',
|
description : 'set to false to not actually build. Only really makes sense with -Dinternal-api-docs=true',
|
||||||
)
|
)
|
||||||
|
|
||||||
option('gc', type : 'feature',
|
option('gc', type : 'feature',
|
||||||
|
@ -37,7 +37,7 @@ option('tests-brief', type : 'boolean', value : false,
|
||||||
)
|
)
|
||||||
|
|
||||||
option('profile-build', type : 'feature', value: 'disabled',
|
option('profile-build', type : 'feature', value: 'disabled',
|
||||||
description : 'whether to enable -ftime-trace in clang builds, allowing for speeding up the build.'
|
description : 'whether to enable -ftime-trace in clang builds, allowing for diagnosing the cause of build time.'
|
||||||
)
|
)
|
||||||
|
|
||||||
option('store-dir', type : 'string', value : '/nix/store',
|
option('store-dir', type : 'string', value : '/nix/store',
|
||||||
|
@ -68,3 +68,7 @@ option('profile-dir', type : 'string', value : 'etc/profile.d',
|
||||||
option('enable-pch-std', type : 'boolean', value : true,
|
option('enable-pch-std', type : 'boolean', value : true,
|
||||||
description : 'whether to use precompiled headers for C++\'s standard library (breaks clangd if you\'re using GCC)',
|
description : 'whether to use precompiled headers for C++\'s standard library (breaks clangd if you\'re using GCC)',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option('lix-clang-tidy-checks-path', type : 'string', value : '',
|
||||||
|
description: 'path to lix-clang-tidy-checks library file, if providing it externally. Uses an internal one if this is not set',
|
||||||
|
)
|
||||||
|
|
21
meson/clang-tidy/build_required_targets.py
Executable file
21
meson/clang-tidy/build_required_targets.py
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def get_targets_of_rule(build_root: str, rule_name: str) -> list[str]:
|
||||||
|
return subprocess.check_output(['ninja', '-C', build_root, '-t', 'targets', 'rule', rule_name]).decode().strip().splitlines()
|
||||||
|
|
||||||
|
def ninja_build(build_root: str, targets: list[str]):
|
||||||
|
subprocess.check_call(['ninja', '-C', build_root, '--', *targets])
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import argparse
|
||||||
|
ap = argparse.ArgumentParser(description='Builds required targets for clang-tidy')
|
||||||
|
ap.add_argument('build_root', help='Ninja build root', type=str)
|
||||||
|
|
||||||
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
targets = [t for t in get_targets_of_rule(args.build_root, 'CUSTOM_COMMAND') if t.endswith('gen.hh')]
|
||||||
|
ninja_build(args.build_root, targets)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
53
meson/clang-tidy/clean_compdb.py
Executable file
53
meson/clang-tidy/clean_compdb.py
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Deletes the PCH arguments from a compilation database, to workaround nixpkgs
|
||||||
|
# stdenv having a cc-wrapper that is impossible to use for anything except cc
|
||||||
|
# itself, for example, clang-tidy.
|
||||||
|
|
||||||
|
import json
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
|
||||||
|
def process_compdb(compdb: list[dict]) -> list[dict]:
|
||||||
|
|
||||||
|
def munch_command(args: list[str]) -> list[str]:
|
||||||
|
out = []
|
||||||
|
eat_next = False
|
||||||
|
for i, arg in enumerate(args):
|
||||||
|
if arg == '-fpch-preprocess':
|
||||||
|
# as used with gcc
|
||||||
|
continue
|
||||||
|
elif arg == '-include-pch' or (arg == '-include' and args[i + 1] == 'precompiled-headers.hh'):
|
||||||
|
# -include-pch some-pch (clang), or -include some-pch (gcc)
|
||||||
|
eat_next = True
|
||||||
|
continue
|
||||||
|
if not eat_next:
|
||||||
|
out.append(arg)
|
||||||
|
eat_next = False
|
||||||
|
return out
|
||||||
|
|
||||||
|
def chomp(item: dict) -> dict:
|
||||||
|
item = item.copy()
|
||||||
|
item['command'] = shlex.join(munch_command(shlex.split(item['command'])))
|
||||||
|
return item
|
||||||
|
|
||||||
|
return [chomp(x) for x in compdb if not x['file'].endswith('precompiled-headers.hh')]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import argparse
|
||||||
|
ap = argparse.ArgumentParser(
|
||||||
|
description='Delete pch arguments from compilation database')
|
||||||
|
ap.add_argument('input',
|
||||||
|
type=argparse.FileType('r'),
|
||||||
|
help='Input json file')
|
||||||
|
ap.add_argument('output',
|
||||||
|
type=argparse.FileType('w'),
|
||||||
|
help='Output json file')
|
||||||
|
args = ap.parse_args()
|
||||||
|
|
||||||
|
input_json = json.load(args.input)
|
||||||
|
json.dump(process_compdb(input_json), args.output, indent=2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
0
meson/clang-tidy/fake.cc
Normal file
0
meson/clang-tidy/fake.cc
Normal file
98
meson/clang-tidy/meson.build
Normal file
98
meson/clang-tidy/meson.build
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
# The clang-tidy target for Lix
|
||||||
|
|
||||||
|
run_clang_tidy = find_program('run-clang-tidy', required : false)
|
||||||
|
# Although this looks like it wants to be pkg-config, pkg-config does not
|
||||||
|
# really work for *plugins*, which are executable-like .so files that also
|
||||||
|
# cannot be found via find_program. Fun!
|
||||||
|
if get_option('lix-clang-tidy-checks-path') != ''
|
||||||
|
lix_clang_tidy_so = get_option('lix-clang-tidy-checks-path')
|
||||||
|
lix_clang_tidy_so_found = true
|
||||||
|
else
|
||||||
|
lix_clang_tidy_subproj = subproject(
|
||||||
|
'lix-clang-tidy',
|
||||||
|
required : false,
|
||||||
|
default_options : {'build-by-default': false}
|
||||||
|
)
|
||||||
|
if lix_clang_tidy_subproj.found()
|
||||||
|
lix_clang_tidy_so = lix_clang_tidy_subproj.get_variable('lix_clang_tidy')
|
||||||
|
lix_clang_tidy_so_found = true
|
||||||
|
else
|
||||||
|
lix_clang_tidy_so_found = false
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Due to numerous problems, such as:
|
||||||
|
# - Meson does not expose pch targets, but *fine*, I can just ask Ninja for
|
||||||
|
# them with `ninja -t targets rule cpp_PCH` and build them manually:
|
||||||
|
# https://github.com/mesonbuild/meson/issues/13499
|
||||||
|
# - Nixpkgs stdenv buries the cc-wrapper under a giant pile of assumptions
|
||||||
|
# about the cc-wrapper actually being used on the cc of a stdenv, rather than
|
||||||
|
# independently for clang-tidy, and we need to use cc-wrapper to get the
|
||||||
|
# correct hardening flags so that clang-tidy can actually parse the PCH file
|
||||||
|
#
|
||||||
|
# I give up. I am going to delete the damn PCH args and then it will work.
|
||||||
|
meson.add_postconf_script(
|
||||||
|
python,
|
||||||
|
meson.current_source_dir() / 'clean_compdb.py',
|
||||||
|
meson.global_build_root() / 'compile_commands.json',
|
||||||
|
meson.current_build_dir() / 'compile_commands.json',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Horrible hack to get around not being able to depend on another target's
|
||||||
|
# generated headers in any way in the meson DSL
|
||||||
|
# https://github.com/mesonbuild/meson/issues/12817 which was incorrectly
|
||||||
|
# closed, if you *actually* need to generate the files once.
|
||||||
|
# Also related: https://github.com/mesonbuild/meson/issues/3667
|
||||||
|
#
|
||||||
|
# Or we could ban meson generators because their design is broken.
|
||||||
|
build_all_generated_headers = custom_target(
|
||||||
|
command : [
|
||||||
|
python,
|
||||||
|
meson.current_source_dir() / 'build_required_targets.py',
|
||||||
|
meson.global_build_root(),
|
||||||
|
],
|
||||||
|
output : 'generated_headers.stamp',
|
||||||
|
build_by_default : false,
|
||||||
|
build_always_stale : true,
|
||||||
|
)
|
||||||
|
|
||||||
|
if lix_clang_tidy_so_found
|
||||||
|
run_clang_tidy_args = [
|
||||||
|
'-load',
|
||||||
|
lix_clang_tidy_so,
|
||||||
|
'-p',
|
||||||
|
# We have to workaround a run-clang-tidy bug too, so we must give the
|
||||||
|
# directory name rather than the actual compdb file.
|
||||||
|
# https://github.com/llvm/llvm-project/issues/101440
|
||||||
|
meson.current_build_dir(),
|
||||||
|
'-quiet',
|
||||||
|
]
|
||||||
|
run_target(
|
||||||
|
'clang-tidy',
|
||||||
|
command : [
|
||||||
|
# XXX: This explicitly invokes it with python because of a nixpkgs bug
|
||||||
|
# where clang-unwrapped does not patch interpreters in run-clang-tidy.
|
||||||
|
# However, making clang-unwrapped depend on python is also silly, so idk.
|
||||||
|
python,
|
||||||
|
run_clang_tidy,
|
||||||
|
run_clang_tidy_args,
|
||||||
|
'-warnings-as-errors',
|
||||||
|
'*',
|
||||||
|
],
|
||||||
|
depends : [
|
||||||
|
build_all_generated_headers,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
run_target(
|
||||||
|
'clang-tidy-fix',
|
||||||
|
command : [
|
||||||
|
python,
|
||||||
|
run_clang_tidy,
|
||||||
|
run_clang_tidy_args,
|
||||||
|
'-fix',
|
||||||
|
],
|
||||||
|
depends : [
|
||||||
|
build_all_generated_headers,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
endif
|
|
@ -53,7 +53,7 @@ void ConfigFile::apply()
|
||||||
|
|
||||||
bool trusted = whitelist.count(baseName);
|
bool trusted = whitelist.count(baseName);
|
||||||
if (!trusted) {
|
if (!trusted) {
|
||||||
switch (nix::fetchSettings.acceptFlakeConfig) {
|
switch (nix::fetchSettings.acceptFlakeConfig.get()) {
|
||||||
case AcceptFlakeConfig::True: {
|
case AcceptFlakeConfig::True: {
|
||||||
trusted = true;
|
trusted = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "state.hh"
|
#include "state.hh"
|
||||||
|
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <clocale>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
// flip this define when doing parser development to enable some g checks.
|
// flip this define when doing parser development to enable some g checks.
|
||||||
|
@ -254,7 +253,8 @@ struct AttrState : SubexprState {
|
||||||
|
|
||||||
std::vector<AttrName> attrs;
|
std::vector<AttrName> attrs;
|
||||||
|
|
||||||
void pushAttr(auto && attr, PosIdx) { attrs.emplace_back(std::move(attr)); }
|
template <typename T>
|
||||||
|
void pushAttr(T && attr, PosIdx) { attrs.emplace_back(std::forward<T>(attr)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct BuildAST<grammar::attr::simple> {
|
template<> struct BuildAST<grammar::attr::simple> {
|
||||||
|
@ -290,7 +290,8 @@ struct InheritState : SubexprState {
|
||||||
std::unique_ptr<Expr> from;
|
std::unique_ptr<Expr> from;
|
||||||
PosIdx fromPos;
|
PosIdx fromPos;
|
||||||
|
|
||||||
void pushAttr(auto && attr, PosIdx pos) { attrs.emplace_back(std::move(attr), pos); }
|
template <typename T>
|
||||||
|
void pushAttr(T && attr, PosIdx pos) { attrs.emplace_back(std::forward<T>(attr), pos); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct BuildAST<grammar::inherit::from> {
|
template<> struct BuildAST<grammar::inherit::from> {
|
||||||
|
|
|
@ -477,8 +477,17 @@ struct curlFileTransfer : public FileTransfer
|
||||||
|
|
||||||
~curlFileTransfer()
|
~curlFileTransfer()
|
||||||
{
|
{
|
||||||
stopWorkerThread();
|
try {
|
||||||
|
stopWorkerThread();
|
||||||
|
} catch (nix::Error e) {
|
||||||
|
// This can only fail if a socket to our own process cannot be
|
||||||
|
// written to, so it is always a bug in the program if it fails.
|
||||||
|
//
|
||||||
|
// Joining the thread would probably only cause a deadlock if this
|
||||||
|
// happened, so just die on purpose.
|
||||||
|
printError("failed to join curl file transfer worker thread: %1%", e.what());
|
||||||
|
std::terminate();
|
||||||
|
}
|
||||||
workerThread.join();
|
workerThread.join();
|
||||||
|
|
||||||
if (curlm) curl_multi_cleanup(curlm);
|
if (curlm) curl_multi_cleanup(curlm);
|
||||||
|
|
|
@ -33,7 +33,7 @@ Machine::Machine(decltype(storeUri) storeUri,
|
||||||
systemTypes(systemTypes),
|
systemTypes(systemTypes),
|
||||||
sshKey(sshKey),
|
sshKey(sshKey),
|
||||||
maxJobs(maxJobs),
|
maxJobs(maxJobs),
|
||||||
speedFactor(speedFactor == 0.0f ? 1.0f : std::move(speedFactor)),
|
speedFactor(speedFactor == 0.0f ? 1.0f : speedFactor),
|
||||||
supportedFeatures(supportedFeatures),
|
supportedFeatures(supportedFeatures),
|
||||||
mandatoryFeatures(mandatoryFeatures),
|
mandatoryFeatures(mandatoryFeatures),
|
||||||
sshPublicHostKey(sshPublicHostKey)
|
sshPublicHostKey(sshPublicHostKey)
|
||||||
|
|
|
@ -192,7 +192,7 @@ static Generator<Entry> parseObject(Source & source, const Path & path)
|
||||||
#define EXPECT(raw, kind) \
|
#define EXPECT(raw, kind) \
|
||||||
do { \
|
do { \
|
||||||
const auto s = readString(source); \
|
const auto s = readString(source); \
|
||||||
if (s != raw) { \
|
if (s != (raw)) { \
|
||||||
throw badArchive("expected " kind " tag"); \
|
throw badArchive("expected " kind " tag"); \
|
||||||
} \
|
} \
|
||||||
co_yield MetadataString{s}; \
|
co_yield MetadataString{s}; \
|
||||||
|
|
|
@ -131,7 +131,7 @@ AutoCloseFD::AutoCloseFD(AutoCloseFD && that) : fd{that.fd}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AutoCloseFD & AutoCloseFD::operator =(AutoCloseFD && that)
|
AutoCloseFD & AutoCloseFD::operator =(AutoCloseFD && that) noexcept(false)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
fd = that.fd;
|
fd = that.fd;
|
||||||
|
|
|
@ -229,7 +229,7 @@ Hash::Hash(std::string_view rest, HashType type, bool isSRI)
|
||||||
|
|
||||||
for (unsigned int n = 0; n < rest.size(); ++n) {
|
for (unsigned int n = 0; n < rest.size(); ++n) {
|
||||||
char c = rest[rest.size() - n - 1];
|
char c = rest[rest.size() - n - 1];
|
||||||
unsigned char digit;
|
size_t digit;
|
||||||
for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */
|
for (digit = 0; digit < base32Chars.size(); ++digit) /* !!! slow */
|
||||||
if (base32Chars[digit] == c) break;
|
if (base32Chars[digit] == c) break;
|
||||||
if (digit >= 32)
|
if (digit >= 32)
|
||||||
|
|
|
@ -37,7 +37,7 @@ void Logger::warn(const std::string & msg)
|
||||||
|
|
||||||
void Logger::writeToStdout(std::string_view s)
|
void Logger::writeToStdout(std::string_view s)
|
||||||
{
|
{
|
||||||
writeFull(STDOUT_FILENO, s);
|
writeFull(STDOUT_FILENO, filterANSIEscapes(s, !shouldANSI(), std::numeric_limits<unsigned int>::max(), false));
|
||||||
writeFull(STDOUT_FILENO, "\n");
|
writeFull(STDOUT_FILENO, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ std::vector<std::string> shell_split(const std::string & input)
|
||||||
begin = ++iterator;
|
begin = ++iterator;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
// no other relevant cases; silence exhaustiveness compiler warning
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,25 @@ namespace nix {
|
||||||
|
|
||||||
bool shouldANSI()
|
bool shouldANSI()
|
||||||
{
|
{
|
||||||
return isatty(STDERR_FILENO)
|
// Implements the behaviour described by https://bixense.com/clicolors/
|
||||||
&& getEnv("TERM").value_or("dumb") != "dumb"
|
// As well as https://force-color.org/ for compatibility, since it fits in the same shape.
|
||||||
&& !(getEnv("NO_COLOR").has_value() || getEnv("NOCOLOR").has_value());
|
// NO_COLOR CLICOLOR CLICOLOR_FORCE Colours?
|
||||||
|
// set x x No
|
||||||
|
// unset x set Yes
|
||||||
|
// unset x unset If attached to a terminal
|
||||||
|
// [we choose the "modern" approach of colour-by-default]
|
||||||
|
auto compute = []() -> bool {
|
||||||
|
bool mustNotColour = getEnv("NO_COLOR").has_value() || getEnv("NOCOLOR").has_value();
|
||||||
|
bool shouldForce = getEnv("CLICOLOR_FORCE").has_value() || getEnv("FORCE_COLOR").has_value();
|
||||||
|
bool isTerminal = isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb";
|
||||||
|
return !mustNotColour && (shouldForce || isTerminal);
|
||||||
|
};
|
||||||
|
static bool cached = compute();
|
||||||
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width)
|
// FIXME(jade): replace with TerminalCodeEater. wowie this is evil code.
|
||||||
|
std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int width, bool eatTabs)
|
||||||
{
|
{
|
||||||
std::string t, e;
|
std::string t, e;
|
||||||
size_t w = 0;
|
size_t w = 0;
|
||||||
|
@ -43,7 +56,7 @@ std::string filterANSIEscapes(std::string_view s, bool filterAll, unsigned int w
|
||||||
t += e;
|
t += e;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (*i == '\t') {
|
else if (*i == '\t' && eatTabs) {
|
||||||
i++; t += ' '; w++;
|
i++; t += ' '; w++;
|
||||||
while (w < (size_t) width && w % 8) {
|
while (w < (size_t) width && w % 8) {
|
||||||
t += ' '; w++;
|
t += ' '; w++;
|
||||||
|
|
|
@ -9,6 +9,15 @@ namespace nix {
|
||||||
/**
|
/**
|
||||||
* Determine whether ANSI escape sequences are appropriate for the
|
* Determine whether ANSI escape sequences are appropriate for the
|
||||||
* present output.
|
* present output.
|
||||||
|
*
|
||||||
|
* This follows the rules described on https://bixense.com/clicolors/
|
||||||
|
* with CLICOLOR defaulted to enabled (and thus ignored).
|
||||||
|
*
|
||||||
|
* That is to say, the following procedure is followed in order:
|
||||||
|
* - NO_COLOR or NOCOLOR set -> always disable colour
|
||||||
|
* - CLICOLOR_FORCE or FORCE_COLOR set -> enable colour
|
||||||
|
* - The output is a tty; TERM != "dumb" -> enable colour
|
||||||
|
* - Otherwise -> disable colour
|
||||||
*/
|
*/
|
||||||
bool shouldANSI();
|
bool shouldANSI();
|
||||||
|
|
||||||
|
@ -21,7 +30,8 @@ bool shouldANSI();
|
||||||
*/
|
*/
|
||||||
std::string filterANSIEscapes(std::string_view s,
|
std::string filterANSIEscapes(std::string_view s,
|
||||||
bool filterAll = false,
|
bool filterAll = false,
|
||||||
unsigned int width = std::numeric_limits<unsigned int>::max());
|
unsigned int width = std::numeric_limits<unsigned int>::max(),
|
||||||
|
bool eatTabs = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculate the window size, updating a global variable. Used in the
|
* Recalculate the window size, updating a global variable. Used in the
|
||||||
|
|
|
@ -63,7 +63,7 @@ std::string percentDecode(std::string_view in)
|
||||||
if (i + 2 >= in.size())
|
if (i + 2 >= in.size())
|
||||||
throw BadURL("invalid URI parameter '%s'", in);
|
throw BadURL("invalid URI parameter '%s'", in);
|
||||||
try {
|
try {
|
||||||
decoded += std::stoul(std::string(in, i + 1, 2), 0, 16);
|
decoded += char8_t(std::stoul(std::string(in, i + 1, 2), 0, 16));
|
||||||
i += 3;
|
i += 3;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw BadURL("invalid URI parameter '%s'", in);
|
throw BadURL("invalid URI parameter '%s'", in);
|
||||||
|
|
|
@ -209,6 +209,11 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
auto lockedFlake = lockFlake();
|
auto lockedFlake = lockFlake();
|
||||||
auto & flake = lockedFlake.flake;
|
auto & flake = lockedFlake.flake;
|
||||||
|
auto formatTime = [](time_t time) -> std::string {
|
||||||
|
std::ostringstream os{};
|
||||||
|
os << std::put_time(std::localtime(&time), "%F %T");
|
||||||
|
return os.str();
|
||||||
|
};
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
|
@ -260,7 +265,7 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
|
||||||
if (auto lastModified = flake.lockedRef.input.getLastModified())
|
if (auto lastModified = flake.lockedRef.input.getLastModified())
|
||||||
logger->cout(
|
logger->cout(
|
||||||
ANSI_BOLD "Last modified:" ANSI_NORMAL " %s",
|
ANSI_BOLD "Last modified:" ANSI_NORMAL " %s",
|
||||||
std::put_time(std::localtime(&*lastModified), "%F %T"));
|
formatTime(*lastModified));
|
||||||
|
|
||||||
if (!lockedFlake.lockFile.root->inputs.empty())
|
if (!lockedFlake.lockFile.root->inputs.empty())
|
||||||
logger->cout(ANSI_BOLD "Inputs:" ANSI_NORMAL);
|
logger->cout(ANSI_BOLD "Inputs:" ANSI_NORMAL);
|
||||||
|
@ -275,16 +280,25 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
|
||||||
bool last = i + 1 == node.inputs.size();
|
bool last = i + 1 == node.inputs.size();
|
||||||
|
|
||||||
if (auto lockedNode = std::get_if<0>(&input.second)) {
|
if (auto lockedNode = std::get_if<0>(&input.second)) {
|
||||||
logger->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
// ├───agenix: github:ryantm/agenix/8d37c5bdeade12b6479c85acd133063ab53187a0
|
||||||
prefix + (last ? treeLast : treeConn), input.first,
|
logger->cout("%s%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
||||||
|
prefix, last ? treeLast : treeConn, input.first,
|
||||||
(*lockedNode)->lockedRef);
|
(*lockedNode)->lockedRef);
|
||||||
|
|
||||||
|
// ├───lix: https://git.lix.systems/api/v1/repos/lix-project <....>
|
||||||
|
// │ Last modified: 2024-07-31 21:01:34
|
||||||
|
if (auto lastModified = (*lockedNode)->lockedRef.input.getLastModified()) {
|
||||||
|
logger->cout("%s%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
|
||||||
|
prefix, last ? treeNull : treeLine, "Last modified", formatTime(*lastModified));
|
||||||
|
}
|
||||||
|
|
||||||
bool firstVisit = visited.insert(*lockedNode).second;
|
bool firstVisit = visited.insert(*lockedNode).second;
|
||||||
|
|
||||||
if (firstVisit) recurse(**lockedNode, prefix + (last ? treeNull : treeLine));
|
if (firstVisit) recurse(**lockedNode, prefix + (last ? treeNull : treeLine));
|
||||||
} else if (auto follows = std::get_if<1>(&input.second)) {
|
} else if (auto follows = std::get_if<1>(&input.second)) {
|
||||||
logger->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
|
// │ ├───darwin follows input 'flake-utils'
|
||||||
prefix + (last ? treeLast : treeConn), input.first,
|
logger->cout("%s%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
|
||||||
|
prefix, last ? treeLast : treeConn, input.first,
|
||||||
printInputPath(*follows));
|
printInputPath(*follows));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
generate_manpage_gen = gen_header.process(meson.project_source_root() / 'doc/manual/generate-manpage.nix')
|
nix_generated_headers = [
|
||||||
|
gen_header.process(meson.project_source_root() / 'doc/manual/generate-manpage.nix'),
|
||||||
utils_gen = gen_header.process(meson.project_source_root() / 'doc/manual/utils.nix')
|
gen_header.process(meson.project_source_root() / 'doc/manual/utils.nix'),
|
||||||
|
gen_header.process('get-env.sh'),
|
||||||
get_env_gen = gen_header.process('get-env.sh')
|
]
|
||||||
|
|
||||||
# src/nix/profile.cc includes src/nix/profile.md, which includes "doc/files/profiles.md.gen.hh".
|
# src/nix/profile.cc includes src/nix/profile.md, which includes "doc/files/profiles.md.gen.hh".
|
||||||
# Unfortunately, https://github.com/mesonbuild/meson/issues/2320.
|
# Unfortunately, https://github.com/mesonbuild/meson/issues/2320.
|
||||||
|
@ -18,7 +18,7 @@ run_command(
|
||||||
meson.current_build_dir() / 'doc/files/profiles.md',
|
meson.current_build_dir() / 'doc/files/profiles.md',
|
||||||
check : true,
|
check : true,
|
||||||
)
|
)
|
||||||
profiles_md_gen = gen_header.process(
|
nix_generated_headers += gen_header.process(
|
||||||
meson.current_build_dir() / 'doc/files/profiles.md',
|
meson.current_build_dir() / 'doc/files/profiles.md',
|
||||||
preserve_path_from : meson.current_build_dir(),
|
preserve_path_from : meson.current_build_dir(),
|
||||||
)
|
)
|
||||||
|
@ -74,10 +74,7 @@ nix_sources = files(
|
||||||
nix = executable(
|
nix = executable(
|
||||||
'nix',
|
'nix',
|
||||||
nix_sources,
|
nix_sources,
|
||||||
generate_manpage_gen,
|
nix_generated_headers,
|
||||||
utils_gen,
|
|
||||||
get_env_gen,
|
|
||||||
profiles_md_gen,
|
|
||||||
nix2_commands_sources,
|
nix2_commands_sources,
|
||||||
dependencies : [
|
dependencies : [
|
||||||
libasanoptions,
|
libasanoptions,
|
||||||
|
|
44
subprojects/lix-clang-tidy/default.nix
Normal file
44
subprojects/lix-clang-tidy/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
cmake,
|
||||||
|
meson,
|
||||||
|
ninja,
|
||||||
|
llvmPackages,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) fileset;
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "lix-clang-tidy-checks";
|
||||||
|
# Setting the version to the Lix version is just going to cause pointless
|
||||||
|
# rebuilds due to versionSuffix and similar, and I cannot conceive of a usage
|
||||||
|
# where we actually care about its version since this is internal-only.
|
||||||
|
version = "0.1";
|
||||||
|
|
||||||
|
src = fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = fileset.unions [
|
||||||
|
./meson.build
|
||||||
|
./meson.options
|
||||||
|
(fileset.fileFilter (
|
||||||
|
{ hasExt, ... }:
|
||||||
|
builtins.any hasExt [
|
||||||
|
"cc"
|
||||||
|
"hh"
|
||||||
|
]
|
||||||
|
) ./.)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
meson
|
||||||
|
cmake
|
||||||
|
ninja
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
llvmPackages.llvm
|
||||||
|
llvmPackages.clang-unwrapped.dev
|
||||||
|
];
|
||||||
|
}
|
18
subprojects/lix-clang-tidy/meson.build
Normal file
18
subprojects/lix-clang-tidy/meson.build
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
project('lix-clang-tidy', ['cpp', 'c'],
|
||||||
|
version : '0.1',
|
||||||
|
default_options : ['warning_level=3', 'cpp_std=c++20']
|
||||||
|
)
|
||||||
|
|
||||||
|
llvm = dependency('Clang', version: '>= 17', modules: ['libclang'])
|
||||||
|
sources = files(
|
||||||
|
'HasPrefixSuffix.cc',
|
||||||
|
'LixClangTidyChecks.cc',
|
||||||
|
'FixIncludes.cc',
|
||||||
|
)
|
||||||
|
|
||||||
|
lix_clang_tidy = shared_module('lix-clang-tidy', sources,
|
||||||
|
dependencies: llvm,
|
||||||
|
# overrides build_by_default, see https://github.com/mesonbuild/meson/issues/13498
|
||||||
|
install : get_option('build-by-default'),
|
||||||
|
build_by_default : get_option('build-by-default')
|
||||||
|
)
|
3
subprojects/lix-clang-tidy/meson.options
Normal file
3
subprojects/lix-clang-tidy/meson.options
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
option('build-by-default', type : 'boolean', value : true,
|
||||||
|
description : 'set to false to not actually build targets by default. This is a hack to deal with meson lacking a build_by_default default option and building subprojects by default'
|
||||||
|
)
|
36
tests/functional/flakes/flake-metadata.sh
Normal file
36
tests/functional/flakes/flake-metadata.sh
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
source ./common.sh
|
||||||
|
|
||||||
|
flakeDir=$TEST_ROOT/flake
|
||||||
|
mkdir -p "$flakeDir"
|
||||||
|
|
||||||
|
cat > "$flakeDir/flake.nix" <<-'EOF'
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
flake-compat = {
|
||||||
|
url = "github:edolstra/flake-compat";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
lanzaboote = {
|
||||||
|
url = "github:nix-community/lanzaboote";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.flake-utils.follows = "flake-utils";
|
||||||
|
inputs.flake-compat.follows = "flake-compat";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { ... }: {};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cp flake-metadata/flake.lock "$flakeDir"
|
||||||
|
touch -d @1000 "$flakeDir/flake.nix" "$flakeDir/flake.lock" "$flakeDir"
|
||||||
|
|
||||||
|
# For some reason we use NIX_STORE_DIR which causes unstable paths. This is
|
||||||
|
# goofy. We can just use --store, which sets rootDir and does not have this
|
||||||
|
# problem.
|
||||||
|
actualStore=$NIX_STORE_DIR
|
||||||
|
unset NIX_STORE_DIR
|
||||||
|
NOCOLOR=1 TZ=UTC LC_ALL=C.UTF-8 nix flake metadata --store "$actualStore" "$flakeDir" | grep -v -e 'Locked URL:' -e 'Resolved URL:' > "$TEST_ROOT/metadata.out.actual"
|
||||||
|
diff -u flake-metadata/metadata.out.expected "$TEST_ROOT/metadata.out.actual"
|
245
tests/functional/flakes/flake-metadata/flake.lock
Normal file
245
tests/functional/flakes/flake-metadata/flake.lock
Normal file
|
@ -0,0 +1,245 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1711299236,
|
||||||
|
"narHash": "sha256-6/JsyozOMKN8LUGqWMopKTSiK8N79T8Q+hcxu2KkTXg=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "880573f80d09e18a11713f402b9e6172a085449f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709336216,
|
||||||
|
"narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710146030,
|
||||||
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"pre-commit-hooks-nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709087332,
|
||||||
|
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lanzaboote": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flake-compat": [
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1713369831,
|
||||||
|
"narHash": "sha256-G4OGxvlIIjphpkxcRAkf1QInYsAeqbfNh6Yl1JLy2uM=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "lanzaboote",
|
||||||
|
"rev": "850f27322239f8cfa56b122cc9a278ab99a49015",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "lanzaboote",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719824438,
|
||||||
|
"narHash": "sha256-pY0wosAgcr9W4vmGML0T3BVhQiGuKoozCbs2t+Je1zc=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "7f993cdf26ccef564eabf31fdb40d140821e12bc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable-small",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710695816,
|
||||||
|
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-23.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pre-commit-hooks-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"lanzaboote",
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"flake-utils": [
|
||||||
|
"lanzaboote",
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710923068,
|
||||||
|
"narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"rev": "e611897ddfdde3ed3eaac4758635d7177ff78673",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"lanzaboote": "lanzaboote",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": [
|
||||||
|
"lanzaboote",
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1711246447,
|
||||||
|
"narHash": "sha256-g9TOluObcOEKewFo2fR4cn51Y/jSKhRRo4QZckHLop0=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "dcc802a6ec4e9cc6a1c8c393327f0c42666f22e4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
36
tests/functional/flakes/flake-metadata/metadata.out.expected
Normal file
36
tests/functional/flakes/flake-metadata/metadata.out.expected
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
Path: /nix/store/gaxb42z68bcr8lch467shvmnhjjzgd8b-source
|
||||||
|
Last modified: 1970-01-01 00:16:40
|
||||||
|
Inputs:
|
||||||
|
├───flake-compat: github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33
|
||||||
|
│ Last modified: 2023-10-04 13:37:54
|
||||||
|
├───flake-utils: github:numtide/flake-utils/b1d9ab70662946ef0850d488da1c9019f3a9752a
|
||||||
|
│ Last modified: 2024-03-11 08:33:50
|
||||||
|
│ └───systems: github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e
|
||||||
|
│ Last modified: 2023-04-09 08:27:08
|
||||||
|
├───lanzaboote: github:nix-community/lanzaboote/850f27322239f8cfa56b122cc9a278ab99a49015
|
||||||
|
│ Last modified: 2024-04-17 16:03:51
|
||||||
|
│ ├───crane: github:ipetkov/crane/880573f80d09e18a11713f402b9e6172a085449f
|
||||||
|
│ │ Last modified: 2024-03-24 16:53:56
|
||||||
|
│ │ └───nixpkgs follows input 'lanzaboote/nixpkgs'
|
||||||
|
│ ├───flake-compat follows input 'flake-compat'
|
||||||
|
│ ├───flake-parts: github:hercules-ci/flake-parts/f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2
|
||||||
|
│ │ Last modified: 2024-03-01 23:36:56
|
||||||
|
│ │ └───nixpkgs-lib follows input 'lanzaboote/nixpkgs'
|
||||||
|
│ ├───flake-utils follows input 'flake-utils'
|
||||||
|
│ ├───nixpkgs follows input 'nixpkgs'
|
||||||
|
│ ├───pre-commit-hooks-nix: github:cachix/pre-commit-hooks.nix/e611897ddfdde3ed3eaac4758635d7177ff78673
|
||||||
|
│ │ Last modified: 2024-03-20 08:24:28
|
||||||
|
│ │ ├───flake-compat follows input 'lanzaboote/flake-compat'
|
||||||
|
│ │ ├───flake-utils follows input 'lanzaboote/flake-utils'
|
||||||
|
│ │ ├───gitignore: github:hercules-ci/gitignore.nix/637db329424fd7e46cf4185293b9cc8c88c95394
|
||||||
|
│ │ │ Last modified: 2024-02-28 02:28:52
|
||||||
|
│ │ │ └───nixpkgs follows input 'lanzaboote/pre-commit-hooks-nix/nixpkgs'
|
||||||
|
│ │ ├───nixpkgs follows input 'lanzaboote/nixpkgs'
|
||||||
|
│ │ └───nixpkgs-stable: github:NixOS/nixpkgs/614b4613980a522ba49f0d194531beddbb7220d3
|
||||||
|
│ │ Last modified: 2024-03-17 17:16:56
|
||||||
|
│ └───rust-overlay: github:oxalica/rust-overlay/dcc802a6ec4e9cc6a1c8c393327f0c42666f22e4
|
||||||
|
│ Last modified: 2024-03-24 02:14:07
|
||||||
|
│ ├───flake-utils follows input 'lanzaboote/flake-utils'
|
||||||
|
│ └───nixpkgs follows input 'lanzaboote/nixpkgs'
|
||||||
|
└───nixpkgs: github:nixos/nixpkgs/7f993cdf26ccef564eabf31fdb40d140821e12bc
|
||||||
|
Last modified: 2024-07-01 09:00:38
|
|
@ -69,8 +69,9 @@ functional_tests_scripts = [
|
||||||
'flakes/unlocked-override.sh',
|
'flakes/unlocked-override.sh',
|
||||||
'flakes/absolute-paths.sh',
|
'flakes/absolute-paths.sh',
|
||||||
'flakes/build-paths.sh',
|
'flakes/build-paths.sh',
|
||||||
'flakes/flake-registry.sh',
|
|
||||||
'flakes/flake-in-submodule.sh',
|
'flakes/flake-in-submodule.sh',
|
||||||
|
'flakes/flake-metadata.sh',
|
||||||
|
'flakes/flake-registry.sh',
|
||||||
'flakes/subdir-flake.sh',
|
'flakes/subdir-flake.sh',
|
||||||
'gc.sh',
|
'gc.sh',
|
||||||
'nix-collect-garbage-d.sh',
|
'nix-collect-garbage-d.sh',
|
||||||
|
|
|
@ -29,6 +29,8 @@ nix search -f search.nix '' ^ | grepQuiet hello
|
||||||
|
|
||||||
## Tests for multiple regex/match highlighting
|
## Tests for multiple regex/match highlighting
|
||||||
|
|
||||||
|
# FIXME: possibly not test this with colour in the future
|
||||||
|
export CLICOLOR_FORCE=1
|
||||||
e=$'\x1b' # grep doesn't support \e, \033 or even \x1b
|
e=$'\x1b' # grep doesn't support \e, \033 or even \x1b
|
||||||
# Multiple overlapping regexes
|
# Multiple overlapping regexes
|
||||||
(( $(nix search -f search.nix '' 'oo' 'foo' 'oo' | grep -c "$e\[32;1mfoo$e\\[0;1m") == 1 ))
|
(( $(nix search -f search.nix '' 'oo' 'foo' 'oo' | grep -c "$e\[32;1mfoo$e\\[0;1m") == 1 ))
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
#include "cli-literate-parser.hh"
|
#include "cli-literate-parser.hh"
|
||||||
#include "escape-string.hh"
|
#include "escape-string.hh"
|
||||||
#include "escape-char.hh"
|
|
||||||
#include "libexpr/print.hh"
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "cli-literate-parser.hh"
|
#include "cli-literate-parser.hh"
|
||||||
#include "escape-string.hh"
|
#include "escape-string.hh"
|
||||||
#include "fmt.hh"
|
#include "fmt.hh"
|
||||||
#include "libexpr/print.hh"
|
|
||||||
#include "shlex.hh"
|
#include "shlex.hh"
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include "strings.hh"
|
#include "strings.hh"
|
||||||
|
@ -361,9 +357,8 @@ const char * ParseError::what() const noexcept
|
||||||
return what_->c_str();
|
return what_->c_str();
|
||||||
} else {
|
} else {
|
||||||
auto escaped = escapeString(rest, {.maxLength = 256, .escapeNonPrinting = true});
|
auto escaped = escapeString(rest, {.maxLength = 256, .escapeNonPrinting = true});
|
||||||
auto hint =
|
auto hint = HintFmt("Parse error: Expected %1%, got:\n%2%", expected, Uncolored(escaped));
|
||||||
new HintFmt("Parse error: Expected %1%, got:\n%2%", expected, Uncolored(escaped));
|
what_ = hint.str();
|
||||||
what_ = hint->str();
|
|
||||||
return what_->c_str();
|
return what_->c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue