-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrev.nix
44 lines (42 loc) · 1.37 KB
/
rev.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ lib, self }:
{
environment.etc."nixos-commit.txt".text =
let
mkDate =
dateStr:
let
dateChars = lib.stringToCharacters dateStr;
step =
value: stepVal:
if builtins.typeOf stepVal == "string" then
(step (value + stepVal))
else if builtins.typeOf stepVal == "int" then
(step (value + (builtins.elemAt dateChars stepVal)))
else
value;
in
step "";
mkInput =
inputName:
let
input = self.inputs.${inputName};
revDate =
if (input.sourceInfo or null) != null then
mkDate input.sourceInfo.lastModifiedDate 0 1 2 3 "/" 4 5 "/" 6 7 " " 8 9 ":" 10 11 ":" 12 13 null
else
"unknown";
fullRev = "${inputName}@${input.shortRev or "unknown"} (${revDate})";
in
"${inputName}@${input.sourceInfo.lastModifiedDate or "unknown"}-${input.shortRev or "unspecified"}";
in
''
[34;1mConfiguration:[m nixcfg@${self.shortRev or "unknown"} (${
mkDate self.sourceInfo.lastModifiedDate 0 1 2 3 "/" 4 5 "/" 6 7 " " 8 9 ":" 10 11 ":" 12 13 null
})
[34;1mInputs:[m ${
builtins.concatStringsSep " " (
map (mkInput) (builtins.sort (a: b: a < b) (builtins.attrNames self.inputs))
)
}
'';
}