Skip to content

Commit

Permalink
Merge pull request #645 from PJungkamp/packaging-nix
Browse files Browse the repository at this point in the history
packaging-nix: Add `direnv` support and improve packaging
  • Loading branch information
stv0g authored Jun 1, 2023
2 parents ff86300 + 0c9f513 commit c5606d7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 35 deletions.
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if direnv_version "2.30.0" \
&& has nix \
&& nix show-config experimental-features 2>/dev/null | grep -wqF flakes
then
watch_file ./packaging/nix/*.nix
use flake ./packaging/nix
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.cproject
.settings/
.vscode/
.direnv/

*.egg-info/

Expand Down
31 changes: 23 additions & 8 deletions packaging/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
);
in {
formatter = forSupportedSystems (system: legacyPackages.${system}.alejandra);
packages = forSupportedSystems (system:
let pkgs = legacyPackages.${system};
packages = forSupportedSystems (
system: let
pkgs = legacyPackages.${system};
in rec {
default = villas;

Expand All @@ -62,23 +63,37 @@
};
}
);
devShells = forSupportedSystems (system:
let pkgs = legacyPackages.${system};
devShells = forSupportedSystems (
system: let
pkgs = legacyPackages.${system};
shellHook = ''
[ -z "$PS1" ] || exec $SHELL
'';
in rec {
default = full;

minimal = pkgs.mkShell {
inherit shellHook;
name = "minimal";
shellHook = "exec $SHELL";
inputsFrom = [ pkgs.villas-minimal ];
inputsFrom = [pkgs.villas-minimal];
};

full = pkgs.mkShell {
inherit shellHook;
name = "full";
shellHook = "exec $SHELL";
inputsFrom = [ pkgs.villas ];
inputsFrom = [pkgs.villas];
};
}
);
checks = forSupportedSystems (
system: let
pkgs = legacyPackages.${system};
in {
fmt = pkgs.runCommand "check-fmt" {} ''
cd ${self}
${pkgs.alejandra}/bin/alejandra --check . 2> $out
'';
}
);
};
}
2 changes: 1 addition & 1 deletion packaging/nix/lib60870.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmake,
lib,
stdenv,
src
src,
}:
stdenv.mkDerivation {
pname = "lib60870";
Expand Down
2 changes: 1 addition & 1 deletion packaging/nix/libiec61850.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmake,
lib,
stdenv,
src
src,
}:
stdenv.mkDerivation {
pname = "libiec61850";
Expand Down
51 changes: 26 additions & 25 deletions packaging/nix/villas.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
withNodeSocket ? withAllNodes,
# dependencies
comedilib,
coreutils,
curl,
czmq,
gnugrep,
Expand All @@ -48,7 +49,7 @@
protobufc,
rdkafka,
rdma-core,
spdlog
spdlog,
}:
stdenv.mkDerivation {
pname = "villas";
Expand All @@ -67,36 +68,36 @@ stdenv.mkDerivation {
'';
postInstall = ''
wrapProgram $out/bin/villas \
--set PATH ${lib.makeBinPath [(placeholder "out") gnugrep]}
--set PATH ${lib.makeBinPath [(placeholder "out") gnugrep coreutils]}
'';
nativeBuildInputs = [
cmake
makeWrapper
pkg-config
];
buildInputs = [
jansson
libwebsockets
libuuid
openssl
curl
spdlog
]
++ lib.optionals withConfig [libconfig]
++ lib.optionals withProtobuf [protobuf protobufc]
++ lib.optionals withNodeComedi [comedilib]
++ lib.optionals withNodeZeromq [czmq libsodium]
++ lib.optionals withNodeIec60870 [lib60870]
++ lib.optionals withNodeIec61850 [libiec61850]
++ lib.optionals withNodeSocket [libnl]
++ lib.optionals withNodeRtp [libre]
++ lib.optionals withNodeUldaq [libuldaq]
++ lib.optionals withNodeTemper [libusb]
++ lib.optionals withNodeMqtt [mosquitto]
++ lib.optionals withNodeNanomsg [nanomsg]
++ lib.optionals withNodeKafka [rdkafka]
++ lib.optionals withNodeInfiniband [rdma-core]
;
buildInputs =
[
jansson
libwebsockets
libuuid
openssl
curl
spdlog
]
++ lib.optionals withConfig [libconfig]
++ lib.optionals withProtobuf [protobuf protobufc]
++ lib.optionals withNodeComedi [comedilib]
++ lib.optionals withNodeZeromq [czmq libsodium]
++ lib.optionals withNodeIec60870 [lib60870]
++ lib.optionals withNodeIec61850 [libiec61850]
++ lib.optionals withNodeSocket [libnl]
++ lib.optionals withNodeRtp [libre]
++ lib.optionals withNodeUldaq [libuldaq]
++ lib.optionals withNodeTemper [libusb]
++ lib.optionals withNodeMqtt [mosquitto]
++ lib.optionals withNodeNanomsg [nanomsg]
++ lib.optionals withNodeKafka [rdkafka]
++ lib.optionals withNodeInfiniband [rdma-core];
meta = with lib; {
description = "a tool connecting real-time power grid simulation equipment";
homepage = "https://villas.fein-aachen.org/";
Expand Down

0 comments on commit c5606d7

Please sign in to comment.