forked from fabian/nix_config
Add 'trivionomicon/' from commit '0ae8676d50
'
git-subtree-dir: trivionomicon git-subtree-mainline:00d3799f90
git-subtree-split:0ae8676d50
This commit is contained in:
commit
ad9c16de0c
50 changed files with 2091 additions and 0 deletions
16
trivionomicon/doctrine/default.nix
Normal file
16
trivionomicon/doctrine/default.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
lib ? pkgs.lib,
|
||||
pkgs,
|
||||
prefix ? "trivium",
|
||||
namespace ? null,
|
||||
}: let
|
||||
doctrine =
|
||||
{
|
||||
lib = import ./lib {inherit lib pkgs doctrine;};
|
||||
inherit namespace prefix;
|
||||
}
|
||||
// lib.optionalAttrs (pkgs != null) {
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
doctrine
|
23
trivionomicon/doctrine/lib/default.nix
Normal file
23
trivionomicon/doctrine/lib/default.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
lib,
|
||||
doctrine,
|
||||
pkgs,
|
||||
}: let
|
||||
close = vars: f: args:
|
||||
(
|
||||
if builtins.isPath f
|
||||
then import f
|
||||
else f
|
||||
)
|
||||
(args // vars);
|
||||
|
||||
closeLib = close {inherit lib;};
|
||||
closeFull = close {inherit lib pkgs doctrine;};
|
||||
in
|
||||
{
|
||||
inherit close;
|
||||
importAll = closeLib ./import-all.nix;
|
||||
}
|
||||
// lib.optionalAttrs (doctrine.namespace != null) {
|
||||
mkModule = closeFull ./mk-module.nix;
|
||||
}
|
21
trivionomicon/doctrine/lib/import-all.nix
Normal file
21
trivionomicon/doctrine/lib/import-all.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
lib,
|
||||
root,
|
||||
exclude ? ["default"],
|
||||
}:
|
||||
with builtins;
|
||||
with lib;
|
||||
# http://chriswarbo.net/projects/nixos/useful_hacks.html
|
||||
let
|
||||
basename = removeSuffix ".nix";
|
||||
|
||||
isMatch = name: type:
|
||||
(hasSuffix ".nix" name || type == "directory")
|
||||
&& ! elem (basename name) exclude;
|
||||
|
||||
entry = name: _: {
|
||||
name = basename name;
|
||||
value = import (root + "/${name}");
|
||||
};
|
||||
in
|
||||
mapAttrs' entry (filterAttrs isMatch (readDir root))
|
51
trivionomicon/doctrine/lib/mk-module.nix
Normal file
51
trivionomicon/doctrine/lib/mk-module.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
# The first few arguments are implicitly passed by the 'close' helper
|
||||
lib,
|
||||
pkgs,
|
||||
doctrine,
|
||||
name,
|
||||
config,
|
||||
hm ? null,
|
||||
sys ? null,
|
||||
options ? null,
|
||||
requires ? [],
|
||||
prefix ? doctrine.prefix,
|
||||
namespace ? doctrine.namespace,
|
||||
passthru ? {},
|
||||
}: let
|
||||
optionsSet = import options (passthru
|
||||
// {
|
||||
inherit config lib pkgs cfg name doctrine;
|
||||
});
|
||||
|
||||
configSet = import configFiles.${namespace} (passthru
|
||||
// {
|
||||
inherit config lib pkgs doctrine cfg;
|
||||
});
|
||||
|
||||
configFiles = lib.filterAttrs (k: v: v != null) {
|
||||
inherit sys hm;
|
||||
};
|
||||
|
||||
cfg = config.${prefix}.${name};
|
||||
in {
|
||||
config =
|
||||
lib.optionalAttrs (configFiles ? ${namespace})
|
||||
(lib.mkIf cfg.enable (lib.mkMerge [
|
||||
configSet
|
||||
{
|
||||
assertions =
|
||||
map (dependency: {
|
||||
assertion = cfg.enable -> config.${prefix}.${dependency}.enable;
|
||||
message = "${prefix}.${name}.enable requires ${prefix}.${dependency}.enable";
|
||||
})
|
||||
requires;
|
||||
}
|
||||
]));
|
||||
|
||||
options.${prefix}.${name} =
|
||||
lib.optionalAttrs (options != null && optionsSet ? ${namespace}) optionsSet.${namespace}
|
||||
// {
|
||||
enable = lib.mkEnableOption name;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue