forked from cccb-website-team/www
add optional nix flake
This commit is contained in:
parent
5c313846e6
commit
1e6d03c635
5 changed files with 78 additions and 16 deletions
80
flake.nix
80
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
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue