bkryza / clang-uml

Customizable automatic UML diagram generator for C++ based on Clang.
Apache License 2.0
592 stars 40 forks source link

packaging: add nixpkgs avalability and make wrapped script the default #286

Closed hatch01 closed 3 months ago

hatch01 commented 3 months ago

Just a small doc modification to indicate that now clang-UML is available in nixpkgs, so users don't really need to build it themselves unless they want a specific version directly from a git branch.

bkryza commented 3 months ago

@hatch01 Thanks for the update. However it doesn't seem to work for me in nix docker:

❯ docker pull nixos/nix
Using default tag: latest
latest: Pulling from nixos/nix
Digest: sha256:a53abaf5242b3e94ad0adce074c386d62eeeb73ec8571ffa28b1ba3f0b2576c9
Status: Image is up to date for nixos/nix:latest
docker.io/nixos/nix:latest
❯ docker run --rm -it nixos/nix
bash-5.2# nix-shell -p clang-uml
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'buildInputs' of derivation 'shell'
         at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:
          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: undefined variable 'clang-uml'
       at «string»:1:107:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (clang-uml) ]; } ""
             | 

Also, is it possible to control which version is installed? Is it always latest tag or latest commit from master?

hatch01 commented 3 months ago

Oh, my bad it has been merged into master but clang-UML is not yet propagated to all the nixpkgs versions. https://github.com/NixOS/nixpkgs/pull/304749 https://nixpk.gs/pr-tracker.html?pr=304749 You are right, we may need to wait until it come to the stable version of nixpkgs.

bkryza commented 3 months ago

No problem. Anyway, I have a question - when I release a new version, do I need to do something,e.g. register it nixpgs somehow manually or is it somehow automated?

hatch01 commented 3 months ago

We need to register the update manually. However, as I am the maintainer of nixpkgs, I will get a notification when you make a new release to ask me to update. However, you can also make a PR on nixpkgs to update the package by yourself.

bkryza commented 3 months ago

@hatch01 Ok great thanks. Could you also just add a comment in the installation.md which version nix-shell -p clang-uml installs, or at least that it may not yet be the latest version (I'll keep it updated manually)...

hatch01 commented 3 months ago

Yes, but it can depend on which version of nixpkgs the user is using. The best way to know that is just to look at search.nixos.org (which any nix user now)

bkryza commented 3 months ago

Ok.

hatch01 commented 3 months ago

clang-uml is now available in nixos-unstable

bkryza commented 3 months ago

@hatch01 I can see it online in the package registry, but the command still doesn't work:

❯ docker run --rm -it nixos/nix
bash-5.2# nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
bash-5.2# nix-shell -p clang-uml
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'buildInputs' of derivation 'shell'
         at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:
          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: undefined variable 'clang-uml'
       at «string»:1:107:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (clang-uml) ]; } ""
             | 

Also, I've noticed that on this page it shows that the package provides 2 binaries:

image

While in the last PR for this we've added a clang-uml-wrapped command: https://github.com/bkryza/clang-uml/blob/6a1322b04c5b12d29a7b1bc2736159313f65bd2f/packaging/nix/default.nix#L36

Is that correct?

hatch01 commented 3 months ago

You probably can't access clang-uml because you need to switch to unstable : https://nixos.org/manual/nixos/unstable/#sec-upgrading And yes I choosed to set the wrapped as the default because it seems to work well and most of the packages in nixpkgs work like this. And if there's problems, the unwrapped is still available.

bkryza commented 3 months ago

@hatch01

You probably can't access clang-uml because you need to switch to unstable : https://nixos.org/manual/nixos/unstable/#sec-upgrading

Can you give list of steps I need to do to see that it works? I tried:

bash-5.2# nix-channel --add https://channels.nixos.org/nixos-unstable nixos
bash-5.2# nix-shell -p clang-uml
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'buildInputs' of derivation 'shell'
         at /nix/store/wj83y3qvj8v29d5zz0fih03682jf6qr1-b9zng82injl4hg2cywz0ql8s9jiylnw0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:
          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: undefined variable 'clang-uml'
       at «string»:1:107:
            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (clang-uml) ]; } ""
             |                                                                                                           ^
bash-5.2# nix-channel --list
nixos https://channels.nixos.org/nixos-unstable
nixpkgs https://nixos.org/channels/nixpkgs-unstable

and still the same error.

And yes I choosed to set the wrapped as the default because it seems to work well and most of the packages in nixpkgs work like this.

But where is that logic now? If this has changed can you also please update:

hatch01 commented 3 months ago

Can you give list of steps I need to do to see that it works? I tried:

podman run -it nixos/nix
nix-channel --add https://channels.nixos.org/nixos-unstable nixos
nix-channel --update
nix-shell -p clang-uml
hatch01 commented 3 months ago

But where is that logic now? If this has changed can you also please update: Yes, you are right it make much more sense to update in the repo.

bkryza commented 3 months ago

@hatch01 Ok thanks, I was missing nix-channel --update :-)