From 1e6d03c635ad2cd5189352d4a5bc14e1f8141dae Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 5 Jun 2025 21:51:31 +0200 Subject: [PATCH] add optional nix flake --- .gitignore | 4 +- config/_default/hugo.toml | 2 +- flake.lock | 6 +-- flake.nix | 80 ++++++++++++++++++++++++++++++++++----- themes/blowfish | 2 +- 5 files changed, 78 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index d2d5473..ca9a506 100644 --- a/.gitignore +++ b/.gitignore @@ -104,4 +104,6 @@ shell.nix .venv # murmeldin -overview.md \ No newline at end of file +overview.md + +/result diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index f96279d..13192d6 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -1,5 +1,5 @@ theme = "blowfish" -baseURL = "https://oururl.de/" +baseURL = "/" defaultContentLanguage = "de" relativeURLs = true canonifyURLs = true diff --git a/flake.lock b/flake.lock index 6cc6b35..2869045 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1741332913, - "narHash": "sha256-ri1e8ZliWS3Jnp9yqpKApHaOo7KBN33W8ECAKA4teAQ=", + "lastModified": 1748995628, + "narHash": "sha256-bFufQGSAEYQgjtc4wMrobS5HWN0hDP+ZX+zthYcml9U=", "owner": "nixos", "repo": "nixpkgs", - "rev": "20755fa05115c84be00b04690630cb38f0a203ad", + "rev": "8eb3b6a2366a7095939cd22f0dc0e9991313294b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 73e94d9..0184615 100644 --- a/flake.nix +++ b/flake.nix @@ -6,30 +6,90 @@ }; outputs = - { self, nixpkgs }: + { + self, + nixpkgs, + }: let forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( system: f rec { - pkgs = nixpkgs.legacyPackages.${system}; inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + selfPkgs = self.packages.${system}; + lib = pkgs.lib; } ); in { - devShells = forAllSystems ( - { pkgs, ... }: + packages = forAllSystems ( { - default = pkgs.mkShell rec { + pkgs, + lib, + selfPkgs, + ... + }: + let + mkWwwContent = + { domain }: + pkgs.stdenvNoCC.mkDerivation { + pname = "www-content"; + version = domain; + src = ./.; + + # Build dependencies + nativeBuildInputs = [ + pkgs.hugo + pkgs.glibcLocales + (pkgs.python3.withPackages (python-pkgs: [ + python-pkgs.icalendar + python-pkgs.pytz + ])) + ]; + + LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; + + # Build phase - run Hugo to generate the site + buildPhase = '' + mkdir -p public + hugo --baseURL=https://${domain}/ + + python3 ./tools/merge_cals.py + upcoming="$(python3 tools/gen_upcoming.py static/all.ics 20 5 | tr '\n' ' ')" + cp static/all.ics public/all.ics + sed -i "s#CALENDAR#$upcoming#g" public/index.html + ''; + + # Install phase - copy the public directory to the output + installPhase = '' + mkdir -p $out + cp -r public/* $out/ + ''; + }; + in + { + production-content = mkWwwContent { domain = "berlin.ccc.de"; }; + staging-content = mkWwwContent { domain = "staging.berlin.ccc.de"; }; + local-content = mkWwwContent { domain = "localhost"; }; + } + ); + + devShells = forAllSystems ( + { + pkgs, + system, + selfPkgs, + ... + }: + { + default = pkgs.mkShellNoCC { + inputsFrom = [ selfPkgs.local-content ]; + packages = with pkgs; [ - hugo go - (pkgs.python3.withPackages (python-pkgs: [ - python-pkgs.icalendar - python-pkgs.pytz - ])) + shellcheck ]; }; diff --git a/themes/blowfish b/themes/blowfish index 0d03681..0b06a64 160000 --- a/themes/blowfish +++ b/themes/blowfish @@ -1 +1 @@ -Subproject commit 0d03681d203f48a8e8a0a836618b091def375c09 +Subproject commit 0b06a64139beba6287e7685f4c810ad4ff772fde