mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 20:40:24 +01:00
feat: refactoring configuration with options to make it more modular
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
{ lib, ... }:
|
||||
|
||||
rec {
|
||||
{lib, ...}: {
|
||||
# Generate an attribute set from a list.
|
||||
#
|
||||
# lib.genAttrs [ "foo" "bar" ] (name: "x_" + name)
|
||||
@@ -8,7 +6,7 @@ rec {
|
||||
listToAttrs = lib.genAttrs;
|
||||
|
||||
# Update only the values of the given attribute set.
|
||||
#
|
||||
#
|
||||
# mapAttrs
|
||||
# (name: value: ("bar-" + value))
|
||||
# { x = "a"; y = "b"; }
|
||||
@@ -16,7 +14,7 @@ rec {
|
||||
mapAttrs = lib.attrsets.mapAttrs;
|
||||
|
||||
# Update both the names and values of the given attribute set.
|
||||
#
|
||||
#
|
||||
# mapAttrs'
|
||||
# (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
|
||||
# { x = "a"; y = "b"; }
|
||||
@@ -24,6 +22,7 @@ rec {
|
||||
mapAttrs' = lib.attrsets.mapAttrs';
|
||||
|
||||
# Merge a list of attribute sets into one. smilar to the operator `a // b`, but for a list of attribute sets.
|
||||
# NOTE: the later attribute set overrides the former one!
|
||||
#
|
||||
# mergeAttrsList
|
||||
# [ { x = "a"; y = "b"; } { x = "c"; z = "d"; } { g = "e"; } ]
|
||||
@@ -31,7 +30,7 @@ rec {
|
||||
mergeAttrsList = lib.attrsets.mergeAttrsList;
|
||||
|
||||
# Generate a string from an attribute set.
|
||||
#
|
||||
#
|
||||
# attrsets.foldlAttrs
|
||||
# (acc: name: value: acc + "\nexport ${name}=${value}")
|
||||
# "# A shell script"
|
||||
|
||||
18
lib/default.nix
Normal file
18
lib/default.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{lib, ...}: {
|
||||
colmenaSystem = import ./colmenaSystem.nix;
|
||||
macosSystem = import ./macosSystem.nix;
|
||||
nixosSystem = import ./nixosSystem.nix;
|
||||
attrs = import ./attrs.nix {inherit lib;};
|
||||
scanPaths = path:
|
||||
builtins.map
|
||||
(f: (path + "/${f}"))
|
||||
(builtins.filter # find all overlay files in the current directory
|
||||
|
||||
(
|
||||
f:
|
||||
f
|
||||
!= "default.nix" # ignore default.nix
|
||||
&& f != "README.md" # ignore README.md
|
||||
)
|
||||
(builtins.attrNames (builtins.readDir path)));
|
||||
}
|
||||
Reference in New Issue
Block a user