From 1e6d03c635ad2cd5189352d4a5bc14e1f8141dae Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 5 Jun 2025 21:51:31 +0200 Subject: [PATCH 1/7] 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 From 3cab0c430325b1b380527ad2689f4e360f942cbe Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 6 Jun 2025 18:21:36 +0200 Subject: [PATCH 2/7] Anfahrt tote links repariert, markdown lint warnungen --- content/verein/anfahrt.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/content/verein/anfahrt.md b/content/verein/anfahrt.md index 4451626..fd36db8 100644 --- a/content/verein/anfahrt.md +++ b/content/verein/anfahrt.md @@ -5,13 +5,14 @@ menu: main: parent: "Verein" tag: ["Verein"] +aliases: ["/page/anfahrt/"] --- -# Allgemeine Hinweise +## Allgemeine Hinweise Die Clubräume liegen im Hinterhof der **Marienstr. 11, 10117 Berlin** ([Google](http://maps.google.com/maps?hl=de&q=Marienstr.%2011%2C%2010117%20Berlin), [OpenStreetMap](http://www.openstreetmap.org/node/2007229025#map=17/52.52159/13.38547)). Die Koordinaten sind **52,52194° Nord; 13,38261° Ost**. -# Nahbereichskarte +## Nahbereichskarte {{< figure src="/img/Weg_zum_CCCB.png" @@ -19,28 +20,27 @@ Die Clubräume liegen im Hinterhof der **Marienstr. 11, 10117 Berlin** ([Google] alt="Fußweg vom S Friedrichstraße zum CCCB" >}} -# Ich reise an... +## Ich reise an mit -## mit dem Rad +### einem Fahrrad Eine beschränkte Anzahl von Fahrradständern befindet sich im Innenhof. Auf dem Weg zum Club befinden sich zahlreiche Fahrradstraßen, die bevorzugt werden sollten. Nutzt beispielsweise [BBBike.de](http://bbbike.de/cgi-bin/bbbike.cgi). -## mit öffentlichem Nahverkehr +### öffentlichem Nahverkehr Der Club befindet sich in unmittelbarer Nähe zum S+U Bahnhof **Friedrichstraße**, an dem auch Regionalbahnen halten. Vom S-Bahn-Bahnsteig (S3/S5/S7, oberirdisch, Ausgang Schiffbauerdamm) gibt es einen direkten Weg über die Spree unterhalb der Bahnbrücke. Über die Albrechtstraße erreicht ihr die Marienstraße. -## mit dem Fernverkehr +### Fernverkehr Aussteigen in **Berlin Hauptbahnhof**. Von dort mit jeder S-Bahn oder Regionalbahn Richtung Osten auf der Stadtbahn eine Haltestelle bis zum **Bahnhof Friedrichstraße** fahren. Den Bahnhof Richtung Spree verlassen, dann die Fußgängerbrücke über den Fluß nehmen und der Albrechtstraße bis zur Stichstraße Marienstraße folgen. -## mit dem Flugzeug +### Flugzeug * vom **Flughafen Berlin Brandenburg** (BER/EDDB): mit dem Airport Express (RE 7 und RB 14) oder S9 bis zum **Bahnhof Friedrichstraße**. Alternativ mit dem FEX bis **Berlin Hauptbahnhof**. Von dort siehe jeweils Abschnitt **Fernverkehr**. **Achtung:** Terminal 5 (früher: SXF) ist nicht mit dem Rest des BER verbunden. Als einzige direkte Bahnanbindung steht hier die S9 zur Verfügung. * vom **Flugplatz Straußberg** (EDAY): S7 direkt bis zum **Bahnhof Friedrichstraße**. Von dort siehe Abschnitt **öffentlicher Nahverkehr**. -## mit dem Auto +### Auto Am besten dem Navigationsgerät folgen. Zufahrt aus Richtung Hauptbahnhof oder Brandenburger Tor ist über die Luisenstraße möglich. Wer von der Friedrichstraße kommt, fährt entweder über den Schiffbauerdamm und die Albrechtstraße (Behinderung durch Außgengastronomie und Kopfsteinpflaster) oder fährt über die Reinhardstraße und die Luisenstraße (die Albrechtstraße ist nur in die Gegenrichtung befahrbar). **Warnung:** Vor Ort gibt es je nach Tageszeit wenige Parkmöglichkeiten. Die Marienstraße und alle umliegenden Straßen unterliegen der Parkraumbewirtschaftung seitens des Bezirks. Parkplätze in unmittelbarer Nähe sind selten. - From edd08a2ed691c63b1e0150d1832346d8e72eb06e Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 6 Jun 2025 18:39:07 +0200 Subject: [PATCH 3/7] fix 404 --- content/404.md | 1 - i18n/de.toml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 content/404.md create mode 100644 i18n/de.toml diff --git a/content/404.md b/content/404.md deleted file mode 100644 index d9fcfba..0000000 --- a/content/404.md +++ /dev/null @@ -1 +0,0 @@ -Leider existiert diese Seite nicht. \ No newline at end of file diff --git a/i18n/de.toml b/i18n/de.toml new file mode 100644 index 0000000..518d233 --- /dev/null +++ b/i18n/de.toml @@ -0,0 +1,4 @@ +[error] +404_title = "Seite nicht gefunden :confused:" +404_error = "Fehler 404" +404_description = "Es sieht so aus, als hättest du einen toten Link gefunden. Leider existiert diese Seite nicht." From 6aadea1155f91789ae81dc1933a851d91dc5b8ac Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 6 Jun 2025 18:50:28 +0200 Subject: [PATCH 4/7] limit systems to the common ones in flake --- flake.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 0184615..6a92ebd 100644 --- a/flake.nix +++ b/flake.nix @@ -11,9 +11,15 @@ nixpkgs, }: let + supported-systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; forAllSystems = f: - nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( + nixpkgs.lib.genAttrs supported-systems ( system: f rec { inherit system; @@ -55,7 +61,7 @@ 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 From 981108e77a305ad19603fe14fe6bef6e5479274f Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 7 Jun 2025 15:35:43 +0200 Subject: [PATCH 5/7] update readme, markdown lint --- README.md | 19 ++++++++++++------- TODO.md | 4 +--- content/_index.md | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c657b59..9b54d24 100644 --- a/README.md +++ b/README.md @@ -19,15 +19,13 @@ This is the website of the CCCB. cd cccb-website ``` -### Run site locally +4. Run hugo webserver -Run hugo webserver: + ```shell + hugo serve + ``` -```shell -hugo serve -``` - -Point your browser to: +5. Point your browser to: To ready your site for upload, run `./build.sh`, which also generates `all.ics` and adds the calendar table to `index.html`. @@ -46,6 +44,13 @@ as long as `hugo serve` is running. - If successfull, check [Website](https://berlin.ccc.de/) if change is correct. 7. Profit! +## Nix stuff + +- After entering the shell with `nix develop`, hugo is available and `hugo serve` should work +- Python including required packages will be available, so the `build.sh` should work without a venv +- You can build the staging and production builds with `nix build .#staging-content` and `nix build .#production-content` +- Do not update the nixpkgs branch - 25.05 contains a newer hugo version that is incompatible with the theme (last checked June 2025) + --- Made with ❤️ and [Hugo](https://gohugo.io). diff --git a/TODO.md b/TODO.md index 10121f4..2d75a8b 100644 --- a/TODO.md +++ b/TODO.md @@ -3,9 +3,7 @@ - DSGVO-compliant Datenschutzerklärung reinbasteln - Entscheiden, welche Seiten sonst noch konvertiert werden sollen und welche in die ewigen Datengründe gehen können - - -# Done +## Done - Template aussuchen - Rausfinden, wie man eine Seite konvertiert diff --git a/content/_index.md b/content/_index.md index b507cf8..531fa85 100644 --- a/content/_index.md +++ b/content/_index.md @@ -23,7 +23,7 @@ description: "Startseite CCCB mit Kurzkalender" --> -### Nächste Veranstaltungen: +### Nächste Veranstaltungen CALENDAR From 7a32bd5efde7d656624c53d3762a3bf2e5f486fb Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 7 Jun 2025 15:40:38 +0200 Subject: [PATCH 6/7] split flake into multiple files --- devShells.nix | 15 +++++++++++ flake.nix | 72 ++------------------------------------------------- packages.nix | 47 +++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 70 deletions(-) create mode 100644 devShells.nix create mode 100644 packages.nix diff --git a/devShells.nix b/devShells.nix new file mode 100644 index 0000000..7c8ed78 --- /dev/null +++ b/devShells.nix @@ -0,0 +1,15 @@ +{ + pkgs, + selfPkgs, + ... +}: +{ + default = pkgs.mkShellNoCC { + inputsFrom = [ selfPkgs.local-content ]; + + packages = with pkgs; [ + go + shellcheck + ]; + }; +} diff --git a/flake.nix b/flake.nix index 6a92ebd..f30d0cc 100644 --- a/flake.nix +++ b/flake.nix @@ -30,77 +30,9 @@ ); in { - packages = forAllSystems ( - { - pkgs, - lib, - selfPkgs, - ... - }: - let - mkWwwContent = - { domain }: - pkgs.stdenvNoCC.mkDerivation { - pname = "www-content"; - version = domain; - src = ./.; + packages = forAllSystems (import ./packages.nix); - # 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; [ - go - - shellcheck - ]; - }; - } - ); + devShells = forAllSystems (import ./devShells.nix); formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); }; diff --git a/packages.nix b/packages.nix new file mode 100644 index 0000000..97e08f6 --- /dev/null +++ b/packages.nix @@ -0,0 +1,47 @@ +{ + pkgs, + ... +}: +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"; }; +} From 9b0da1e267c160f2aa9ad14f2869b04bfd2467a4 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 7 Jun 2025 19:22:56 +0200 Subject: [PATCH 7/7] flake lib.mkWwwContent --- flake.nix | 42 +++++++++++++++++++++++++++++++++++++++- packages.nix | 54 +++++++++++++--------------------------------------- 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/flake.nix b/flake.nix index f30d0cc..462a81d 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,7 @@ inherit system; pkgs = nixpkgs.legacyPackages.${system}; selfPkgs = self.packages.${system}; - lib = pkgs.lib; + lib = pkgs.lib // self.lib; } ); in @@ -35,5 +35,45 @@ devShells = forAllSystems (import ./devShells.nix); formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); + + lib.mkWwwContent = + { domain, system }: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + 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/ + ''; + }; }; } diff --git a/packages.nix b/packages.nix index 97e08f6..08271c9 100644 --- a/packages.nix +++ b/packages.nix @@ -1,47 +1,19 @@ { pkgs, + lib, ... }: -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"; }; + production-content = lib.mkWwwContent { + domain = "berlin.ccc.de"; + inherit (pkgs) system; + }; + staging-content = lib.mkWwwContent { + domain = "staging.berlin.ccc.de"; + inherit (pkgs) system; + }; + local-content = lib.mkWwwContent { + domain = "localhost"; + inherit (pkgs) system; + }; }