enable building with nix

This commit is contained in:
eymeric
2024-04-08 22:47:59 +02:00
parent 31d8f4d773
commit e3fd1382e9
6 changed files with 146 additions and 0 deletions

1
.envrc Normal file
View File

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

3
.gitignore vendored
View File

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

View File

@@ -53,6 +53,17 @@ conda config --set channel_priority strict
conda install -c bkryza/label/clang-uml clang-uml conda install -c bkryza/label/clang-uml clang-uml
``` ```
#### nix
```bash
nix build
```
Or if you have flake enabled, you can also run
```bash
nix run github:/bkryza/clang-uml
```
#### Windows #### Windows
Download and run the latest Windows installer from Download and run the latest Windows installer from

64
flake.lock generated Normal file
View File

@@ -0,0 +1,64 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"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": 1712512205,
"narHash": "sha256-CrKKps0h7FoagRcE2LT3h/72Z64D0Oh83UF1XZVhCLQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3c1b6f75344e207a67536d834886ee9b4577ebe7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

33
flake.nix Normal file
View File

@@ -0,0 +1,33 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [];
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
packages.default = config.packages.clang-uml;
packages.clang-uml = pkgs.callPackage packaging/nix/default.nix { };
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# C++ Compiler is already part of stdenv
cmake
llvmPackages_latest.libllvm
yaml-cpp
ccache
elfutils
pkg-config
clang
libclang
];
};
};
};
}

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

@@ -0,0 +1,34 @@
{ pkgs ? import <nixpkgs> {} }:
# Nix derivation for basic C++ project using clang
with pkgs; stdenv.mkDerivation {
name = "clang-uml";
src = ../..;
buildInputs = [
clang
libclang
cmake
llvmPackages_latest.libllvm
yaml-cpp
ccache
elfutils
pkg-config
];
dontUseCmakeConfigure = true;
buildPhase = "CCACHE_DIR=/build/.ccache make release";
installPhase = ''
mkdir -p $out/bin
cp release/src/clang-uml $out/bin/clang-uml
'';
postInstall = "
installShellCompletion --cmd clang-uml \
--zsh packaging/autocomplete/_clang-uml
--bach packaging/autocomplete/clang-uml
";
}