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

103 lines
3.3 KiB

1 year ago
{
inputs = {
naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
1 year ago
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
1 year ago
};
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
let
buildTargetsBySystem = {
"x86_64-linux" = "x86_64-unknown-linux-musl";
"i686-linux" = "i686-unknown-linux-musl";
"aarch64-linux" = "aarch64-unknown-linux-musl";
};
supportedSystems = builtins.attrNames buildTargetsBySystem;
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 = crossPkgs: hostSystem: {
OPENSSL_STATIC = "1";
OPENSSL_LIB_DIR = "${crossPkgs.pkgsStatic.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${crossPkgs.pkgsStatic.openssl.dev}/include";
CARGO_BUILD_TARGET = buildTargetsBySystem.${hostSystem};
CARGO_BUILD_RUSTFLAGS = [
"-C" "target-feature=+crt-static"
"-C" "linker=${crossPkgs.stdenv.cc}/bin/${crossPkgs.stdenv.cc.targetPrefix}cc"
"-C" "link-arg=-static"
];
};
in
{
packages = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem buildSystem;
crossPkgs = mkPkgs buildSystem hostSystem;
naersk-lib = pkgs.callPackage naersk {
cargo = pkgs.rust-toolchain;
rustc = pkgs.rust-toolchain;
};
rustEnv = mkRustEnv crossPkgs hostSystem;
1 year ago
in
naersk-lib.buildPackage ({
src = ./.;
doCheck = false;
nativeBuildInputs = [ crossPkgs.pkgsStatic.stdenv.cc ];
} // rustEnv)
);
devShells = eachCrossSystem (buildSystem: hostSystem: let
pkgs = mkPkgs buildSystem buildSystem;
crossPkgs = mkPkgs buildSystem hostSystem;
rustEnv = mkRustEnv crossPkgs hostSystem;
in
pkgs.mkShell ({
nativeBuildInputs = [
crossPkgs.stdenv.cc
crossPkgs.openssl
pkgs.nmap # ncat
pkgs.rust-toolchain
];
shellHook = ''
export CARGO_HOME=$(pwd)/.cargo
if [ -f "config.yml" ]; then
export DOMANI_CONFIG_PATH=config-dev.yml
fi
'';
} // rustEnv));
};
1 year ago
}