add optional nix flake

This commit is contained in:
Vinzenz Schroeter 2025-06-05 21:51:31 +02:00
parent 5c313846e6
commit 1e6d03c635
5 changed files with 78 additions and 16 deletions

4
.gitignore vendored
View file

@ -104,4 +104,6 @@ shell.nix
.venv .venv
# murmeldin # murmeldin
overview.md overview.md
/result

View file

@ -1,5 +1,5 @@
theme = "blowfish" theme = "blowfish"
baseURL = "https://oururl.de/" baseURL = "/"
defaultContentLanguage = "de" defaultContentLanguage = "de"
relativeURLs = true relativeURLs = true
canonifyURLs = true canonifyURLs = true

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1741332913, "lastModified": 1748995628,
"narHash": "sha256-ri1e8ZliWS3Jnp9yqpKApHaOo7KBN33W8ECAKA4teAQ=", "narHash": "sha256-bFufQGSAEYQgjtc4wMrobS5HWN0hDP+ZX+zthYcml9U=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "20755fa05115c84be00b04690630cb38f0a203ad", "rev": "8eb3b6a2366a7095939cd22f0dc0e9991313294b",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -6,30 +6,90 @@
}; };
outputs = outputs =
{ self, nixpkgs }: {
self,
nixpkgs,
}:
let let
forAllSystems = forAllSystems =
f: f:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
system: system:
f rec { f rec {
pkgs = nixpkgs.legacyPackages.${system};
inherit system; inherit system;
pkgs = nixpkgs.legacyPackages.${system};
selfPkgs = self.packages.${system};
lib = pkgs.lib;
} }
); );
in in
{ {
devShells = forAllSystems ( packages = forAllSystems (
{ pkgs, ... }:
{ {
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; [ packages = with pkgs; [
hugo
go go
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.icalendar
python-pkgs.pytz
]))
shellcheck shellcheck
]; ];
}; };

@ -1 +1 @@
Subproject commit 0d03681d203f48a8e8a0a836618b091def375c09 Subproject commit 0b06a64139beba6287e7685f4c810ad4ff772fde