Add multiple hosts & restructure things

This commit is contained in:
2024-01-30 02:51:16 +00:00
parent f5f1a2b69c
commit 5e5508ec84
37 changed files with 596 additions and 510 deletions

12
common/default.nix Normal file
View File

@@ -0,0 +1,12 @@
{ config, lib, helpers, ... }:
{
options.custom = {
modules = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
};
};
imports = (helpers.getModules "/default.nix" config.custom.modules);
}

25
common/helpers.nix Normal file
View File

@@ -0,0 +1,25 @@
{ lib, ... }: {
getModules = (filename: modules:
(builtins.filter
(path: builtins.pathExists path)
# (builtins.map
# (dirname: ./. + ("/" + dirname) + filename)
# (lib.attrsets.filterAttrs
# (entry: entry == "directory")
# (builtins.readDir ../modules)
# )
# )
(builtins.map
(path: path + filename)
modules
)
)
);
filterModules = (modules:
(builtins.filter
(path: builtins.pathExists path)
modules
)
);
}

70
common/home.nix Normal file
View File

@@ -0,0 +1,70 @@
{ pkgs, config, lib, helpers, ... }:
{
options.custom = {
username = lib.mkOption {
type = lib.types.str;
default = "dakedres";
};
nonFreePackages = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
};
wallpaper = lib.mkOption {
type = lib.types.path;
};
colors =
let
colorOption = lib.mkOption {
type = lib.types.str;
default = "#000000";
};
in
{
base00 = colorOption;
base01 = colorOption;
base02 = colorOption;
base03 = colorOption;
base04 = colorOption;
base05 = colorOption;
base06 = colorOption;
base07 = colorOption;
base08 = colorOption;
base09 = colorOption;
base0A = colorOption;
base0B = colorOption;
base0C = colorOption;
base0D = colorOption;
base0E = colorOption;
base0F = colorOption;
};
};
config =
let
username = config.custom.username;
nonFreePackages = config.custom.nonFreePackages;
in
{
home = {
username = username;
homeDirectory = "/home/${username}";
};
# Unfree packages
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) nonFreePackages;
home.packages =
map (name: pkgs.${name}) nonFreePackages;
# Take over my xsession
xsession.enable = true;
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
};
}

3
common/homeOptions.nix Normal file
View File

@@ -0,0 +1,3 @@
{ lib, ... }: {
}