Implement nix-based build system
This commit is contained in:
parent
b8b7ee2ac5
commit
fd1e4e66f6
8 changed files with 95 additions and 8 deletions
8
Makefile
8
Makefile
|
@ -1,4 +1,8 @@
|
||||||
|
ifeq ($(PREFIX),)
|
||||||
|
PREFIX := /usr/local
|
||||||
|
endif
|
||||||
ODIR=output
|
ODIR=output
|
||||||
|
|
||||||
PAGES_SRC := $(wildcard content/pages/*)
|
PAGES_SRC := $(wildcard content/pages/*)
|
||||||
PAGES_DST := $(patsubst content/pages/%,$(ODIR)/%/index.html,$(PAGES_SRC))
|
PAGES_DST := $(patsubst content/pages/%,$(ODIR)/%/index.html,$(PAGES_SRC))
|
||||||
|
|
||||||
|
@ -41,5 +45,9 @@ clean:
|
||||||
deploy:
|
deploy:
|
||||||
rsync -avP --delete output/ root@knazarov.com:/var/www/knazarov.com/
|
rsync -avP --delete output/ root@knazarov.com:/var/www/knazarov.com/
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -d $(DESTDIR)$(PREFIX)/srv/knazarov.com
|
||||||
|
rsync -av --no-o --no-g output/ $(DESTDIR)$(PREFIX)/srv/knazarov.com
|
||||||
|
|
||||||
analytics:
|
analytics:
|
||||||
ssh root@knazarov.com "cat /var/log/nginx/access.log" | ./bin/analytics.sh
|
ssh root@knazarov.com "cat /var/log/nginx/access.log" | ./bin/analytics.sh
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
expand() {
|
expand() {
|
||||||
TITLE="$1"
|
TITLE="$1"
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
remove_nbsp() {
|
remove_nbsp() {
|
||||||
sed 's#\ # #g'
|
sed 's#\ # #g'
|
||||||
}
|
}
|
||||||
|
|
||||||
date_rfc_822() {
|
date_rfc_822() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
26
flake.lock
Normal file
26
flake.lock
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1686503661,
|
||||||
|
"narHash": "sha256-s20xJMC8j8RRluqJixb7fLYkNiGNGebw82/R3ozcvzI=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "089f5788fbfefe3adcb930a908d4874e1ce5c0ce",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
33
flake.nix
Normal file
33
flake.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
description = "Nix flake for knazarov.com";
|
||||||
|
|
||||||
|
# Flake inputs
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Flake outputs
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
# Systems supported
|
||||||
|
allSystems = [
|
||||||
|
"x86_64-linux" # 64-bit Intel/AMD Linux
|
||||||
|
"aarch64-linux" # 64-bit ARM Linux
|
||||||
|
"x86_64-darwin" # 64-bit Intel macOS
|
||||||
|
"aarch64-darwin" # 64-bit ARM macOS
|
||||||
|
];
|
||||||
|
|
||||||
|
# Helper to provide system-specific attributes
|
||||||
|
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = forAllSystems( {pkgs }:
|
||||||
|
{
|
||||||
|
"knazarov.com" = (pkgs.callPackage ./knazarov.com.nix {});
|
||||||
|
default = (pkgs.callPackage ./knazarov.com.nix {});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
20
knazarov.com.nix
Normal file
20
knazarov.com.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
stdenv
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "knazarov.com";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
dontPatch = true;
|
||||||
|
|
||||||
|
installFlags = "PREFIX=${placeholder "out"} VERSION=${version}";
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
gawk
|
||||||
|
gnused
|
||||||
|
rsync
|
||||||
|
];
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue