Skip to content

Instantly share code, notes, and snippets.

@benpye
Created February 21, 2021 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benpye/ab5a9b2aec1f5ec18c17a64fb3da098e to your computer and use it in GitHub Desktop.
Save benpye/ab5a9b2aec1f5ec18c17a64fb3da098e to your computer and use it in GitHub Desktop.
{ config, lib, pkgs, ... }:
with lib;
let
fromOctalStr = value:
let
toOctalDigit = d:
{
"0" = 0;
"1" = 1;
"2" = 2;
"3" = 3;
"4" = 4;
"5" = 5;
"6" = 6;
"7" = 7;
}.${d};
octalMul = x: y: x * 8 + (toOctalDigit y);
in builtins.foldl' octalMul 0 (stringToCharacters value);
toSocket = name: value:
if value == null
then null
else if name == "SockPathMode"
then fromOctalStr value
else value;
toSockets = name: value:
if value == null
then null
else mapAttrs toSocket value;
toUserAgent = name: value:
if value == null
then null
else if name == "Umask"
then fromOctalStr value
else if name == "Sockets"
then mapAttrs toSockets value
else value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment