dream2nix/src/utils/config.nix
DavHau 9ff7a0ab58 CLI improvements
- rename command package -> add
  - improve handling of dream2nix config
  - improve purity of cli execution
  - automatically find git repo root
  - improve package update cli
2021-11-07 15:18:28 +07:00

34 lines
693 B
Nix

let
b = builtins;
# loads attrs either from s:
# - json file
# - json string
# - attrset (no changes)
loadAttrs = input:
if b.isPath input then
b.fromJSON (b.readFile input)
else if b.isString input then
b.fromJSON input
else if b.isAttrs input then
input
else
throw "input for loadAttrs must be json file or string or attrs";
# load dream2nix config extending with defaults
loadConfig = configInput:
let
config = loadAttrs configInput;
defaults = {
overridesDirs = [];
packagesDir = null;
repoName = "this repo";
};
in
defaults // config;
in
{
inherit loadConfig;
}