Skip to content

Commit f67eb09

Browse files
committed
nix: Add clang-built package and devShell
Signed-off-by: Philipp Jungkamp <[email protected]>
1 parent cab6e02 commit f67eb09

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

flake.nix

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
withAllNodes = true;
7474
};
7575

76+
villas-node-clang = pkgs.villas-node.override {
77+
stdenv = pkgs.clangStdenv;
78+
};
79+
7680
dockerImage = pkgs.dockerTools.buildLayeredImage {
7781
name = "villas-node";
7882
tag = "latest-nix";
@@ -81,7 +85,6 @@
8185
};
8286

8387
# Cross-compiled packages
84-
8588
villas-node-x86_64-linux = if pkgs.system == "x86_64-linux" then pkgs.villas-node else pkgs.pkgsCross.x86_64-linux.villas-node;
8689
villas-node-aarch64-linux = if pkgs.system == "aarch64-linux" then pkgs.villas-node else pkgs.pkgsCross.aarch64-multiplatform.villas-node;
8790

@@ -126,7 +129,7 @@
126129
system:
127130
let
128131
pkgs = devPkgsFor system;
129-
hardeningDisable = [ "all" ];
132+
130133
packages = with pkgs; [
131134
bashInteractive
132135
bc
@@ -142,19 +145,35 @@
142145
pre-commit
143146
ruby # for pre-commit markdownlint hook
144147
];
148+
149+
mkShellFor = stdenv: pkg: stdenv.mkDerivation {
150+
name = "${pkg.pname}-${stdenv.cc.cc.pname}-devShell";
151+
152+
# disable all hardening to suppress warnings in debug builds
153+
hardeningDisable = [ "all" ];
154+
155+
# inherit inputs from pkg
156+
buildInputs = pkg.buildInputs ++ packages;
157+
nativeBuildInputs = pkg.nativeBuildInputs ++ packages;
158+
propagatedBuildInputs = pkg.propagatedBuildInputs;
159+
propagatedNativeBuildInputs = pkg.propagatedNativeBuildInputs;
160+
161+
# configure nix-ld for pre-commit
162+
env = {
163+
NIX_LD = lib.fileContents "${stdenv.cc}/nix-support/dynamic-linker";
164+
NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.gcc-unwrapped.lib ];
165+
};
166+
};
145167
in
146168
rec {
147-
default = full;
169+
default = gcc;
148170

149-
full = pkgs.mkShell {
150-
inherit hardeningDisable packages;
151-
name = "full";
152-
inputsFrom = with pkgs; [ villas-node ];
153-
};
171+
gcc = mkShellFor pkgs.stdenv pkgs.villas-node;
172+
clang = mkShellFor pkgs.clangStdenv pkgs.villas-node;
154173

155174
python = pkgs.mkShell {
156-
inherit hardeningDisable;
157-
name = "python";
175+
name = "villas-python-devShell";
176+
hardeningDisable = [ "all" ];
158177
inputsFrom = with pkgs; [ villas-node-python ];
159178
packages =
160179
with pkgs;

0 commit comments

Comments
 (0)