{ description = "tlater.net web server"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; naersk = { url = "github:nmattia/naersk"; inputs.nixpkgs.follows = "nixpkgs"; }; 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. }; }; 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;}; # 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; }; 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"; }; }; devShells.${system} = { default = pkgs.mkShell { packages = builtins.concatLists [ buildInputs [ (rust-toolchain.override { extensions = ["rust-src" "rust-analysis" "rust-analyzer-preview"]; }) ] ]; }; }; }; }