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
|
||||
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
|
||||
with lib;
|
||||
{
|
||||
options.${ccfg.custom_config_key}.boot.grub = {
|
||||
enable = mkEnableOption "Grub bootloader";
|
||||
device = mkOption {
|
||||
type = types.str;
|
||||
enable = lib.mkEnableOption "Grub bootloader";
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/dev/sda";
|
||||
description = ''
|
||||
The device to install GRUB on.
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
device = cfg.device;
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
# ccfg = import ../config.nix;
|
||||
# cfg_path = "${custom_config_key}".boot.systemd;
|
||||
cfg = config.ringofstorms_common.boot.systemd;
|
||||
ccfg = import ../config.nix;
|
||||
cfg_path = "${ccfg.custom_config_key}".boot.systemd;
|
||||
cfg = config.${cfg_path};
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.ringofstorms_common.boot.systemd = {
|
||||
enable = mkEnableOption "Systemd bootloader";
|
||||
options.${cfg_path} = {
|
||||
enable = lib.mkEnableOption "Systemd bootloader";
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader = {
|
||||
systemd-boot = {
|
||||
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 = {
|
||||
default =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
ccfg = import ./config.nix;
|
||||
cfg_path = "${ccfg.custom_config_key}";
|
||||
cfg = config.${cfg_path};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# ./boot/grub.nix
|
||||
./boot/grub.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