diff options
author | tv <tv@krebsco.de> | 2015-07-19 16:20:16 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2015-07-19 16:20:16 +0200 |
commit | 9ab9c0f7c96bb1c14993a32d5c38c16ea7d70ea3 (patch) | |
tree | a8ca98b617848e5a9e55f1b476e4fd0ba511d8f9 /Zpkgs/tv | |
parent | 89fb0d184993ed04945997a73273f5c4bfe59b0c (diff) |
Zpkgs tv genid: init
Diffstat (limited to 'Zpkgs/tv')
-rw-r--r-- | Zpkgs/tv/default.nix | 1 | ||||
-rw-r--r-- | Zpkgs/tv/genid.nix | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Zpkgs/tv/default.nix b/Zpkgs/tv/default.nix index 3ebfdeb..631bb0e 100644 --- a/Zpkgs/tv/default.nix +++ b/Zpkgs/tv/default.nix @@ -3,6 +3,7 @@ pkgs // { dic = pkgs.callPackage ./dic.nix {}; + genid = pkgs.callPackage ./genid.nix {}; github-hosts-sync = pkgs.callPackage ./github-hosts-sync.nix {}; github-known_hosts = pkgs.callPackage ./github-known_hosts.nix {}; much = pkgs.callPackage ./much.nix {}; diff --git a/Zpkgs/tv/genid.nix b/Zpkgs/tv/genid.nix new file mode 100644 index 0000000..22ef6d2 --- /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 +'' |