forked from hacc/haccfiles
stuebinm
3dc63acf52
turns out there is a string-slicing function, I just overlooked it when writing this file (it's even a builtin). So let's use that instead.
28 lines
908 B
Nix
28 lines
908 B
Nix
{ config, lib, pkgs, sources, ... }:
|
|
|
|
let
|
|
self = sources.self;
|
|
|
|
formatDate = date: with lib.strings;
|
|
let
|
|
year = substring 0 4 date;
|
|
month = substring 4 2 date;
|
|
day = substring 6 2 date;
|
|
hour = substring 8 2 date;
|
|
minute = substring 10 2 date;
|
|
second = substring 12 2 date;
|
|
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 ""}
|
|
'';
|
|
|
|
# used by monit
|
|
environment.etc."haccfiles-commit".text = self.rev or self.dirtyRev;
|
|
}
|