summary refs log tree commit diff stats
path: root/flake.nix
diff options
context:
space:
mode:
authorAlan Pearce2023-06-30 18:42:51 +0200
committerAlan Pearce2023-06-30 18:42:51 +0200
commit90c15edbc8c4b664704f4e205cffcfeff578f98c (patch)
treeef71c59e931729d46e221dcecf44ee5d89ac8b87 /flake.nix
parent416aed825565074c19ab4550766da1623b8bb326 (diff)
downloadwebsite-90c15edbc8c4b664704f4e205cffcfeff578f98c.tar.lz
website-90c15edbc8c4b664704f4e205cffcfeff578f98c.tar.zst
website-90c15edbc8c4b664704f4e205cffcfeff578f98c.zip
Build docker image
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix89
1 files changed, 65 insertions, 24 deletions
diff --git a/flake.nix b/flake.nix
index 9cf8588..e4067e5 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,38 +1,79 @@
 {
   description = "My website, alanpearce.eu";
   inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+  inputs.flockenzeit.url = "github:balsoft/Flockenzeit";
   inputs.flake-utils.url = "github:numtide/flake-utils";
   inputs.flake-compat = {
     url = "github:edolstra/flake-compat";
     flake = false;
   };
 
-  outputs = { self, nixpkgs, flake-utils, flake-compat }:
-    flake-utils.lib.eachDefaultSystem (system:
-      let
-        pkgs = nixpkgs.legacyPackages.${system};
-      in
-      {
-        packages = {
-          default = pkgs.stdenv.mkDerivation {
-            name = "alanpearce.eu";
-            src = self;
+  outputs = { self, nixpkgs, flockenzeit, flake-utils, ... }:
+    flake-utils.lib.eachDefaultSystem
+      (system:
+        let
+          pkgs = nixpkgs.legacyPackages.${system};
+          nativeBuildInputs = with pkgs; [
+            zola
+            nodePackages_latest.prettier
+            fd
+            brotli
+            gzip
+            zstd
+            git
+          ];
+        in
+        rec {
+          packages = {
+            default = pkgs.stdenv.mkDerivation {
+              name = "alanpearce.eu";
+              src = self;
 
-            enableParallelBuilding = true;
-            makeFlags = [ "PREFIX=$(out)" ];
+              enableParallelBuilding = true;
+              makeFlags = [ "PREFIX=$(out)/public" ];
 
-            nativeBuildInputs = with pkgs; [
-              zola
-              nodePackages_latest.prettier
-              fd
-              brotli
-              gzip
-              zstd
-              git
-            ];
+              inherit nativeBuildInputs;
+
+              dontFixup = true;
 
-            dontFixup = true;
+              postInstall = ''
+                cp Caddyfile $out/
+              '';
+            };
+            docker = pkgs.dockerTools.buildImage {
+              name = "alanpearce/website";
+              fromImage = pkgs.dockerTools.pullImage {
+                imageName = "caddy";
+                finalImageName = "caddy";
+                finalImageTag = "2-alpine";
+                imageDigest = "sha256:d4ca216d8dc515a49bc20fa22a449283ade6c8fc132eb6fa412ff351664d4917";
+                sha256 = "auFzOG+6PSOVNXXXsRsEEThtIHJYM3JUkMQGcUt4cNQ=";
+              };
+              created = flockenzeit.lib.ISO-8601 self.lastModified;
+              copyToRoot = pkgs.buildEnv {
+                name = "website";
+                paths = with pkgs; [
+                  packages.default
+                  nss.tools
+                ];
+                pathsToLink = [ "/bin" "/public" ];
+              };
+              config = {
+                WorkingDir = "${packages.default}";
+                ExposedPorts = {
+                  "80/tcp" = { };
+                };
+                Volumes = {
+                  "/data" = { };
+                };
+              };
+            };
+          };
+          devShell = pkgs.mkShell {
+            buildInputs = [
+              nativeBuildInputs
+              pkgs.flyctl
+            ];
           };
-        };
-      });
+        });
 }