mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat(lib): add octalToDecimal
This commit is contained in:
parent
c3b31f0161
commit
663138ae4c
2 changed files with 9 additions and 1 deletions
8
lib.nix
8
lib.nix
|
|
@ -30,6 +30,14 @@ rec {
|
|||
builtins.readFile
|
||||
(pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");
|
||||
|
||||
exp = base: exp: foldr (value: acc: acc * base) 1 (range 1 exp);
|
||||
|
||||
octalToDecimal = value:
|
||||
(foldr (char: acc: {
|
||||
i = acc.i + 1;
|
||||
value = acc.value + (toInt char) * (exp 8 acc.i);
|
||||
}) {i = 0; value = 0;} (stringToCharacters value)).value;
|
||||
|
||||
mkValueOrSecretOption = {...}@options: mkOption ({
|
||||
type = types.nullOr (types.either types.str (types.submodule {
|
||||
options.secret = mkOption {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue