Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shay Bergmann
committed
Jun 8, 2021
1 parent
7c5340c
commit b50d229
Showing
16 changed files
with
181 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ lib }: rec { | ||
recImport = import ./rec-import.nix { inherit lib; }; | ||
sanitize = import ./sanitize.nix { inherit lib snakeCase; }; | ||
snakeCase = import ./snake-case.nix { inherit lib; }; | ||
mkModules = import ./make-modules.nix { inherit lib; }; | ||
} | ||
|
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,38 @@ | ||
{ lib }: dir: | ||
|
||
let | ||
join = a: b: if a == "" then b else "${a}-${b}"; | ||
|
||
inherit (builtins) readDir mapAttrs attrValues foldl' elemAt typeOf substring stringLength listToAttrs; | ||
|
||
convert = prefix: d: | ||
let | ||
entries = readDir d; | ||
expanded = mapAttrs (name: type: | ||
if type == "regular" then [ | ||
(join prefix name) | ||
(d + "/${name}") | ||
] else if type == "directory" then [ | ||
(join prefix name) | ||
(convert (join prefix name) (d + "/${name}")) | ||
] else | ||
null) entries; | ||
in attrValues expanded; | ||
|
||
tree = convert "" dir; | ||
|
||
result = sum: input: | ||
foldl' (s: elems: | ||
let | ||
cat = elemAt elems 0; | ||
car = elemAt elems 1; | ||
in if typeOf car == "list" then | ||
(result s car) | ||
else | ||
s ++ [{ | ||
name = substring 0 ((stringLength cat) - 4) cat; | ||
value = import car; | ||
}]) sum input; | ||
|
||
folded = result [ ] tree; | ||
in listToAttrs folded |
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
{ lib }: | ||
let | ||
inherit (builtins) attrNames readDir; | ||
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair; | ||
inherit (lib) filterAttrs hasSuffix removeSuffix mapAttrs' nameValuePair; | ||
|
||
# mapFilterAttrs :: | ||
# (name -> value -> bool ) | ||
# (name -> value -> { name = any; value = any; }) | ||
# attrs | ||
mapFilterAttrs = sieve: f: attrs: filterAttrs sieve (mapAttrs' f attrs); | ||
|
||
in { dir, _import ? base: import "${dir}/${base}.nix" }: | ||
mapFilterAttrs (_: v: v != null) (n: v: | ||
recImport = { dir, _import ? base: builtins.trace "importing ${toString dir} ${base}" (import (dir + "/${base}.nix")) }: | ||
mapFilterAttrs (_: v: v != null) (n: v: | ||
if n != "default.nix" | ||
&& ((hasSuffix ".nix" n && v == "regular" && false) || v == "directory") | ||
&& ((hasSuffix ".nix" n && v == "regular") || v == "directory") | ||
|
||
then | ||
let name = n; in nameValuePair (name) (_import name) | ||
then let | ||
baseName = removeSuffix ".nix" n; | ||
in nameValuePair (baseName) (if v == "regular" then _import baseName else recImport { dir = dir + "/${baseName}"; }) | ||
|
||
else nameValuePair ("") (null)) (readDir dir); | ||
|
||
in recImport | ||
|
||
else | ||
nameValuePair ("") (null)) (readDir dir) |
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
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,9 @@ | ||
{ ... }: { | ||
# NOTE Shouldn't these just go inside their respective modules? | ||
disabledModules = [ | ||
"services/databases/victoriametrics.nix" | ||
"services/monitoring/telegraf.nix" | ||
"services/networking/consul.nix" | ||
"services/security/vault.nix" | ||
]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ self, ... }: { | ||
imports = [ self.inputs.hydra-provisioner.nixosModules.hydra-provisioner ]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.