-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
153 lines (134 loc) · 3.58 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
description = "Build a cargo workspace";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = {
nixpkgs,
crane,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
craneLib = (crane.mkLib pkgs).overrideToolchain (fenix.packages.${system}.stable.toolchain);
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./src
./lib
./egui-grid
./rust-nlopt
];
};
commonArgs = {
inherit src;
strictDeps = true;
nativeBuildInputs = [
pkgs.cmake
pkgs.gnumake
pkgs.pkg-config
pkgs.glib.out
pkgs.gtk3.out
pkgs.wrapGAppsHook3
pkgs.protobuf
pkgs.makeWrapper
pkgs.julia
];
buildInputs = [
pkgs.glib.out
pkgs.gtk3.out
];
};
dynamicRuntimeDeps = [
pkgs.libxkbcommon.out
pkgs.gtk3.out
pkgs.glib.out
pkgs.atk.out
pkgs.libglvnd.out
pkgs.libGL.out
pkgs.xorg.libX11.out
pkgs.xorg.libXrandr.out
pkgs.xorg.libXcursor.out
pkgs.xorg.libXi.out
pkgs.fontconfig.out
pkgs.wayland.out
pkgs.gdk-pixbuf.out
pkgs.cairo.out
pkgs.pango.out
pkgs.gsettings-desktop-schemas.out
pkgs.alacritty.out
pkgs.zlib.out
pkgs.blas
pkgs.gcc
pkgs.gfortran
pkgs.gfortran.cc.lib
pkgs.gnum4
pkgs.lapack
pkgs.libgccjit
pkgs.openblas
pkgs.perl
];
kerbtk-bin = craneLib.buildPackage (commonArgs
// {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
doCheck = false;
cargoExtraArgs = "-p kerbtk-bin";
preBuild = ''
export JULIA_DIR=${pkgs.julia}
'';
postInstall = ''
wrapProgram $out/bin/kerbtk-bin \
--suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath dynamicRuntimeDeps}
'';
});
in {
formatter = pkgs.alejandra;
packages = {
inherit kerbtk-bin;
default = kerbtk-bin;
};
apps = {
kerbtk-bin = flake-utils.lib.mkApp {
drv = kerbtk-bin;
};
};
devShells.default = craneLib.devShell rec {
nativeBuildInputs = kerbtk-bin.nativeBuildInputs;
buildInputs = kerbtk-bin.buildInputs;
packages =
nativeBuildInputs
++ buildInputs
++ dynamicRuntimeDeps
++ [
pkgs.clippy
pkgs.rustfmt
pkgs.rust-analyzer
];
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath packages;
shellHook = ''
export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
export JULIA_DIR=${pkgs.julia}
export NIX_LD_LIBRARY_PATH=${nixpkgs.lib.makeLibraryPath packages}
'';
};
});
}