diff --git a/.gitignore b/.gitignore index 89e2f9e..0a0323f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ _site/ assets/img/*.jpg blog.tar.gz + +# Nix +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5528cc0 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0fe9bb6 --- /dev/null +++ b/flake.nix @@ -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; + }; + }); + }; +} diff --git a/pkgs/blog.nix b/pkgs/blog.nix new file mode 100644 index 0000000..4bef433 --- /dev/null +++ b/pkgs/blog.nix @@ -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; + }; +}