diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..a5dbbcba --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index 74c9721d..de6d13d3 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,10 @@ coverage*.info packaging/_BUILD packaging/conda/meta.yaml +#nix +.direnv/ +result + # CLion .idea/ diff --git a/docs/installation.md b/docs/installation.md index f009d6c0..19b9f3ea 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -53,6 +53,23 @@ conda config --set channel_priority strict conda install -c bkryza/label/clang-uml clang-uml ``` +#### nix + +```bash +git clone https://github.com/bkryza/clang-uml + +# To build using nix flakes +nix --extra-experimental-features 'nix-command flakes' build + +# or without nix flakes +nix-build -E 'with import { }; callPackage ./packaging/nix { }' +``` + +Or if you have flake enabled, you can also directly run +```bash +nix run github:bkryza/clang-uml +``` + #### Windows Download and run the latest Windows installer from diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..c5276dea --- /dev/null +++ b/flake.lock @@ -0,0 +1,45 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712163089, + "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=", + "path": "/nix/store/n2g5cqwv8qf5p6vjxny6pg3blbdij12k-source", + "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..6500bb0f --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "C++ UML diagram generator based on Clang"; + + inputs = { + nixpkgs.url = "nixpkgs"; + + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + }; + + outputs = {flake-parts, ...} @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; + + perSystem = { + self', + pkgs, + ... + }: { + packages = { + default = self'.packages.clang-uml; + clang-uml = pkgs.callPackage ./packaging/nix {}; + }; + + devShells.default = pkgs.mkShell { + inputsFrom = [self'.packages.clang-uml]; + }; + + formatter = pkgs.alejandra; + }; + }; +} diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix new file mode 100644 index 00000000..b66794fb --- /dev/null +++ b/packaging/nix/default.nix @@ -0,0 +1,30 @@ +{ + stdenv, + cmake, + pkg-config, + installShellFiles, + libclang, + libllvm, + yaml-cpp, +}: +stdenv.mkDerivation { + name = "clang-uml"; + src = ../..; + + nativeBuildInputs = [ + cmake + pkg-config + installShellFiles + ]; + + buildInputs = [ + libclang + libllvm + yaml-cpp + ]; + + postInstall = '' + installShellCompletion --bash $src/packaging/autocomplete/clang-uml + installShellCompletion --zsh $src/packaging/autocomplete/_clang-uml + ''; +}