diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fd015aa..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "images"] - path = images - url = ../static-site-images -[submodule "extra-content"] - path = extra-content - url = ../extra-site-content diff --git a/extra-content b/extra-content deleted file mode 160000 index 62e61fa..0000000 --- a/extra-content +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 62e61fa89e83d76ab705230591136258e657a156 diff --git a/flake.lock b/flake.lock index 54c0809..6e93346 100644 --- a/flake.lock +++ b/flake.lock @@ -19,6 +19,57 @@ "type": "github" } }, + "anki-decks": { + "inputs": { + "anki-compiler": "anki-compiler", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1696027377, + "narHash": "sha256-3U2rucDeMbKe+5DwI+Aln5bABRSFcOTwQI+DuqiqAKo=", + "owner": "Smaug123", + "repo": "anki-decks", + "rev": "6b612a9193a71caf79e7bc1e01fda7f6495abd2a", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "anki-decks", + "type": "github" + } + }, + "content-source": { + "flake": false, + "locked": { + "lastModified": 1694371160, + "narHash": "sha256-fOhvSnah74ZLYV130HOYnVduw5qpK32GikDdC6u/4gA=", + "owner": "Smaug123", + "repo": "static-site-content", + "rev": "67c4f084fc3425e86c1f98e3b0e5fa1b8049296d", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "static-site-content", + "type": "github" + } + }, + "extra-content": { + "flake": false, + "locked": { + "lastModified": 1694359899, + "narHash": "sha256-zqso6yrZLMvhEWBrffXMTvirHeX/CWy0HmfCpC+FFXE=", + "path": "/Users/patrick/Desktop/website/extra-site-content", + "type": "path" + }, + "original": { + "path": "/Users/patrick/Desktop/website/extra-site-content", + "type": "path" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -42,11 +93,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -55,6 +106,42 @@ "type": "github" } }, + "images": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": "nixpkgs_3", + "scripts": "scripts" + }, + "locked": { + "lastModified": 1696067098, + "narHash": "sha256-EJzgliSlIVcKGNF80gdqENn7AvC0Mbn0OILofVEdhxA=", + "path": "/Users/patrick/Desktop/website/static-site-images", + "type": "path" + }, + "original": { + "path": "/Users/patrick/Desktop/website/static-site-images", + "type": "path" + } + }, + "katex-source": { + "flake": false, + "locked": { + "lastModified": 1691244098, + "narHash": "sha256-hDHo7JQAo+fGxQvY5OtXlfh+e6PjlVIQPTyCa3Fjg0Y=", + "owner": "KaTeX", + "repo": "KaTeX", + "rev": "4f1d9166749ca4bd669381b84b45589f1500a476", + "type": "github" + }, + "original": { + "owner": "KaTeX", + "repo": "KaTeX", + "rev": "4f1d9166749ca4bd669381b84b45589f1500a476", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1694021185, @@ -86,11 +173,116 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "pdfs": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1696026308, + "narHash": "sha256-TM4d1ZQ+AEhjbHZk6qMhwACSLet6HZbWqKEwyxsQAQw=", + "owner": "Smaug123", + "repo": "static-site-pdfs", + "rev": "f2cb47916b08a5ade2b6edba5a7aeee67cef8feb", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "static-site-pdfs", + "type": "github" + } + }, "root": { "inputs": { - "anki-compiler": "anki-compiler", + "anki-decks": "anki-decks", + "content-source": "content-source", + "extra-content": "extra-content", "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" + "images": "images", + "katex-source": "katex-source", + "nixpkgs": "nixpkgs_4", + "pdfs": "pdfs", + "scripts": "scripts_2" + } + }, + "scripts": { + "locked": { + "lastModified": 1696031019, + "narHash": "sha256-MuKEC8ZZ1Znm2idxQEQYU18z/1l9rjBZaj5gdKd9elQ=", + "owner": "Smaug123", + "repo": "flake-shell-script", + "rev": "05cc0582a193d3b42b6b4e64c6ec7a9bca4bb3c5", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "flake-shell-script", + "type": "github" + } + }, + "scripts_2": { + "locked": { + "lastModified": 1696031019, + "narHash": "sha256-MuKEC8ZZ1Znm2idxQEQYU18z/1l9rjBZaj5gdKd9elQ=", + "owner": "Smaug123", + "repo": "flake-shell-script", + "rev": "05cc0582a193d3b42b6b4e64c6ec7a9bca4bb3c5", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "flake-shell-script", + "type": "github" } }, "systems": { diff --git a/flake.nix b/flake.nix index cd825cf..0b239f1 100644 --- a/flake.nix +++ b/flake.nix @@ -3,71 +3,61 @@ inputs = { flake-utils.url = github:numtide/flake-utils; + scripts.url = "github:Smaug123/flake-shell-script"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; - anki-compiler.url = "github:Smaug123/anki-dotnet"; + extra-content = { + url = "path:/Users/patrick/Desktop/website/extra-site-content"; + flake = false; + }; + katex-source = { + url = "github:KaTeX/KaTeX/4f1d9166749ca4bd669381b84b45589f1500a476"; + flake = false; + }; + images = { + url = "path:/Users/patrick/Desktop/website/static-site-images"; + inputs.flake-utils.follows = "flake-utils"; + }; + pdfs = { + url = "github:Smaug123/static-site-pdfs"; + inputs.flake-utils.follows = "flake-utils"; + }; + anki-decks = { + url = "github:Smaug123/anki-decks"; + inputs.flake-utils.follows = "flake-utils"; + }; + content-source = { + url = "github:Smaug123/static-site-content"; + flake = false; + }; }; outputs = { self, nixpkgs, flake-utils, - anki-compiler, + katex-source, + images, + pdfs, + anki-decks, + content-source, + extra-content, + scripts, }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; - in let - texlive = pkgs.texlive.combine { - inherit (pkgs.texlive) scheme-medium mdframed etoolbox zref needspace tikz-cd; - }; in rec { packages = flake-utils.lib.flattenTree { gitAndTools = pkgs.gitAndTools; }; - defaultPackage = let - createShellScript = name: contents: - pkgs.stdenv.mkDerivation { - __contentAddressed = true; - pname = name; - version = "0.1.0"; - src = contents; - - buildInputs = [ - pkgs.shellcheck - ]; - - phases = ["configurePhase" "buildPhase" "installPhase"]; - - configurePhase = '' - ${pkgs.shellcheck}/bin/shellcheck "${contents}" - ''; - - buildPhase = '' - cp "${contents}" run.sh - patchShebangs run.sh - sed -i 's_"/bin/sh"_"${pkgs.bash}/bin/sh"_' run.sh - ''; - - installPhase = '' - mkdir -p $out - mv run.sh $out/run.sh - ''; - }; - in let - buildLatex = createShellScript "latex" ./docker/latex/build.sh; - buildPictures = createShellScript "pictures" ./docker/pictures/build.sh; - buildHugo = createShellScript "hugo" ./docker/hugo/build.sh; - buildAnki = createShellScript "anki" ./build/anki.sh; - buildEverything = createShellScript "all" ./build/all.sh; + defaultPackage = + let + buildHugo = scripts.lib.createShellScript pkgs "hugo" ./docker/hugo/build.sh; in let katex = pkgs.stdenv.mkDerivation { + __contentAddressed = true; pname = "katex"; version = "0.1.0"; - src = pkgs.fetchFromGitHub { - owner = "KaTeX"; - repo = "KateX"; - rev = "4f1d9166749ca4bd669381b84b45589f1500a476"; - sha256 = "sha256-hDHo7JQAo+fGxQvY5OtXlfh+e6PjlVIQPTyCa3Fjg0Y="; - }; + src = katex-source; buildInputs = [pkgs.nodejs pkgs.yarn]; @@ -75,7 +65,6 @@ export HOME=$(mktemp -d) yarn --immutable yarn build - find . -type f -name "katex.min.*" ''; installPhase = '' @@ -84,107 +73,33 @@ cp -r ./dist "$out/dist" ''; }; - in let - pdfs = pkgs.stdenv.mkDerivation { - __contentAddressed = true; - pname = "patrickstevens.co.uk-latex"; - version = "0.1.2"; - src = pkgs.fetchFromGitHub { - owner = "Smaug123"; - repo = "static-site-pdfs"; - rev = "d8cf76c2f1f669e177cff5217f9ebbf763070d71"; - sha256 = "sha256-BH8EoVP4jtqisjIuayDKxXrvjzyNrJJP/OJf6rH0zgE="; - }; - buildInputs = [ - texlive - buildLatex - ]; - - buildPhase = '' - ${pkgs.bash}/bin/sh ${buildLatex}/run.sh . - ''; - - installPhase = '' - mkdir -p $out - cp ./* $out - ''; - }; - in let - images = pkgs.stdenv.mkDerivation { - __contentAddressed = true; - pname = "patrickstevens.co.uk-images"; - version = "0.1.0"; - src = ./images; - buildInputs = [ - pkgs.imagemagick - buildPictures - ]; - - buildPhase = '' - ${pkgs.bash}/bin/sh ${buildPictures}/run.sh . - ''; - - installPhase = '' - ls -la . - mkdir -p $out - mv ./* $out - ''; - }; in let extraContent = pkgs.stdenv.mkDerivation { __contentAddressed = true; pname = "patrickstevens.co.uk-extraContent"; version = "0.1.0"; - src = ./extra-content; + src = extra-content; buildInputs = []; installPhase = '' mkdir -p $out cp -r ./. $out ''; }; - in let - ankiDecks = pkgs.stdenv.mkDerivation { - __contentAddressed = true; - pname = "patrickstevens.co.uk-anki"; - version = "0.2.0"; - src = pkgs.fetchFromGitHub { - owner = "Smaug123"; - repo = "anki-decks"; - rev = "589a52858d5dca419ad8866946b7418f30b36eff"; - sha256 = "sha256-tc3Twev82WVFbHbEgLVwgcQnPaEYGAUHqw8lpj1Kuqk="; - }; - buildInputs = []; - installPhase = '' - pwd - ${./build/anki.sh} . "${anki-compiler.packages.${system}.default}/bin/AnkiStatic" "$out" - ''; - }; in pkgs.stdenv.mkDerivation { __contentAddressed = true; pname = "patrickstevens.co.uk"; version = "0.1.0"; - src = pkgs.fetchFromGitHub { - owner = "Smaug123"; - repo = "static-site-content"; - rev = "67c4f084fc3425e86c1f98e3b0e5fa1b8049296d"; - sha256 = "sha256-fOhvSnah74ZLYV130HOYnVduw5qpK32GikDdC6u/4gA="; - }; + src = content-source; buildInputs = [ pkgs.hugo - buildHugo - images - pdfs - ankiDecks - katex - extraContent pkgs.html-tidy ]; buildPhase = '' - ${./build/all.sh} "${pdfs}" "${images}" "${ankiDecks}" "${buildHugo}" "${katex}" "${extraContent}" + ${scripts.lib.createShellScript pkgs "all" ./build/all.sh}/run.sh "${pdfs.packages.${system}.default}" "${images}" "${anki-decks.packages.${system}.default}" "${buildHugo}" "${katex}" "${extraContent}" ''; checkPhase = '' diff --git a/images b/images deleted file mode 160000 index c0bfc30..0000000 --- a/images +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c0bfc303ff5a0c89e43d1e1ea3cd988fd6bf5af1