# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. { description = "beeauvin.com - personal website"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; outputs = { self, nixpkgs }: let lib = nixpkgs.lib; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forEachSystem = function: lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system}); # The built site: every page, stylesheet and static file, ready to serve. site = pkgs: pkgs.stdenvNoCC.mkDerivation { name = "beeauvin-com"; # Only what Zola reads, so a change to CI or the readme doesn't rebuild the site. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./config.toml ./content ./sass ./static ./templates ./themes ]; }; nativeBuildInputs = [ pkgs.zola ]; buildPhase = '' runHook preBuild zola build --output-dir "$out" runHook postBuild ''; dontInstall = true; }; # The site served by static-web-server on port 8080, with sws.toml's headers. This # is what App Platform runs (see tofu/website.tf in the platform repository). image = pkgs: pkgs.dockerTools.buildLayeredImage { name = "registry.digitalocean.com/beeauvin/website"; tag = "latest"; config = { Entrypoint = [ (lib.getExe pkgs.static-web-server) ]; Env = [ "SERVER_ROOT=${site pkgs}" "SERVER_PORT=8080" "SERVER_CONFIG_FILE=${./sws.toml}" ]; ExposedPorts."8080/tcp" = { }; User = "65534:65534"; }; }; in { packages = forEachSystem ( pkgs: { site = site pkgs; default = site pkgs; } // lib.optionalAttrs pkgs.stdenv.isLinux { image = image pkgs; } ); devShells = forEachSystem (pkgs: { default = pkgs.mkShell { packages = [ pkgs.zola ]; }; }); }; }