tlaternet-webserver/flake.nix

73 lines
2.1 KiB
Nix

{
description = "tlater.net web server";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
naersk = {
url = "github:nmattia/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, naersk }@inputs:
flake-utils.lib.simpleFlake {
inherit self nixpkgs;
name = "tlaternet-webserver";
preOverlays = [ rust-overlay.overlay ];
overlay = final: prev: {
tlaternet-webserver = let
# The rust toolchain to use
toolchain =
prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# The rust build lib, set to use the toolchain
naersk-lib = naersk.lib.${prev.system}.override {
cargo = toolchain;
rustc = toolchain;
};
# pkg-config, needed to include many native libs
nativeBuildInputs = [ prev.pkgconfig ];
# Native libs
buildInputs = [ prev.openssl ];
in rec {
# The packages provided by this flake
packages = {
webserver = prev.callPackage
({ rustPlatform, openssl, pkgconfig, ... }:
naersk-lib.buildPackage {
inherit nativeBuildInputs buildInputs;
pname = "tlaternet-webserver";
root = ./.;
}) { };
};
defaultPackage = packages.webserver;
# A dev shell to hack manually; note this includes
# additional toolchain components
devShell = prev.mkShell {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ [
(toolchain.override {
extensions =
[ "rust-src" "rust-analysis" "rust-analyzer-preview" ];
})
];
};
};
};
};
}