Compare commits

...

2 Commits

Author SHA1 Message Date
stuebinm 5e51d5f252 docs: do not rebuild on each change
this does slight tweaking of paths to make the docs.hacc.space
derivation no longer depend on our entire flake, so we won't have to
rebuild it as often.
2024-04-06 23:16:43 +02:00
stuebinm 069236027c meta: add build info to motd / system label, remove /etc/haccfiles 2024-04-06 23:15:37 +02:00
3 changed files with 35 additions and 11 deletions

View File

@ -58,9 +58,9 @@
system = "x86_64-linux";
modules = [
./parsons/configuration.nix
./modules/buildinfo.nix
sops-nix.nixosModules.sops
{ nixpkgs.pkgs = pkgs; }
{ environment.etc."haccfiles".source = self.outPath; }
];
specialArgs = {
sources = inputs;

30
modules/buildinfo.nix Normal file
View File

@ -0,0 +1,30 @@
{ config, lib, pkgs, sources, ... }:
let
self = sources.self;
slice = string: start: length: with lib;
strings.concatStrings
(lists.take length
(lists.drop start
(strings.stringToCharacters string)));
formatDate = date:
let
year = slice date 0 4;
month = slice date 4 2;
day = slice date 6 2;
hour = slice date 8 2;
minute = slice date 10 2;
second = slice date 12 2;
in
"${year}-${month}-${day} ${hour}:${minute}:${second} UTC";
in
{
system.nixos.label = "${config.system.nixos.release}-haccfiles-${self.shortRev or self.dirtyShortRev}";
users.motd = ''
Welcome to ${config.networking.hostName}, running NixOS ${config.system.nixos.release}!
Built from haccfiles ${self.rev or self.dirtyRev}.
Last commit was at ${formatDate self.lastModifiedDate}.
${if self ? dirtyRev then "\nPlease remember to commit your changes.\n" else ""}
'';
}

View File

@ -1,23 +1,17 @@
{ stdenvNoCC, zola, writeScriptBin }:
{ copyPathToStore, stdenvNoCC, zola, writeScriptBin }:
stdenvNoCC.mkDerivation rec {
name = "docs.hacc.space-static";
# HINT: this is cursed. Nix flakes have no optimisation to deal with ${./.},
# so we wind up having to do this to make the symlink to content/ work.
# (we still need to manually adjust it — but at least this way we can find
# its target without further hoops)
#
# This does also mean we now copy the entire flake into the Nix store twice.
# Yay for flakes!
src = "${../../.}/websites/docs.hacc.space";
src = ./.;
content = copyPathToStore ../../docs;
phases = [ "buildPhase" ];
buildInputs = [ zola ];
buildPhase = ''
cp -r $src/* .
rm content
ln -s $src/../../docs content
ln -s $content content
zola build --output-dir $out
'';