feat: Add a flake

This commit is contained in:
PapaTutuWawa 2022-05-14 17:32:00 +02:00
parent 6b2de918d1
commit b74438edb6
4 changed files with 126 additions and 0 deletions

3
.gitignore vendored
View File

@ -2,3 +2,6 @@
_site/ _site/
assets/img/*.jpg assets/img/*.jpg
blog.tar.gz blog.tar.gz
# Nix
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 blog hosted at https://blog.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/blog.nix {
shared-assets = assets.packages.${system}.default;
};
});
};
}

36
pkgs/blog.nix Normal file
View File

@ -0,0 +1,36 @@
{
lib, stdenv
, gnumake, imagemagick
, shared-assets
}:
stdenv.mkDerivation {
pname = "blog";
version = "20211128";
src = ../.;
buildInputs = [ shared-assets gnumake imagemagick ];
patchPhase = ''
sed -i Makefile -e "s|python ../shared-assets/makesite.py|python ${shared-assets}/bin/makesite.py|g"
sed -i Makefile -e "s|tar -czf blog.tar.gz _site||g"
'';
buildPhase = ''
make buildnosign
'';
installPhase = ''
mkdir -p $out/srv/www/blog
cp -vr _site/* $out/srv/www/blog
'';
doCheck = false;
meta = with lib; {
description = "The blog hosted at https://blog.polynom.me";
homepage = "https://git.polynom.me/polynom.me/blog.polynom.me";
maintainers = [];
license = licenses.gpl3;
};
}