domani/flake.nix

60 lines
1.6 KiB
Nix
Raw Normal View History

2023-05-03 07:58:06 +00:00
{
inputs = {
naersk.url = "github:nix-community/naersk/master";
2023-05-04 12:56:31 +00:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
2023-05-03 07:58:06 +00:00
utils.url = "github:numtide/flake-utils";
2023-05-08 16:25:51 +00:00
rust-overlay.url = "github:oxalica/rust-overlay";
2023-05-03 07:58:06 +00:00
};
2023-05-08 16:25:51 +00:00
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
2023-05-03 07:58:06 +00:00
utils.lib.eachDefaultSystem (system:
let
2023-05-08 16:25:51 +00:00
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk-lib = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};
opensslEnv = {
OPENSSL_STATIC = "1";
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}/include";
};
2023-05-03 07:58:06 +00:00
in
{
defaultPackage = naersk-lib.buildPackage ({
2023-05-15 20:58:40 +00:00
src = ./.;
doCheck = false;
nativeBuildInputs = [ pkgs.pkgsStatic.stdenv.cc ];
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
} // opensslEnv);
2023-05-16 14:20:01 +00:00
devShell = pkgs.mkShell ({
2023-05-08 16:25:51 +00:00
nativeBuildInputs = [
pkgs.stdenv.cc
pkgs.openssl
2023-05-08 16:25:51 +00:00
toolchain
pkgs.nmap # ncat
2023-05-08 16:25:51 +00:00
];
2023-05-04 12:56:31 +00:00
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
if [ -f "config.yml" ]; then
export DOMANI_CONFIG_PATH=config.yml
fi
2023-05-04 12:56:31 +00:00
'';
} // opensslEnv);
2023-05-03 07:58:06 +00:00
});
}