forked from hacc/haccfiles
meta: add build info to motd / system label, remove /etc/haccfiles
This commit is contained in:
parent
283aba0c2c
commit
069236027c
2 changed files with 31 additions and 1 deletions
|
@ -58,9 +58,9 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
./parsons/configuration.nix
|
./parsons/configuration.nix
|
||||||
|
./modules/buildinfo.nix
|
||||||
sops-nix.nixosModules.sops
|
sops-nix.nixosModules.sops
|
||||||
{ nixpkgs.pkgs = pkgs; }
|
{ nixpkgs.pkgs = pkgs; }
|
||||||
{ environment.etc."haccfiles".source = self.outPath; }
|
|
||||||
];
|
];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
sources = inputs;
|
sources = inputs;
|
||||||
|
|
30
modules/buildinfo.nix
Normal file
30
modules/buildinfo.nix
Normal 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 ""}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue