{ pkgs, self }: let revision = "${self.lastModifiedDate}-${self.shortRev or self.dirtyShortRev or "dirty"}"; version = self.shortRev or self.dirtyShortRev or "unstable-${self.lastModified}"; dockerTag = self.rev or self.dirtyRev or "unstable-${self.lastModified}"; mkDocker = server: let PORT = 3000; in pkgs.dockerTools.streamLayeredImage { name = "registry.fly.io/alanpearce-eu"; tag = dockerTag; contents = [ server ]; config = { Cmd = [ "website" ]; Env = [ "PRODUCTION=true" "PORT=${builtins.toString PORT}" "ROOT=public" ]; ExposedPorts = { "${builtins.toString PORT}/tcp" = { }; }; }; }; in rec { default = server; builder = pkgs.buildGoApplication { pname = "website-builder"; inherit version; CGO_ENABLED = 0; src = with pkgs.lib.fileset; toSource { root = ./..; fileset = unions [ ./../go.mod ./../go.sum ./../cmd ./../internal ]; }; modules = ./gomod2nix.toml; subPackages = [ "cmd/build" ]; }; server = pkgs.buildGoApplication { pname = "website"; inherit version; CGO_ENABLED = 0; src = with pkgs.lib.fileset; toSource { root = ./..; fileset = unions [ ./../go.mod ./../go.sum ./../server.go ./../internal ./../config.toml ./../content ./../static ./../templates ]; }; nativeBuildInputs = [ builder ]; prePatch = '' ${builder}/bin/build ''; modules = ./gomod2nix.toml; ldflags = [ "-s" "-w" "-X" "main.Commit=${version}" ]; }; docker = mkDocker server; docker-aarch64-linux = mkDocker (self.packages.aarch64-linux.server); docker-x86_64-linux = mkDocker (self.packages.x86_64-linux.server); fly = docker-x86_64-linux; }