diff options
author | tv <tv@shackspace.de> | 2015-07-19 16:20:16 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-07-19 16:20:16 +0200 |
commit | d0a1d841189481c91ccd38cf79c5db834daa4f9f (patch) | |
tree | a8ca98b617848e5a9e55f1b476e4fd0ba511d8f9 /Zpkgs/tv/genid.nix | |
parent | 2457f4183b3266b8ca35f9d3036f4fc45e62c407 (diff) |
Zpkgs tv genid: init
Diffstat (limited to 'Zpkgs/tv/genid.nix')
-rw-r--r-- | Zpkgs/tv/genid.nix | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Zpkgs/tv/genid.nix b/Zpkgs/tv/genid.nix new file mode 100644 index 000000000..22ef6d29b --- /dev/null +++ b/Zpkgs/tv/genid.nix @@ -0,0 +1,21 @@ +{ lib, pkgs, ... }: + +pkgs.writeScriptBin "genid" '' + #! /bin/sh + # usage: genid NAME + set -euf + + export PATH=${lib.makeSearchPath "bin" (with pkgs; [ + bc + coreutils + ])} + + name=$1 + hash=$(printf %s "$name" | sha1sum | cut -d\ -f1 | tr a-f A-F) + echo " + min=2^16 # bigger than nobody and nogroup, see <nixos/modules/misc/ids.nix> + max=2^32 # see 2^(8*sizeof(uid_t)) + ibase=16 + ($hash + min) % max + " | bc +'' |