forked from fediversity/fediversity
		
	part of #177 Reviewed-on: Fediversity/Fediversity#452 Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Kiara Grouwstra <kiara@procolix.eu> Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
let
 | 
						|
  inherit (builtins)
 | 
						|
    attrValues
 | 
						|
    elemAt
 | 
						|
    foldl'
 | 
						|
    mapAttrs
 | 
						|
    match
 | 
						|
    readDir
 | 
						|
    readFile
 | 
						|
    ;
 | 
						|
  ## `mergeAttrs` and `concatMapAttrs` are in `lib.trivial` and `lib.attrsets`,
 | 
						|
  ## but we would rather avoid a dependency in nixpkgs for this file.
 | 
						|
  mergeAttrs = x: y: x // y;
 | 
						|
  concatMapAttrs = f: v: foldl' mergeAttrs { } (attrValues (mapAttrs f v));
 | 
						|
  removePubSuffix =
 | 
						|
    s:
 | 
						|
    let
 | 
						|
      maybeMatch = match "(.*)\.pub" s;
 | 
						|
    in
 | 
						|
    if maybeMatch == null then s else elemAt maybeMatch 0;
 | 
						|
  removeTrailingWhitespace =
 | 
						|
    s:
 | 
						|
    let
 | 
						|
      maybeMatch = match "(.*[^[:space:]])[[:space:]]*" s;
 | 
						|
    in
 | 
						|
    if maybeMatch == null then "" else elemAt maybeMatch 0;
 | 
						|
 | 
						|
  collectKeys =
 | 
						|
    dir:
 | 
						|
    concatMapAttrs (name: _: {
 | 
						|
      "${removePubSuffix name}" = removeTrailingWhitespace (readFile (dir + "/${name}"));
 | 
						|
    }) (readDir dir);
 | 
						|
in
 | 
						|
{
 | 
						|
  contributors = collectKeys ./contributors;
 | 
						|
  systems = collectKeys ./systems;
 | 
						|
  panel = removeTrailingWhitespace (readFile ./panel-ssh-key.pub);
 | 
						|
  cd = removeTrailingWhitespace (readFile ./cd-ssh-key.pub);
 | 
						|
}
 |