From 7a32bd5efde7d656624c53d3762a3bf2e5f486fb Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 7 Jun 2025 15:40:38 +0200 Subject: [PATCH] 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"; }; +}