13 Oct 2024 |
| анимешник228 changed their display name from nikita143 to анимешник228. | 19:26:59 |
djacu | Ok so what's the problem? There are a few typographical errors | 21:14:51 |
| boeufseche joined the room. | 23:19:00 |
14 Oct 2024 |
| frank joined the room. | 18:58:23 |
15 Oct 2024 |
| 𝒕𝒂𝒏𝒗𝒊𝒓 changed their display name from Tanvir to 𝒕𝒂𝒏𝒗𝒊𝒓. | 16:06:34 |
| 𝒕𝒂𝒏𝒗𝒊𝒓 changed their profile picture. | 20:15:11 |
16 Oct 2024 |
| @cx_:matrix.org left the room. | 19:23:11 |
17 Oct 2024 |
| davidas joined the room. | 04:22:57 |
| @barryfm:matrix.org left the room. | 13:34:42 |
| Dominic Mills set a profile picture. | 17:15:01 |
| muneer joined the room. | 17:25:11 |
| bendlas changed their profile picture. | 17:37:59 |
| davidas changed their display name from David L to davidas. | 21:13:49 |
| Nikita Bobko set a profile picture. | 22:44:26 |
18 Oct 2024 |
| Tristan Ross joined the room. | 03:06:01 |
| mate joined the room. | 04:34:12 |
emily | is there anything clever that can be done to strip location information from an attrset value to ensure that builtins.unsafeGetAttrPos returns null for it? | 14:34:09 |
emily | builtins.mapAttrs (_: v: v) "cleans" an entire attrset | 15:49:08 |
emily | builtins.listToAttrs [ { name = "a"; value = orig.a; } ] also seems to do it | 15:51:36 |
19 Oct 2024 |
| radrudrod joined the room. | 01:54:58 |
| Crystal_ForceIX joined the room. | 03:28:17 |
| jwillikers joined the room. | 12:05:29 |
infinisil | In reply to @emilazy:matrix.org is there anything clever that can be done to strip location information from an attrset value to ensure that builtins.unsafeGetAttrPos returns null for it? On my phone right now, so just a guess: Perhaps deepSeq works | 14:01:31 |
20 Oct 2024 |
| Kourtni joined the room. | 06:03:19 |
| Crystal_ForceIX changed their display name from crystal_forceix to Crystal_ForceIX. | 09:44:24 |
| sebastian joined the room. | 21:22:21 |
sebastian | Hello everyone, is there a nice way to recursively convert the names of an attribute set from camalCase to snake_case?
I have the following:
{
keycloak = {
displayName = "Keycloak";
clientId = "semaphore";
clientSecret = "semaphore";
providerUrl = "https://keycloak.example.com/realms/master";;
redirectUrl = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
}
And would need:
{
keycloak = {
display_name = "Keycloak";
client_id = "semaphore";
client_secret = "l3CVYbqO5zgewnFP02iN9VkQv5u6ngo2vccO8S3BwxU=";
provider_url = "https://keycloak.example.com/realms/master";;
redirect_url = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
}
This could simplify my templating considerably and i wouldn't always have to keep the names and rewrite them manually.
I experimented once with the following, but I can't get the iteration to work properly.
let
camelToSnake = str:
builtins.foldl'
(acc: c: acc + (
if c == lib.toUpper c
then "_" + lib.toLower c
else c
)) ""
(lib.stringToCharacters str);
camelCaseToSnakeCaseAttrs = attrs: lib.attrsets.mapAttrs (name: value:
let
SnakeCase = camelToSnake name;
in
if lib.types.isAttrs value then
{ inherit SnakeCase; } // { SnakeCase = renameAttrs value; }
else
{ inherit SnakeCase; } // { SnakeCase = value; }
) attrs;
exampleSet = {
keycloak = {
displayName = "Keycloak";
clientId = "semaphore";
clientSecret = "semaphore";
providerUrl = "https://keycloak.example.com/realms/master";;
redirectUrl = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
};
in
camelCaseToSnakeCaseAttrs exampleSet
| 21:40:20 |
Artturin | In reply to @sebastian:srx.digital
Hello everyone, is there a nice way to recursively convert the names of an attribute set from camalCase to snake_case?
I have the following:
{
keycloak = {
displayName = "Keycloak";
clientId = "semaphore";
clientSecret = "semaphore";
providerUrl = "https://keycloak.example.com/realms/master";;
redirectUrl = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
}
And would need:
{
keycloak = {
display_name = "Keycloak";
client_id = "semaphore";
client_secret = "l3CVYbqO5zgewnFP02iN9VkQv5u6ngo2vccO8S3BwxU=";
provider_url = "https://keycloak.example.com/realms/master";;
redirect_url = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
}
This could simplify my templating considerably and i wouldn't always have to keep the names and rewrite them manually.
I experimented once with the following, but I can't get the iteration to work properly.
let
camelToSnake = str:
builtins.foldl'
(acc: c: acc + (
if c == lib.toUpper c
then "_" + lib.toLower c
else c
)) ""
(lib.stringToCharacters str);
camelCaseToSnakeCaseAttrs = attrs: lib.attrsets.mapAttrs (name: value:
let
SnakeCase = camelToSnake name;
in
if lib.types.isAttrs value then
{ inherit SnakeCase; } // { SnakeCase = renameAttrs value; }
else
{ inherit SnakeCase; } // { SnakeCase = value; }
) attrs;
exampleSet = {
keycloak = {
displayName = "Keycloak";
clientId = "semaphore";
clientSecret = "semaphore";
providerUrl = "https://keycloak.example.com/realms/master";;
redirectUrl = "https://semaphore.example.com/api/auth/oidc/keycloak/redirect";;
};
};
in
camelCaseToSnakeCaseAttrs exampleSet
https://github.com/kaii-zen/xinomorf/blob/43092992e19fc533ef8fe67c536d0089870b9220/lib/attrsets.nix#L2 https://github.com/rummik/nixos-config/blob/f88adb6397cdbb775a1b699d866fcb43ef3611a6/users/profiles/nixvim/helpers.nix#L35
- more at
https://github.com/search?q=lang%3Anix+snakeTo&type=code
| 23:25:07 |
Artturin | * https://github.com/kaii-zen/xinomorf/blob/43092992e19fc533ef8fe67c536d0089870b9220/lib/attrsets.nix#L2
https://github.com/rummik/nixos-config/blob/f88adb6397cdbb775a1b699d866fcb43ef3611a6/users/profiles/nixvim/helpers.nix#L3 and more at
https://github.com/search?q=lang%3Anix+snakeTo&type=code
| 23:25:29 |
21 Oct 2024 |
| @tolgaerok:matrix.org left the room. | 04:35:09 |