From b74438edb6519e28e9f2c3139c921b543058e48a Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 14 May 2022 17:32:00 +0200 Subject: [PATCH] feat: Add a flake --- .gitignore | 3 +++ flake.lock | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 25 +++++++++++++++++++++ pkgs/blog.nix | 36 ++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 pkgs/blog.nix 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; + }; +}