Merge pull request #258 from hatch01/master

enable building with nix
This commit is contained in:
Bartek Kryza
2024-04-17 18:04:56 +02:00
committed by GitHub
6 changed files with 131 additions and 0 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake .

4
.gitignore vendored
View File

@@ -33,6 +33,10 @@ coverage*.info
packaging/_BUILD
packaging/conda/meta.yaml
#nix
.direnv/
result
# CLion
.idea/

View File

@@ -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 <nixpkgs> { }; 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

45
flake.lock generated Normal file
View File

@@ -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
}

34
flake.nix Normal file
View File

@@ -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;
};
};
}

30
packaging/nix/default.nix Normal file
View File

@@ -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
'';
}