nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 callPackage,
3 lib,
4 stdenv,
5 buildPackages,
6 fetchFromGitHub,
7 rustPlatform,
8 installShellFiles,
9 pkg-config,
10 openssl,
11 testers,
12}:
13
14let
15 canRun = stdenv.hostPlatform.emulatorAvailable buildPackages;
16 lychee = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/lychee${stdenv.hostPlatform.extensions.executable}";
17in
18rustPlatform.buildRustPackage rec {
19 pname = "lychee";
20 version = "0.21.0";
21
22 src = fetchFromGitHub {
23 owner = "lycheeverse";
24 repo = "lychee";
25 tag = "lychee-v${version}";
26 leaveDotGit = true;
27 postFetch = ''
28 GIT_DATE=$(git -C $out/.git show -s --format=%cs)
29 substituteInPlace $out/lychee-bin/build.rs \
30 --replace-fail \
31 '("cargo:rustc-env=GIT_DATE={}", git_date())' \
32 '("cargo:rustc-env=GIT_DATE={}", "'$GIT_DATE'")'
33 rm -rf $out/.git
34 '';
35 hash = "sha256-Nt7LsnQkWQS0f2/lS8WNYkI+XbKUSHQ6bNf9FNjfk7A=";
36 };
37
38 cargoHash = "sha256-1sqFjNil6KktpqrsXXgt3xtOz7eFQc2skkFHqmTMDg4=";
39
40 nativeBuildInputs = [
41 pkg-config
42 installShellFiles
43 ];
44
45 buildInputs = [ openssl ];
46
47 postFixup = lib.optionalString canRun ''
48 ${lychee} --generate man > lychee.1
49 installManPage lychee.1
50 '';
51
52 cargoTestFlags = [
53 # don't run doctests since they tend to use the network
54 "--lib"
55 "--bins"
56 "--tests"
57 ];
58
59 checkType = "debug"; # compilation fails otherwise
60
61 checkFlags = [
62 # Network errors for all of these tests
63 # "error reading DNS system conf: No such file or directory (os error 2)" } }
64 "--skip=archive::wayback::tests::wayback_suggestion_real_unknown"
65 "--skip=archive::wayback::tests::wayback_api_no_breaking_changes"
66 "--skip=cli::test_dont_dump_data_uris_by_default"
67 "--skip=cli::test_dump_data_uris_in_verbose_mode"
68 "--skip=cli::test_exclude_example_domains"
69 "--skip=cli::test_local_dir"
70 "--skip=cli::test_local_file"
71 "--skip=client::tests"
72 "--skip=collector::tests"
73 "--skip=commands::generate::tests::test_examples_work"
74 "--skip=src/lib.rs"
75 # Color error for those tests as we are not in a tty
76 "--skip=formatters::response::color::tests::test_format_response_with_error_status"
77 "--skip=formatters::response::color::tests::test_format_response_with_ok_status"
78 ];
79
80 passthru.tests = {
81 # NOTE: These assume that testers.lycheeLinkCheck uses this exact derivation.
82 # Which is true most of the time, but not necessarily after overriding.
83 ok = callPackage ./tests/ok.nix { };
84 fail = callPackage ./tests/fail.nix { };
85 fail-emptyDirectory = callPackage ./tests/fail-emptyDirectory.nix { };
86 network = testers.runNixOSTest ./tests/network.nix;
87 };
88
89 meta = {
90 description = "Fast, async, stream-based link checker written in Rust";
91 homepage = "https://github.com/lycheeverse/lychee";
92 downloadPage = "https://github.com/lycheeverse/lychee/releases/tag/lychee-v${version}";
93 license = with lib.licenses; [
94 asl20
95 mit
96 ];
97 maintainers = with lib.maintainers; [
98 totoroot
99 tuxinaut
100 ];
101 mainProgram = "lychee";
102 };
103}