Domani connects your domain to whatever you want to host on it, all with no account needed
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
domani/flake.nix

93 lines
3.0 KiB

{
inputs = {
naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
buildTargetsBySystem = {
"x86_64-linux" = "x86_64-unknown-linux-musl";
"aarch64-linux" = "aarch64-unknown-linux-musl";
};
eachCrossSystem = callback: (builtins.foldl'
(overall: buildSystem: overall // {
${buildSystem} = (builtins.foldl'
(inner: hostSystem: inner // {
"cross-${hostSystem}" = callback buildSystem hostSystem;
})
{ default = callback buildSystem buildSystem; }
supportedSystems
);
})
{}
supportedSystems
);
mkPkgs = buildSystem: hostSystem: import nixpkgs {
system = buildSystem;
overlays = [
(import rust-overlay)
(final: prev: {
rust-toolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
})
];
} // (if buildSystem == hostSystem then {} else {
# The nixpkgs cache doesn't have any packages where cross-compiling has
# been enabled, even if the target platform is actually the same as the
# build platform (and therefore it's not really cross-compiling). So we
# only set up the cross-compiling config if the target platform is
# different.
crossSystem.config = hostSystem;
});
mkRustEnv = pkgs: {
OPENSSL_STATIC = "1";
OPENSSL_LIB_DIR = "${pkgs.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.pkgsStatic.openssl.dev}/include";
CARGO_BUILD_TARGET = buildTargetsBySystem.${pkgs.stdenv.hostPlatform.system};
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
};
in
{
packages = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem hostSystem;
naersk-lib = pkgs.callPackage naersk {
cargo = pkgs.rust-toolchain;
rustc = pkgs.rust-toolchain;
};
rustEnv = mkRustEnv pkgs;
in
naersk-lib.buildPackage ({
src = ./.;
doCheck = false;
nativeBuildInputs = [ pkgs.pkgsStatic.stdenv.cc ];
} // rustEnv)
);
devShells = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem hostSystem;
rustEnv = mkRustEnv pkgs;
in
pkgs.mkShell ({
nativeBuildInputs = [
pkgs.stdenv.cc
pkgs.openssl
pkgs.rust-toolchain
pkgs.nmap # ncat
];
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
if [ -f "config.yml" ]; then
export DOMANI_CONFIG_PATH=config-dev.yml
fi
'';
} // rustEnv));
};
}