added support for keys in external files

This commit is contained in:
Kristian Krsnik 2023-08-01 21:58:56 +02:00
parent db71bf8452
commit 12a4ab7ae7
3 changed files with 29 additions and 2 deletions

View File

@ -1,11 +1,21 @@
import requests, json, re import requests, json, re, os
from datetime import datetime from datetime import datetime
def loadSettings() -> dict: def loadSettings() -> dict:
# TODO: check integrity # TODO: check integrity
try: try:
with open('config.json', 'r') as file: with open('config.json', 'r') as file:
return json.load(file) # Read if the API keys are path to files
config = json.load(file)
keys = config['api'].keys()
mask = dict()
for key in keys:
api_key = key
if os.path.exists(key):
with open(key, 'r') as file:
api_key = file.readline().strip()
mask[key] = api_key
config['api'] = { mask[key]: value for key, value in config['api'].items() }
except FileNotFoundError: except FileNotFoundError:
sample_config = { sample_config = {
'api': {}, 'api': {},

View File

@ -40,5 +40,7 @@
type = "app"; type = "app";
}; };
}); });
homeManagerModules.default = import ./nix/hm-module.nix self;
}; };
} }

15
nix/hm-module.nix Normal file
View File

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.dyn-gandi;
in {
options.dyn-gandi = {
enable = lib.mkEnableOption null // {
description = lib.mdDoc '''';
};
};
config = lib.mkIf cfg.enable {
};
}