-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
123 lines (114 loc) · 4.21 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
description = "A flake for building and developing uml-cpp with nix";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.egm.url = "github:nemears/egm";
outputs = { self, nixpkgs, flake-utils, egm }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
mkUmlCpp = { src } :
let
# this is how im reading the version from the meson.build might not be most efficient but works
currentVersion = pkgs.runCommandWith {
name = "getVersion";
derivationArgs.nativBuildInputs = [ src ] ;
} "grep -Po \"(?<=version: ').*(?=')\" ${src}/meson.build > $out";
version = builtins.readFile currentVersion;
in
pkgs.stdenv.mkDerivation {
inherit src;
name = "uml-cpp";
nativeBuildInputs = with pkgs; [ pkg-config ];
installPhase = ''
mkdir -p $out/lib/pkgconfig $out/include
cp -r $src/include/uml $out/include
echo "prefix=$out
Name: uml
Description: uml modeling C++ api
Version: ${version}
Cflags: -I$out/include" > $out/lib/pkgconfig/uml-cpp.pc
'';
};
# function to create uml-cpp derivation from certain source
mkUmlCppPre05 = { src , version } : pkgs.stdenv.mkDerivation {
inherit src;
name = "uml-cpp";
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [cmake pkg-config clang gnumake coreutils yaml-cpp egm.outputs.packages.${system}.default ];
cmakeFlags = [
"-DUML_BUILD_TESTS=OFF"
"-DCMAKE_BUILD_TYPE=RELEASE"
];
installPhase =
''
mkdir -p $out/lib/pkgconfig $out/include
cp -r libuml.so $out/lib
cp -r $src/include/uml $out/include
touch $out/lib/pkgconfig/uml-cpp.pc
echo "prefix=$out
Name: uml
Description: uml modeling C++ api
Version: ${version}
Libs: -L$out/lib -luml
Cflags: -I$out/include" > $out/lib/pkgconfig/uml-cpp.pc
export PKG_CONFIG_PATH=PKG_CONFIG_PATH:$out/lib/pkgconfig
'';
};
in
{
# dev shell for nix develop (good for commandline dev)
devShells.default = (pkgs.mkShell.override { stdenv = pkgs.clangStdenv; }) {
packages = with pkgs; [
# build dependencies
clang
meson
ninja
pkg-config
gtest
yaml-cpp
egm.outputs.packages.${system}.default
# dev dependencies
websocketpp
asio
openssl
# debug dependencies
gdb
valgrind
];
stdenv = pkgs.clangStdenv;
};
packages = {
uml-cpp_0_4_2= pkgs.stdenvNoCC.mkDerivation {
src = pkgs.fetchurl {
url = "https://github.com/nemears/uml-cpp/releases/download/v0.4.2/uml-cpp-0.4.2.tar.gz";
hash = "sha256-82tcL2GUFo/MH3cJTch7dZINF/54GPAXoMYEzHXHWLo=";
};
name = "uml-cpp";
installPhase = ''
mkdir $out
cp -r . $out
'';
};
uml-cpp = mkUmlCpp {
src = ./.;
};
uml-cpp_0_3_5 = mkUmlCppPre05 {
src = pkgs.fetchFromGitHub {
owner = "nemears";
repo = "uml-cpp";
rev = "v0.3.5";
hash = "sha256-HzzOe+9s67LwWlHWYIa+vxbWMBVCsVY7RXfFDkElwpY=";
};
version = "0.3.5";
};
default = self.packages.${system}.uml-cpp;
};
overlay = final : prev: {
uml-cpp = self.packages.${system}.uml-cpp;
uml-cpp_0_3_5 = self.packages.${system}.uml-cpp_0_3_5;
};
}
);
}