mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-20 21:11:57 +03:00
9ff7a0ab58
- rename command package -> add - improve handling of dream2nix config - improve purity of cli execution - automatically find git repo root - improve package update cli
34 lines
693 B
Nix
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;
|
|
} |