-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pops.hive): add homeConfiguration
- Loading branch information
Showing
6 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
Submodule examples
updated
from 1b187f to db9d7d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# SPDX-FileCopyrightText: 2024 The divnix/hive Authors | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
{ | ||
lib, | ||
root, | ||
super, | ||
}: | ||
let | ||
inherit (lib) pipe; | ||
l = lib // builtins; | ||
inherit (root.hive) checks transformers; | ||
|
||
# Error reporting | ||
showAssertions = | ||
let | ||
collectFailed = | ||
cfg: l.map (x: x.message) (l.filter (x: !x.assertion) cfg.assertions); | ||
showWarnings = | ||
res: | ||
let | ||
f = w: x: l.trace "warning: ${w}" x; | ||
in | ||
l.fold f res res.config.warnings; | ||
in | ||
evaled: | ||
showWarnings ( | ||
let | ||
failed = collectFailed evaled.config; | ||
failedStr = l.concatStringsSep "\n" (map (x: "- ${x}") failed); | ||
in | ||
if failed == [ ] then evaled else throw "\nFailed assertions:\n${failedStr}" | ||
); | ||
|
||
hmCliSchema = | ||
evaled: | ||
let | ||
asserted = showAssertions evaled; | ||
in | ||
{ | ||
# __schema = "v0"; | ||
inherit (asserted) options config; | ||
inherit (asserted.config.home) activationPackage; | ||
newsDisplay = evaled.config.news.display; | ||
newsEntries = l.sort (a: b: a.time > b.time) ( | ||
l.filter (a: a.condition) evaled.config.news.entries | ||
); | ||
}; | ||
in | ||
super.walk transformers.homeConfiguration [ | ||
(config: config.bee._evaled) | ||
hmCliSchema | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# SPDX-FileCopyrightText: 2024 The divnix/hive Authors | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
{ lib, root }: | ||
{ | ||
evaled, | ||
locatedConfig, | ||
inputs ? { }, | ||
}: | ||
let | ||
inherit (root.hive) beeModule; | ||
|
||
l = lib // builtins; | ||
|
||
hmLib = import (evaled.config.bee.home + /modules/lib/stdlib-extended.nix) lib; | ||
|
||
hmModules = import (evaled.config.bee.home + /modules/modules.nix) { | ||
inherit (evaled.config.bee) pkgs; | ||
lib = hmLib; | ||
check = true; | ||
# we switch off the nixpkgs module, package instantiation needs | ||
# to happen on the `std` layer | ||
useNixpkgsModule = false; | ||
}; | ||
eval = | ||
extra: | ||
lib.evalModules { | ||
specialArgs = { | ||
modulesPath = l.toString (evaled.config.bee.home + /modules); | ||
}; | ||
modules = [ | ||
beeModule | ||
locatedConfig | ||
extra | ||
] ++ hmModules; | ||
}; | ||
bee = evaled.config.bee // { | ||
_evaled = eval { config._module.check = true; }; | ||
_unchecked = eval { config._module.check = false; }; | ||
}; | ||
in | ||
{ | ||
inherit bee; | ||
# complete module set, can be lib.evalModuled as-is | ||
imports = [ | ||
beeModule | ||
locatedConfig | ||
] ++ hmModules; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# copyright: @domenkozar https://github.com/cachix/devenv/issues/516#issue-1652139691 | ||
|
||
{ lib }: | ||
let | ||
parseLine = | ||
line: | ||
let | ||
parts = builtins.match "(.+) *= *(.+)" line; | ||
in | ||
if (!builtins.isNull parts) && (builtins.length parts) == 2 then | ||
{ | ||
name = builtins.elemAt parts 0; | ||
value = builtins.elemAt parts 1; | ||
} | ||
else | ||
null; | ||
|
||
parseEnvFile = | ||
content: | ||
builtins.listToAttrs ( | ||
lib.filter (x: !builtins.isNull x) ( | ||
map parseLine (lib.splitString "\n" content) | ||
) | ||
); | ||
|
||
envContent = file: builtins.readFile file; | ||
in | ||
parseEnvFile envContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters