mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
Work in progress refactor.
This commit is contained in:
parent
ad1faf2f24
commit
9ece41ee80
14 changed files with 130 additions and 76 deletions
|
|
@ -1,5 +1,12 @@
|
|||
{ pkgs, hostsDir ? ../config/hosts, privateHostsDir ? ../config/private/hosts
|
||||
, commonImports ? [ ../config/common ../modules ], pkgsPath ? ../pkgs }:
|
||||
{
|
||||
pkgs,
|
||||
hostsDir ? ../config/hosts,
|
||||
privateHostsDir ? ../config/private/hosts,
|
||||
commonImports ? [ ../config/common ../modules/nixos ],
|
||||
pkgsPath ? ../pkgs,
|
||||
sources ? {},
|
||||
witch ? {}
|
||||
}:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
|
|
@ -7,22 +14,37 @@ rec {
|
|||
hostNames = attrNames
|
||||
(filterAttrs (name: type: type == "directory") (builtins.readDir hostsDir));
|
||||
|
||||
hostConfig = hostName:
|
||||
{ config, ... }: {
|
||||
_module.args = { inherit hosts profiles; };
|
||||
imports = [
|
||||
(import (hostsDir + "/${hostName}/configuration.nix"))
|
||||
(import (privateHostsDir + "/${hostName}/configuration.nix"))
|
||||
../modules/deploy
|
||||
] ++ commonImports;
|
||||
networking = { inherit hostName; };
|
||||
nixpkgs.pkgs = import pkgsPath { inherit (config.nixpkgs) config; };
|
||||
hostConfig = hostName: { config, ... }: {
|
||||
_module.args = {
|
||||
inherit hosts profiles;
|
||||
};
|
||||
imports = [
|
||||
(import (hostsDir + "/${hostName}/configuration.nix"))
|
||||
(import (privateHostsDir + "/${hostName}/configuration.nix"))
|
||||
# urgh, yes, we still need to manually import the deploy module for now
|
||||
# at least if i want to keep my thing reusable.
|
||||
../modules/nixos/deploy
|
||||
] ++ commonImports;
|
||||
networking = {
|
||||
inherit hostName;
|
||||
};
|
||||
nixpkgs.pkgs = import pkgsPath { inherit (config.nixpkgs) config; };
|
||||
};
|
||||
|
||||
hosts = listToAttrs (map (hostName:
|
||||
nameValuePair hostName
|
||||
(import (pkgs.path + "/nixos") { configuration = hostConfig hostName; }))
|
||||
hostNames);
|
||||
|
||||
hosts = listToAttrs (
|
||||
map (
|
||||
hostName: nameValuePair hostName (
|
||||
import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
modules = [
|
||||
(hostConfig hostName)
|
||||
(if sources ? home-manager then sources.home-manager + "/nixos" else {})
|
||||
];
|
||||
specialArgs = { inherit sources witch; };
|
||||
}
|
||||
)
|
||||
) hostNames
|
||||
);
|
||||
|
||||
profileNames = unique (concatLists
|
||||
(mapAttrsToList (name: host: host.config.meta.deploy.profiles) hosts));
|
||||
|
|
|
|||
22
lib/modules.nix
Normal file
22
lib/modules.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
modulesDir,
|
||||
defaultFile ? "default.nix",
|
||||
importAll ? false
|
||||
}:
|
||||
|
||||
with builtins;
|
||||
|
||||
let
|
||||
filterAttrNamesToList = filter: set: foldl' (a: b: a ++ b) [] (
|
||||
map (e: if (filter e set.${e}) then [ e ] else []) (attrNames set)
|
||||
);
|
||||
nameValuePair = name: value: { inherit name value; };
|
||||
listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) {};
|
||||
directories = filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir);
|
||||
files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}")) directories;
|
||||
modules = map ({name, value}:
|
||||
# if the file contains a function, assume it to be a module and pass the path
|
||||
# (for dedup and such). if it contains anything else, pass that.
|
||||
let m = import value; in { inherit name; value = if (isFunction m) && !importAll then value else m; }
|
||||
) files;
|
||||
in (listToAttrs modules)
|
||||
34
lib/style.nix
Normal file
34
lib/style.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
rec {
|
||||
base16 = {
|
||||
color0 = "#2e3440";
|
||||
color1 = "#bf616a";
|
||||
color2 = "#a3be8c";
|
||||
color3 = "#ebcb8b";
|
||||
color4 = "#81a1c1";
|
||||
color5 = "#b48ead";
|
||||
color6 = "#88c0d0";
|
||||
color7 = "#e5e9f0";
|
||||
|
||||
color8 = "#4c566a";
|
||||
color9 = "#d08770";
|
||||
color10 = "#3b4252";
|
||||
color11 = "#434c5e";
|
||||
color12 = "#d8dee9";
|
||||
color13 = "#eceff4";
|
||||
color14 = "#5e81ac";
|
||||
color15 = "#8fbcbb";
|
||||
|
||||
color16 = "#fd971f";
|
||||
color17 = "#cc6633";
|
||||
color18 = "#383830";
|
||||
color19 = "#49483e";
|
||||
color20 = "#a59f85";
|
||||
color21 = "#f5f4f1";
|
||||
};
|
||||
|
||||
font = {
|
||||
name = "Hack Nerd Font";
|
||||
size = "9";
|
||||
size_css = "12px";
|
||||
};
|
||||
}
|
||||
6
lib/witch.nix
Normal file
6
lib/witch.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{ lib }:
|
||||
|
||||
{
|
||||
style = import ./style.nix;
|
||||
colorhelpers = import ./colorhelpers.nix { inherit lib; };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue