mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-08-16 18:00:30 +03:00
refactor: remove _loaded, add a new loadedConfig arg to src/default.nix
This commit is contained in:
parent
7be6110eaf
commit
dea20d928a
@ -163,9 +163,7 @@
|
||||
import ./src rec {
|
||||
externalDir = externalDirFor."${system}";
|
||||
inherit externalPaths externalSources inputs lib pkgs;
|
||||
config = {
|
||||
inherit overridesDirs;
|
||||
};
|
||||
config = {inherit overridesDirs;};
|
||||
});
|
||||
|
||||
docsCli = forAllSystems (
|
||||
|
@ -6,17 +6,16 @@
|
||||
pkgs ? import <nixpkgs> {},
|
||||
lib ? pkgs.lib,
|
||||
nix ? pkgs.nix,
|
||||
# default to empty dream2nix config
|
||||
# already validated config.
|
||||
# this is mainly used by src/lib.nix since it loads the config beforehand.
|
||||
loadedConfig ? null,
|
||||
# default to empty dream2nix config. This is assumed to be not loaded.
|
||||
config ?
|
||||
import ./modules/config.nix {
|
||||
configRaw =
|
||||
if builtins ? getEnv && builtins.getEnv "dream2nixConfig" != ""
|
||||
# if called via CLI, load config via env
|
||||
then builtins.toPath (builtins.getEnv "dream2nixConfig")
|
||||
# load from default directory
|
||||
else {};
|
||||
inherit lib;
|
||||
},
|
||||
if builtins ? getEnv && builtins.getEnv "dream2nixConfig" != ""
|
||||
# if called via CLI, load config via env
|
||||
then builtins.toPath (builtins.getEnv "dream2nixConfig")
|
||||
# load from default directory
|
||||
else {},
|
||||
/*
|
||||
Inputs that are not required for building, and therefore not need to be
|
||||
copied alongside a dream2nix installation.
|
||||
@ -48,16 +47,18 @@
|
||||
# load from default directory
|
||||
else ./external,
|
||||
} @ args: let
|
||||
argsConfig = config;
|
||||
in let
|
||||
b = builtins;
|
||||
|
||||
l = lib // builtins;
|
||||
|
||||
config = import ./modules/config.nix {
|
||||
configRaw = argsConfig;
|
||||
inherit lib;
|
||||
};
|
||||
config =
|
||||
if loadedConfig != null
|
||||
then loadedConfig
|
||||
else
|
||||
import ./modules/config.nix {
|
||||
inherit lib;
|
||||
rawConfig = args.config;
|
||||
};
|
||||
|
||||
configFile = pkgs.writeText "dream2nix-config.json" (b.toJSON config);
|
||||
|
||||
|
@ -13,11 +13,14 @@
|
||||
|
||||
initDream2nix = config: pkgs:
|
||||
import ./default.nix
|
||||
{inherit config inputs pkgs externalPaths externalSources;};
|
||||
{
|
||||
loadedConfig = config;
|
||||
inherit inputs pkgs externalPaths externalSources;
|
||||
};
|
||||
|
||||
loadConfig = config'': let
|
||||
config' = import ./modules/config.nix {
|
||||
configRaw = config'';
|
||||
rawConfig = config'';
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
configRaw,
|
||||
rawConfig,
|
||||
lib,
|
||||
}: let
|
||||
b = builtins;
|
||||
@ -19,14 +19,11 @@
|
||||
then input
|
||||
else throw "input for loadAttrs must be json file or string or attrs";
|
||||
|
||||
config = loadAttrs configRaw;
|
||||
config = loadAttrs rawConfig;
|
||||
|
||||
evaled = lib.evalModules {
|
||||
modules = [./config {inherit config;}];
|
||||
specialArgs = {inherit lib;};
|
||||
};
|
||||
in
|
||||
# If the config was already loaded, then we skip validating it again
|
||||
if configRaw._loaded or null == true
|
||||
then configRaw
|
||||
else evaled.config
|
||||
evaled.config
|
||||
|
@ -1,6 +1,5 @@
|
||||
{
|
||||
imports = [
|
||||
./interface.nix
|
||||
./implementation.nix
|
||||
];
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
config = {
|
||||
_loaded = true;
|
||||
};
|
||||
}
|
@ -3,11 +3,6 @@
|
||||
t = l.types;
|
||||
in {
|
||||
options = {
|
||||
_loaded = l.mkOption {
|
||||
type = t.bool;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
overridesDirs = l.mkOption {
|
||||
type = t.listOf t.path;
|
||||
default = [];
|
||||
|
Loading…
Reference in New Issue
Block a user