tlaternet-webserver/flake.nix

83 lines
2.1 KiB
Nix
Raw Normal View History

{
description = "tlater.net web server";
inputs = {
2022-06-20 14:46:36 +01:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
2022-08-13 21:44:31 +01:00
inputs.nixpkgs.follows = "nixpkgs";
};
2021-03-31 22:25:44 +01:00
naersk = {
url = "github:nmattia/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-08-13 21:44:31 +01:00
tlaternet-templates = {
url = "git+https://gitea.tlater.net/tlaternet/tlaternet.git";
# No need to override anything here; we can save some downloads
# if we rely on the webserver to do that.
};
};
2021-03-31 22:25:44 +01:00
2022-08-13 21:44:31 +01:00
outputs = {
self,
nixpkgs,
rust-overlay,
naersk,
tlaternet-templates,
}: let
# At the moment, we only deploy to x86_64-linux. Update when we
# care about another platform.
system = "x86_64-linux";
overlays = [
rust-overlay.overlays.default
];
pkgs = import nixpkgs {inherit system overlays;};
2021-03-31 22:25:44 +01:00
2022-08-13 21:44:31 +01:00
# Rust build config
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk-lib = naersk.lib.${system}.override {
cargo = rust-toolchain;
rustc = rust-toolchain;
};
buildInputs = with pkgs; [
pkg-config
openssl
];
in {
packages.${system} = rec {
tlaternet-webserver = naersk-lib.buildPackage {
inherit buildInputs;
pname = "tlaternet-webserver";
root = pkgs.lib.cleanSource self;
};
default = tlaternet-webserver;
};
2021-03-31 22:25:44 +01:00
2022-08-13 21:44:31 +01:00
apps.${system} = {
run-with-templates = let
script = pkgs.writeShellScriptBin "run-with-templates" ''
export ROCKET_TEMPLATE_DIR=${tlaternet-templates.packages.${system}.tlaternet-templates}
${self.packages.${system}.tlaternet-webserver}/bin/tlaternet-webserver
'';
in {
type = "app";
program = "${script}/bin/run-with-templates";
};
};
2021-03-31 22:25:44 +01:00
2022-08-13 21:44:31 +01:00
devShells.${system} = {
default = pkgs.mkShell {
packages = builtins.concatLists [
buildInputs
[
(rust-toolchain.override {
extensions = ["rust-src" "rust-analysis" "rust-analyzer-preview"];
})
]
];
2021-03-31 22:25:44 +01:00
};
};
2022-08-13 21:44:31 +01:00
};
}