AkechiShiro / arewehackersyet

Tracking the availability of Kali Linux packages in NixOS
https://akechishiro.github.io/arewehackersyet/index.html
10 stars 1 forks source link

Better automation of the kali-tools.nix file #1

Open AkechiShiro opened 5 months ago

AkechiShiro commented 5 months ago

There are a few improvements that could be made to fully automatically maintain, the tracker.

Automatically mark packages as todo if they raise a specific exception

An update to the nix code is needed to automatically mark the pkg as "todo" if

<pkgname> = pkgs.<pkgname>;

Does not exist in Nixpkgs unstable

raises not found attribute exception, such as this one :

Nix traceback
error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'are-we-hackers-yet-stats'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'buildCommand' of derivation 'are-we-hackers-yet-stats'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:98:16:

           97|         enableParallelBuilding = true;
           98|         inherit buildCommand name;
             |                ^
           99|         passAsFile = [ "buildCommand" ]

       … while evaluating derivation 'are-we-hackers-yet-stats-builder'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'text' of derivation 'are-we-hackers-yet-stats-builder'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:162:16:

          161|       ({
          162|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          163|         passAsFile = [ "text" ]

       … while evaluating derivation 'are-we-hackers-yet-stats-json'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'text' of derivation 'are-we-hackers-yet-stats-json'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:162:16:

          161|       ({
          162|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          163|         passAsFile = [ "text" ]

       … while calling anonymous lambda

         at /home/zwei/project/opensource/arewehackersyet/stats.nix:11:24:

           10|     mapAttrs
           11|       (_: mapAttrs (_: pkg: if isString pkg then pkg else pkg.meta.name))
             |                        ^
           12|       kali.kaliGroups;

       error: attribute '"0trace"' missing

       at /home/zwei/project/opensource/arewehackersyet/kali-tools.nix:9:14:

            8|
            9|   "0trace" = pkgs."0trace";
             |              ^
           10|   "arping | iputils-arping" = pkgs.arping;

Automatically mark packages as broken if they throw an error

At the moment, I don't know if there is a way to differentiate both errors for the current builder code, but they do not happen at the same code paths during evaluation.

Nix traceback
error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'are-we-hackers-yet-stats'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'buildCommand' of derivation 'are-we-hackers-yet-stats'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:98:16:

           97|         enableParallelBuilding = true;
           98|         inherit buildCommand name;
             |                ^
           99|         passAsFile = [ "buildCommand" ]

       … while evaluating derivation 'are-we-hackers-yet-stats-builder'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'text' of derivation 'are-we-hackers-yet-stats-builder'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:162:16:

          161|       ({
          162|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          163|         passAsFile = [ "text" ]

       … while evaluating derivation 'are-we-hackers-yet-stats-json'
         whose name attribute is located at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'text' of derivation 'are-we-hackers-yet-stats-json'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/build-support/trivial-builders/default.nix:162:16:

          161|       ({
          162|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          163|         passAsFile = [ "text" ]

       … while calling anonymous lambda

         at /home/zwei/project/opensource/arewehackersyet/stats.nix:11:24:

           10|     mapAttrs
           11|       (_: mapAttrs (_: pkg: if isString pkg then pkg else pkg.meta.name))
             |                        ^
           12|       kali.kaliGroups;

       … while calling anonymous lambda

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:45:11:

           44|     lib.mapAttrs
           45|       (n: alias:
             |           ^
           46|         removeDistribute

       … from call site

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:46:9:

           45|       (n: alias:
           46|         removeDistribute
             |         ^
           47|           (removeRecurseForDerivations

       … while calling 'removeDistribute'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:32:22:

           31|   # sets from building on Hydra.
           32|   removeDistribute = alias: with lib;
             |                      ^
           33|     if isDerivation alias then

       … from call site

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:33:8:

           32|   removeDistribute = alias: with lib;
           33|     if isDerivation alias then
             |        ^
           34|       dontDistribute alias

       … while calling 'isDerivation'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/lib/attrsets.nix:780:5:

          779|     # Value to check.
          780|     value: value.type or null == "derivation";
             |     ^
          781|

       … from call site

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:47:12:

           46|         removeDistribute
           47|           (removeRecurseForDerivations
             |            ^
           48|             (checkInPkgs n alias)))

       … while calling 'removeRecurseForDerivations'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:25:33:

           24|   # to appear while listing all the packages available.
           25|   removeRecurseForDerivations = alias: with lib;
             |                                 ^
           26|     if alias.recurseForDerivations or false

       … from call site

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:48:14:

           47|           (removeRecurseForDerivations
           48|             (checkInPkgs n alias)))
             |              ^
           49|       aliases;

       … while calling 'checkInPkgs'

         at /nix/store/hwcgg7k1fwaqszsfvx82jbva129xrdjb-source/pkgs/top-level/aliases.nix:38:20:

           37|   # Make sure that we are not shadowing something from all-packages.nix.
           38|   checkInPkgs = n: alias:
             |                    ^
           39|     if builtins.hasAttr n super

       error: gnuradio3_7 has been removed because it required Python 2
AkechiShiro commented 5 months ago

Usage of builtin.tryEval can allow evaluating if an expression did evaluate successfully and outputs a boolean (true or false).

However I'm still missing what kinds of errors did the evaluation trigger, in order to be able to filter at the error evaluation level, something more precise is needed.

Maybe checking with builtin.hasAttr "xyz" pkgs before accessing to pkgs.xyz, this would probably solve the issue if the pkgs does not exists.

But for packages that exists but are broken, it still isn't enough.