My Nix Configuration
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 4bdadb148a0ec86adabd58de68992a2afa23f143 33 lines 1.0 kB view raw
1{ lib, ... }: 2{ 3 toPascalCase = 4 string: 5 let 6 head = lib.toUpper (builtins.substring 0 1 string); 7 tail = builtins.substring 1 (-1) string; 8 in 9 head + tail; 10 11 # Taken from nixpkgs Vaultwarden module, licensed MIT 12 # https://github.com/NixOS/nixpkgs/blob/6c9a78c09ff4d6c21d0319114873508a6ec01655/nixos/modules/services/security/vaultwarden/default.nix#L20 13 toUpperSnakeCase = 14 name: 15 let 16 parts = builtins.split "([A-Z0-9]+)" name; 17 in 18 lib.foldl' ( 19 key: x: 20 let 21 last = lib.stringLength key - 1; 22 in 23 if lib.isList x then 24 key + lib.optionalString (key != "" && lib.substring last 1 key != "_") "_" + lib.head x 25 else if key != "" && lib.elem (lib.substring 0 1 x) lib.lowerChars then # to handle e.g. [ "disable" [ "2FAR" ] "emember" ] 26 lib.substring 0 last key 27 + lib.optionalString (lib.substring (last - 1) 1 key != "_") "_" 28 + lib.substring last 1 key 29 + lib.toUpper x 30 else 31 key + lib.toUpper x 32 ) "" parts; 33}