Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,63 @@
name: Build and Deploy Decal Web

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"
- main

jobs:

check-flake:
runs-on: ci-ocf-decalweb
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/flake-checker-action@v9

build_and_deploy:
build-container:
runs-on: ubuntu-latest
permissions:
packages: write
env:
image_name: decalweb
registry: ghcr.io/${{ github.repository_owner }}
steps:
- uses: actions/checkout@v7

runs-on: ci-ocf-decalweb
- uses: cachix/install-nix-action@v31

- name: Build and tag image
run: |
IMAGE_TAG=$(sh $(nix build .#image --no-link --print-out-paths) 2>/dev/null | podman load -q | grep -oe "$image_name:.*$" | sed -e "s/$image_name://")
echo "image_tags=$IMAGE_TAG" >> $GITHUB_ENV

- name: Tag latest
if: github.ref == 'refs/heads/main'
run: |
podman tag $image_name:$image_tags $image_name:latest
echo "image_tags=$image_tags latest" >> $GITHUB_ENV

- name: Log in to GHCR
uses: redhat-actions/podman-login@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ${{ env.registry }}

- name: Push to GHCR
id: push-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.image_name }}
tags: ${{ env.image_tags }}
registry: ${{ env.registry }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-ghcr.outputs.registry-paths }}"

build_and_deploy:
runs-on: ci-ocf-decalweb
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion content/archives.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--- title: Archives
---
title: Archives
weight: 50
---

Expand Down
11 changes: 10 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ stdenvNoCC, git, hugo, just }:
{
stdenvNoCC,
git,
hugo,
just,
}:

stdenvNoCC.mkDerivation {
name = "ocf-decal-web";
Expand All @@ -9,10 +14,14 @@ stdenvNoCC.mkDerivation {
];

buildPhase = ''
runHook preBuild
hugo
runHook postBuild
'';

installPhase = ''
runHook preInstall
mv public $out
runHook postInstall
'';
}
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 72 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,93 @@
{
description = "Sysadmin DeCal website configuration for the Open Computing Facility";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
systems.url = "github:nix-systems/default";
};
outputs = { self, nixpkgs, systems }:
outputs =
{
self,
nixpkgs,
systems,
}:
let
pkgsFor = system: nixpkgs.legacyPackages.${system};
pkgsFor = system: import nixpkgs { inherit system; };
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems) (system: fn (pkgsFor system));
in
{
packages = forAllSystems (pkgs: {
packages = forAllSystems (pkgs: rec {
default = pkgs.callPackage ./. { };
image = pkgs.dockerTools.streamLayeredImage (
let
timestamp = builtins.readFile (
pkgs.runCommand "timestamp" { } ''
date --date='@${toString self.lastModified}' --iso-8601=minutes > $out
''
);

decalwebPath = default;

nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nobody nobody;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
include ${pkgs.nginx}/conf/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
server {
listen ${nginxPort};
root ${decalwebPath};
}
}
'';
in
{
name = "decalweb";
created = timestamp;
mtime = timestamp;

contents = with pkgs; [
busybox
nginx
dockerTools.fakeNss
];

extraCommands = ''
# nginx requires these dirs to exist, see:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix
mkdir -p tmp/nginx_client_body
mkdir -p var/log/nginx
'';

config = {
Cmd = [
"nginx"
"-c"
nginxConf
];
ExposedPorts = {
"${nginxPort}/tcp" = { };
};
};
}
);
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
inputsFrom = [ self.packages.${pkgs.system}.default ];
shellHook = "hugo server --minify";
};
deploy = pkgs.mkShell {
packages = with pkgs; [
rsync
openssh
];
packages = with pkgs; [
rsync
openssh
];
};
});
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
};
}
Loading