WIP refactor
This commit is contained in:
parent
a5c14dc701
commit
4b1bf541cf
6 changed files with 95 additions and 14 deletions
|
@ -5,21 +5,21 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
ccfg = import ../config.nix;
|
ccfg = import ../config.nix;
|
||||||
cfg = config.${ccfg.custom_config_key}.boot.grub;
|
cfg_path = "${ccfg.custom_config_key}".boot.grub;
|
||||||
|
cfg = config.${cfg_path};
|
||||||
in
|
in
|
||||||
with lib;
|
|
||||||
{
|
{
|
||||||
options.${ccfg.custom_config_key}.boot.grub = {
|
options.${ccfg.custom_config_key}.boot.grub = {
|
||||||
enable = mkEnableOption "Grub bootloader";
|
enable = lib.mkEnableOption "Grub bootloader";
|
||||||
device = mkOption {
|
device = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "/dev/sda";
|
default = "/dev/sda";
|
||||||
description = ''
|
description = ''
|
||||||
The device to install GRUB on.
|
The device to install GRUB on.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
boot.loader.grub = {
|
boot.loader.grub = {
|
||||||
enable = true;
|
enable = true;
|
||||||
device = cfg.device;
|
device = cfg.device;
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# ccfg = import ../config.nix;
|
ccfg = import ../config.nix;
|
||||||
# cfg_path = "${custom_config_key}".boot.systemd;
|
cfg_path = "${ccfg.custom_config_key}".boot.systemd;
|
||||||
cfg = config.ringofstorms_common.boot.systemd;
|
cfg = config.${cfg_path};
|
||||||
in
|
in
|
||||||
with lib;
|
|
||||||
{
|
{
|
||||||
options.ringofstorms_common.boot.systemd = {
|
options.${cfg_path} = {
|
||||||
enable = mkEnableOption "Systemd bootloader";
|
enable = lib.mkEnableOption "Systemd bootloader";
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
boot.loader = {
|
boot.loader = {
|
||||||
systemd-boot = {
|
systemd-boot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
3
common/config.nix
Normal file
3
common/config.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
config_prefix = "ringofstorms_common";
|
||||||
|
}
|
|
@ -20,13 +20,30 @@
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
default =
|
default =
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
ccfg = import ./config.nix;
|
||||||
|
cfg_path = "${ccfg.custom_config_key}";
|
||||||
|
cfg = config.${cfg_path};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# ./boot/grub.nix
|
./boot/grub.nix
|
||||||
./boot/systemd.nix
|
./boot/systemd.nix
|
||||||
|
./users/users.nix
|
||||||
];
|
];
|
||||||
|
options.${cfg_path} = {
|
||||||
|
systemName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "The name of the system.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
# // TODO ADD Nix helper stuff rest of it.
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
9
common/users/user.nix
Normal file
9
common/users/user.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
username,
|
||||||
|
}:
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
users.user.${username} = {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
53
common/users/users.nix
Normal file
53
common/users/users.nix
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
ccfg = import ../config.nix;
|
||||||
|
cfg_path = "${ccfg.custom_config_key}".users;
|
||||||
|
cfg = config.${cfg_path};
|
||||||
|
top_cfg = config."${ccfg.custom_config_key}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
option.${cfg_path} = {
|
||||||
|
adminUsers = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
example = [ "josh" ];
|
||||||
|
description = ''
|
||||||
|
List of users to be added to the system.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
primaryUser = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = lib.optionalString (cfg.adminUsers != [ ] && cfg.adminUsers != null) (
|
||||||
|
builtins.elemAt cfg.adminUsers 0
|
||||||
|
);
|
||||||
|
description = "The primary user of the system.";
|
||||||
|
};
|
||||||
|
users = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.attrs;
|
||||||
|
default = { };
|
||||||
|
description = "Normal* users to configure (not for system users). Should match nix options of users.userser.<name>.*";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config =
|
||||||
|
{
|
||||||
|
users.users = lib.mapAttrs (
|
||||||
|
name: config:
|
||||||
|
{
|
||||||
|
inherit name;
|
||||||
|
isNormalUser = true;
|
||||||
|
}
|
||||||
|
// config
|
||||||
|
) cfg.users;
|
||||||
|
|
||||||
|
programs.nh.flake = "/home/${cfg.primaryUser}/.config/nixos-config/hosts/${top_cfg.systemName}";
|
||||||
|
}
|
||||||
|
// lib.map (name: {
|
||||||
|
users.users.${name} = {
|
||||||
|
extraGroups = [ "wheel" ];
|
||||||
|
};
|
||||||
|
}) cfg.adminUsers;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue