Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debugger tools to C language pack #1216

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

k3yss
Copy link
Collaborator

@k3yss k3yss commented May 20, 2024

This PR adds gdb and valgrind to the list of default packages, which are important tools for developing with C.

@domenkozar
Copy link
Member

Package ‘valgrind-3.22.0’ in /nix/store/virtual0000000000000000000000007-source/pkgs/development/tools/analysis/valgrind/default.nix:118 is marked as broken, refusing to evaluate.

@k3yss k3yss force-pushed the work/keys/c-language-debugger branch from f942654 to 7555781 Compare June 9, 2024 18:52
@k3yss
Copy link
Collaborator Author

k3yss commented Jun 9, 2024

@domenkozar the latest commit should fix the issue.

For future reference, how do one know which packages are broken?

@k3yss k3yss force-pushed the work/keys/c-language-debugger branch from 2227060 to 55ec49b Compare June 10, 2024 16:47
@sandydoo sandydoo merged commit ad779fe into cachix:main Jun 12, 2024
252 of 267 checks passed
@k3yss k3yss deleted the work/keys/c-language-debugger branch June 12, 2024 11:57
@gador
Copy link

gador commented Sep 11, 2024

I've run into an error due to this PR on aarch64 when using rust:

Backtrace
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = d<erivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'devenv-shell'
         whose name attribute is located at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'CFLAGS' of derivation 'devenv-shell'

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:1571:24:
         1570|     let f = attrPath:
         1571|       zipAttrsWith (n: values:
             |                        ^
         1572|         let here = attrPath ++ [n]; in

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/types.nix:607:29:
          606|       merge = loc: defs:
          607|         zipAttrsWith (name: defs:
             |                             ^
          608|           let merged = mergeDefinitions (loc ++ [name]) elemType defs;

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:836:28:
          835|         # Process mkMerge and mkIf properties.
          836|         defs' = concatMap (m:
             |                            ^
          837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/virtual0000000000000000000000008-source/src/modules/languages/rust.nix':

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:837:128:
          836|         defs' = concatMap (m:
          837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                ^
          838|         ) defs;

       … while calling 'dischargeProperties'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:908:25:
          907|   */
          908|   dischargeProperties = def:
             |                         ^
          909|     if def._type or "" == "merge" then

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:273:39:
          272|         then value
          273|         else { ${elemAt attrPath n} = atDepth (n + 1); };
             |                                       ^
          274|     in atDepth 0;

       … while calling 'atDepth'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:270:17:
          269|       len = length attrPath;
          270|       atDepth = n:
             |                 ^
          271|         if n == len

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/languages/rust.nix:141:22:
          140|             RUSTDOCFLAGS = "${moldFlags}";
          141|             CFLAGS = lib.optionalString pkgs.stdenv.isDarwin "-iframework ${config.devenv.profile}/Library/Frameworks";
             |                      ^
          142|           };

       … while calling 'optionalString'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/strings.nix:677:5:
          676|     cond:
          677|     string: if cond then string else "";
             |     ^
          678|

       … while evaluating derivation 'devenv-profile'
         whose name attribute is located at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'passAsFile' of derivation 'devenv-profile'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/build-support/trivial-builders/default.nix:60:9:
           59|         inherit buildCommand name;
           60|         passAsFile = [ "buildCommand" ]
             |         ^
           61|           ++ (derivationArgs.passAsFile or [ ]);

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/top-level.nix:15:13:
           14|     name = "devenv-profile";
           15|     paths = lib.flatten (builtins.map drvOrPackageToPaths config.packages);
             |             ^
           16|     ignoreCollisions = true;

       … while calling 'flatten'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/lists.nix:431:13:
          430|   */
          431|   flatten = x:
             |             ^
          432|     if isList x

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/top-level.nix:15:59:
           14|     name = "devenv-profile";
           15|     paths = lib.flatten (builtins.map drvOrPackageToPaths config.packages);
             |                                                           ^
           16|     ignoreCollisions = true;

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:1205:18:
         1204|         mapAttrs
         1205|           (name: value:
             |                  ^
         1206|             if isAttrs value && cond value

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:1208:18:
         1207|             then recurse (path ++ [ name ]) value
         1208|             else f (path ++ [ name ]) value);
             |                  ^
         1209|     in

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:254:72:
          253|           # For definitions that have an associated option
          254|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          255|

       … while evaluating the option `packages':

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:836:28:
          835|         # Process mkMerge and mkIf properties.
          836|         defs' = concatMap (m:
             |                            ^
          837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/virtual0000000000000000000000008-source/src/modules/languages/c.nix':

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:837:128:
          836|         defs' = concatMap (m:
          837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                ^
          838|         ) defs;

       … while calling 'dischargeProperties'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:908:25:
          907|   */
          908|   dischargeProperties = def:
             |                         ^
          909|     if def._type or "" == "merge" then

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:914:11:
          913|         if def.condition then
          914|           dischargeProperties def.content
             |           ^
          915|         else

       … while calling 'dischargeProperties'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:908:25:
          907|   */
          908|   dischargeProperties = def:
             |                         ^
          909|     if def._type or "" == "merge" then

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/languages/c.nix:30:10:
           29|       pkg-config
           30|     ] ++ lib.optional (cfg.debugger != null) cfg.debugger
             |          ^
           31|     ++ lib.optional (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.valgrind && !pkgs.valgrind.meta.broken) pkgs.valgrind;

       … while calling 'optional'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/lists.nix:784:20:
          783|   */
          784|   optional = cond: elem: if cond then [elem] else [];
             |                    ^
          785|

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/languages/c.nix:30:24:
           29|       pkg-config
           30|     ] ++ lib.optional (cfg.debugger != null) cfg.debugger
             |                        ^
           31|     ++ lib.optional (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.valgrind && !pkgs.valgrind.meta.broken) pkgs.valgrind;

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:1205:18:
         1204|         mapAttrs
         1205|           (name: value:
             |                  ^
         1206|             if isAttrs value && cond value

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/attrsets.nix:1208:18:
         1207|             then recurse (path ++ [ name ]) value
         1208|             else f (path ++ [ name ]) value);
             |                  ^
         1209|     in

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:254:72:
          253|           # For definitions that have an associated option
          254|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          255|

       … while evaluating the option `languages.c.debugger':

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/modules.nix:846:19:
          845|           # Avoid sorting if we don't have to.
          846|           if any (def: def.value._type or "" == "order") defs''.values
             |                   ^
          847|           then sortProperties defs''.values

       … from call site
         at «github:cachix/devenv/b3d6c84d66618197b47a8baa8d00d1d9d283a93c»/src/modules/languages/c.nix:13:12:
           12|       default =
           13|         if lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.gdb
             |            ^
           14|         then pkgs.gdb

       … while calling 'availableOn'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/meta.nix:289:27:
          288|   */
          289|   availableOn = platform: pkg:
             |                           ^
          290|     ((!pkg?meta.platforms) || any (platformMatch platform) pkg.meta.platforms) &&

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/top-level/all-packages.nix:19135:9:
        19134|
        19135|   gdb = callPackage ../development/tools/misc/gdb {
             |         ^
        19136|     guile = null;

       … while calling 'callPackageWith'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/customisation.nix:212:35:
          211|   */
          212|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          213|     let

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/trivial.nix:957:7:
          956|     { # TODO: Should we add call-time "type" checking like built in?
          957|       __functor = self: f;
             |       ^
          958|       __functionArgs = args;

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/customisation.nix:136:17:
          135|     in
          136|     mirrorArgs (origArgs:
             |                 ^
          137|     let

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/customisation.nix:138:16:
          137|     let
          138|       result = f origArgs;
             |                ^
          139|

       … while calling anonymous lambda
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/development/tools/misc/gdb/default.nix:1:1:
            1| { lib, stdenv, targetPackages
             | ^
            2|

       … from call site
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/pkgs/development/tools/misc/gdb/default.nix:30:8:
           29| assert pythonSupport -> python3 != null;
           30| assert lib.asserts.assertMsg (stdenv.targetPlatform.system != "aarch64-darwin") "GDB does not support aarch64-darwin as a target";
             |        ^
           31|

       … while calling 'assertMsg'
         at «git+https://git.flo-the.dev/gador/nixpkgs?ref=current&rev=26b80fadab685866e7e69c4e70fb71234e8b2787»/lib/asserts.nix:41:5:
           40|     pred:
           41|     msg:
             |     ^
           42|     pred || builtins.throw msg;

       error:
       error: GDB does not support aarch64-darwin as a target

My config:

{
  pkgs,
  lib,
  config,
  inputs,
  ...
}:

rec {
  # https://devenv.sh/packages/
  packages =
    with pkgs;
    [
      git
      sqlite
      sqlitebrowser
    ]
    ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ darwin.apple_sdk.frameworks.AppKit ])
    ++ lib.optionals pkgs.stdenv.isLinux (
      with pkgs;
      [
        glib
        gtk3
        trunk

        # misc. libraries
        openssl

        # GUI libs
        libxkbcommon
        libGL
        fontconfig
        vulkan-loader

        # wayland libraries
        wayland

        # x11 libraries
        xorg.libXcursor
        xorg.libXrandr
        xorg.libXi
        xorg.libX11
      ]
    );

  # https://devenv.sh/languages/
  languages.rust.enable = true;
  languages.rust.channel = "stable";
  languages.rust.targets = [ "wasm32-unknown-unknown" ];

  env.LD_LIBRARY_PATH = lib.makeLibraryPath packages;

  pre-commit.hooks = {
    nixfmt.enable = true;
    nixfmt.package = pkgs.nixfmt-rfc-style;
    detect-private-keys.enable = true;
    detect-private-keys.excludes = [ "tests/" ];
  };
}

If I add languages.c.debugger = null; it works again.

I'm not sure, why the c debugger is even included here, but obviously the platform check from this PR fails.

@domenkozar
Copy link
Member

@k3yss let's disable gdb for aarch64-linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants