Add NixNG configuration

This commit is contained in:
Pim Kunis 2024-12-31 11:03:29 +01:00
parent 433c1ef4b5
commit 9e99ee2e47
2 changed files with 142 additions and 20 deletions

76
flake.lock generated
View file

@ -18,7 +18,61 @@
"type": "github" "type": "github"
} }
}, },
"nginx": {
"flake": false,
"locked": {
"lastModified": 1735301654,
"narHash": "sha256-PHcSyHYyPUwPAls0BgtnGu2e936vhxW2nt7bQxDyGAQ=",
"owner": "nginx",
"repo": "nginx",
"rev": "e3a9b6ad08a86e799a3d77da3f2fc507d3c9699e",
"type": "github"
},
"original": {
"owner": "nginx",
"repo": "nginx",
"type": "github"
}
},
"nixng": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1735551011,
"narHash": "sha256-rp26PcdLjfgxsCeaSeZ0K1rGPN1Ap7YCy1UVuo9gRJA=",
"owner": "pizzapim",
"repo": "NixNG",
"rev": "aa35f7a3d426e906b15e3083c90bf2972bcfb4b4",
"type": "github"
},
"original": {
"owner": "pizzapim",
"ref": "kubernetes",
"repo": "NixNG",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": {
"lastModified": 1726871744,
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1714076141, "lastModified": 1714076141,
"narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=", "narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=",
@ -37,7 +91,9 @@
"root": { "root": {
"inputs": { "inputs": {
"flutils": "flutils", "flutils": "flutils",
"nixpkgs": "nixpkgs" "nginx": "nginx",
"nixng": "nixng",
"nixpkgs": "nixpkgs_2"
} }
}, },
"systems": { "systems": {
@ -54,6 +110,24 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1727984844,
"narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -4,9 +4,19 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flutils.url = "github:numtide/flake-utils"; flutils.url = "github:numtide/flake-utils";
nixng = {
url = "github:pizzapim/NixNG/kubernetes";
inputs.nixpkgs.follows = "nixpkgs";
};
nginx = {
url = "github:nginx/nginx";
flake = false;
};
}; };
outputs = { self, nixpkgs, flutils}: flutils.lib.eachDefaultSystem (system: outputs = { self, nixpkgs, flutils, nixng, nginx, ...}: flutils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
@ -21,29 +31,67 @@
dontUnpack = true; dontUnpack = true;
installPhase = "install -Dm755 ${./patch-feed-date.py} $out/bin/patch-feed-date"; installPhase = "install -Dm755 ${./patch-feed-date.py} $out/bin/patch-feed-date";
}; };
nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nginx nginx;
daemon off;
error_log /dev/stderr;
pid /httpd.pid;
events {}
http {
access_log /dev/stdout;
include ${nginx.outPath}/conf/mime.types;
server {
listen ${nginxPort};
index index.html;
location / {
root ${self.packages.${system}.default};
}
}
}
'';
in in
{ {
packages = { packages.default = pkgs.stdenv.mkDerivation {
static-website = pkgs.stdenv.mkDerivation { name = "blog";
name = "blog"; src = ./src;
src = ./src; sourceRoot = "src";
sourceRoot = "src";
buildInputs = [ buildInputs = [
gems gems
gems.wrappedRuby gems.wrappedRuby
patch-feed-date patch-feed-date
]; ];
buildPhase = '' buildPhase = ''
bundle exec jekyll build --future bundle exec jekyll build --future
''; '';
installPhase = '' installPhase = ''
mkdir -p $out mkdir -p $out
cp -r _site/* $out/ cp -r _site/* $out/
patch-feed-date --file _site/feed.xml > $out/feed.xml patch-feed-date --file _site/feed.xml > $out/feed.xml
''; '';
};
nixngConfigurations.default = nixng.nglib.makeSystem {
inherit nixpkgs system;
name = "nixng-blog";
config = {config, lib, ...}: {
dinit.enable = true;
init.services.nginx = {
shutdownOnExit = true;
script = lib.mkForce (pkgs.writeShellScript "nginx-run" ''
HOME=~nginx ${config.services.nginx.package}/bin/nginx -c ${nginxConf}
'');
};
services.nginx = {
enable = true;
configuration = [];
};
}; };
}; };
}); });