[Nix-dev] User and group ID ranges

Игорь Пашев pashev.igor at gmail.com
Thu Jan 14 10:55:45 CET 2016


I use this function to get IDs:

 uid = name:
    let
      dec = {
        "0" =  0; "1" =  1; "2" =  2; "3" =  3;
        "4" =  4; "5" =  5; "6" =  6; "7" =  7;
        "8" =  8; "9" =  9; "a" = 10; "b" = 11;
        "c" = 12; "d" = 13; "e" = 14; "f" = 15;
      };
      base = 1000000000; # 2^31 > base + 16^7, 2^31 for JSON int
      hex = lib.toLower (builtins.substring 0 7 (builtins.hashString
"sha1" name));
      pow = b: n: lib.foldl builtins.mul 1 (builtins.genList (_: b) n);
      digits = lib.imap (i: d: {m = pow 16 (i - 1); d = d;})
(lib.stringToCharacters hex);
      f = a: {m, d}: a + m * dec.${d};

    in lib.foldl f base digits;

2016-01-13 16:02 GMT+03:00 Christian Kauhaus <kc at flyingcircus.io>:
> Hi,
>
> we are currently in the process of configuring users and groups with fixed
> UID/GID numbers from a central directory on a bunch of NixOS machines.
>
> I'd like to clarify some policy issues to avoid future ID conflicts.


More information about the nix-dev mailing list