lib.uuidFrom: generate a deterministic UUID
This commit is contained in:
parent
192e9f1b7b
commit
d18c6122be
13
flake.nix
13
flake.nix
|
@ -124,6 +124,19 @@
|
|||
"abort generators.toDhall: unhandled value (${x})";
|
||||
};
|
||||
|
||||
uuidFrom = seed:
|
||||
let digest = builtins.hashString "sha256" seed;
|
||||
in (lib.lists.foldl ({ str, off }:
|
||||
n:
|
||||
let chunk = builtins.substring off n digest;
|
||||
in {
|
||||
str = if off == 0 then chunk else "${str}-${chunk}";
|
||||
off = off + n;
|
||||
}) {
|
||||
str = "";
|
||||
off = 0;
|
||||
} [ 8 4 4 4 12 ]).str;
|
||||
|
||||
nixosSystem =
|
||||
# A derivative of the function for generating Linux NixOS systems.
|
||||
# This one is not so well tested…
|
||||
|
|
Loading…
Reference in New Issue