feat: Expose website as a flake

This commit is contained in:
PapaTutuWawa 2022-05-14 17:23:19 +02:00
parent 110eea369b
commit eb018b6717
5 changed files with 126 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
_site
result

62
flake.lock Normal file
View File

@ -0,0 +1,62 @@
{
"nodes": {
"assets": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1652540787,
"narHash": "sha256-VU598G+6sAPkmHRIOoZohduMMjwXv/zRf2BYlgIcChA=",
"ref": "refs/heads/master",
"rev": "de5a0ba39fb9da7eec81f1f59d07af67ec4a9233",
"revCount": 17,
"type": "git",
"url": "https://git.polynom.me/polynom.me/shared-assets.git"
},
"original": {
"type": "git",
"url": "https://git.polynom.me/polynom.me/shared-assets.git"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1638239011,
"narHash": "sha256-AjhmbT4UBlJWqxY0ea8a6GU2C2HdKUREkG43oRr3TZg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1638239011,
"narHash": "sha256-AjhmbT4UBlJWqxY0ea8a6GU2C2HdKUREkG43oRr3TZg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"assets": "assets",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

25
flake.nix Normal file
View File

@ -0,0 +1,25 @@
{
description = "The website hosted at https://polynom.me";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/21.11";
assets.url = "git+https://git.polynom.me/polynom.me/shared-assets.git";
};
outputs = {
self,
nixpkgs,
assets
}: let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.attrsets.genAttrs supportedSystems;
in {
packages = forAllSystems (system: let
pkgs = import nixpkgs { inherit system; };
in {
default = pkgs.callPackage ./pkgs/website.nix {
shared-assets = assets.packages.${system}.default;
};
});
};
}

View File

@ -10,8 +10,7 @@
content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<link rel="stylesheet" href="assets/css/index.css" />
<!-- TODO -->
<link rel="stylesheet" href="https://cdn.polynom.me/css/main.css" />
<link rel="stylesheet" href="{{ page_assets }}/css/main.css" />
<!-- Mastodon -->
<link rel="me" href="https://{{ mastodon_instance_url }}/{{ mastodon_handle }}" />

37
pkgs/website.nix Normal file
View File

@ -0,0 +1,37 @@
{
lib, stdenv
, python3
, shared-assets
}:
stdenv.mkDerivation {
pname = "website";
version = "202205120-01";
src = ../.;
buildInputs = [ shared-assets python3 ];
buildPhase = ''
${python3}/bin/python ${shared-assets}/bin/makesite.py \
-v page_assets=https://cdn.polynom.me \
--assets ./assets \
--copy-assets \
--include robots.txt \
-p params.json
'';
installPhase = ''
mkdir -p $out/srv/www/website
cp -vr _site/* $out/srv/www/website
'';
doCheck = false;
meta = with lib; {
description = "The website hosted at https://polynom.me";
homepage = "https://git.polynom.me/polynom.me/website";
maintainers = [];
license = licenses.gpl3;
};
}