From 36c22e9a36eaeb3c1864121f4b06a593375e0ea0 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Fri, 26 Apr 2024 15:15:05 +0200 Subject: [PATCH] init --- .gitignore | 1 + blog-pim.nix | 47 ++++++++++++++++++ flake.lock | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 22 +++++++++ 4 files changed, 203 insertions(+) create mode 100644 .gitignore create mode 100644 blog-pim.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/blog-pim.nix b/blog-pim.nix new file mode 100644 index 0000000..b5ed4ab --- /dev/null +++ b/blog-pim.nix @@ -0,0 +1,47 @@ +{ nixpkgs, flutils, blog-pim, nginx, ... }: flutils.lib.eachDefaultSystem (system: +let + pkgs = nixpkgs.legacyPackages.${system}; + nginxPort = "80"; + nginxConf = pkgs.writeText "nginx.conf" '' + user nobody nobody; + daemon off; + error_log /dev/stdout info; + pid /dev/null; + events {} + http { + access_log /dev/stdout; + include ${nginx.outPath}/conf/mime.types; + + server { + listen ${nginxPort}; + index index.html; + location / { + root ${blog-pim.packages.${system}.static-website}; + } + } + } + ''; +in +{ + packages.blog-pim = pkgs.dockerTools.buildLayeredImage { + name = "blog-pim"; + tag = "test"; # TODO: what is the best way to tag this? + + contents = [ + pkgs.fakeNss + pkgs.nginx + ]; + + extraCommands = '' + mkdir -p tmp/nginx_client_body + mkdir -p var/log/nginx + ''; + + config = { + Cmd = [ "nginx" "-c" nginxConf ]; + ExposedPorts = { + "${nginxPort}/tcp" = { }; + }; + }; + }; +}) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a561c7e --- /dev/null +++ b/flake.lock @@ -0,0 +1,133 @@ +{ + "nodes": { + "blog-pim": { + "inputs": { + "flutils": "flutils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714137143, + "narHash": "sha256-LMZjGiacgn0R9zuuolU+XJZsx1hkX5p9gs+d7B0YQCc=", + "ref": "refs/heads/master", + "rev": "77d432ad8b0e16213b29bbb58e3d73aef0512ee9", + "revCount": 3, + "type": "git", + "url": "https://git.kun.is/home/blog-pim" + }, + "original": { + "type": "git", + "url": "https://git.kun.is/home/blog-pim" + } + }, + "flutils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flutils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nginx": { + "flake": false, + "locked": { + "lastModified": 1713277799, + "narHash": "sha256-VNDzQvUGeh54F3s6SIq6lBrp4RatURzJoJqVorexttA=", + "owner": "nginx", + "repo": "nginx", + "rev": "d8a849ae3c99ee5ca82c9a06074761e937dac6d6", + "type": "github" + }, + "original": { + "owner": "nginx", + "repo": "nginx", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1714076141, + "narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "blog-pim": "blog-pim", + "flutils": "flutils_2", + "nginx": "nginx", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..27eaf85 --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flutils.url = "github:numtide/flake-utils"; + + nginx = { + url = "github:nginx/nginx"; + flake = false; + }; + + blog-pim = { + url = "git+https://git.kun.is/home/blog-pim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { flutils, ... }@inputs: flutils.lib.meld inputs [ + ./blog-pim.nix + ]; +}