diff --git a/common/boot/grub.nix b/common/boot/grub.nix index 91ad85a..c174350 100644 --- a/common/boot/grub.nix +++ b/common/boot/grub.nix @@ -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; diff --git a/common/boot/systemd.nix b/common/boot/systemd.nix index 38b48c3..de3ca50 100644 --- a/common/boot/systemd.nix +++ b/common/boot/systemd.nix @@ -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; diff --git a/common/config.nix b/common/config.nix new file mode 100644 index 0000000..1101fb1 --- /dev/null +++ b/common/config.nix @@ -0,0 +1,3 @@ +{ + config_prefix = "ringofstorms_common"; +} diff --git a/common/flake.nix b/common/flake.nix index 834eed8..87526d1 100644 --- a/common/flake.nix +++ b/common/flake.nix @@ -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. + }; }; }; }; diff --git a/common/users/user.nix b/common/users/user.nix new file mode 100644 index 0000000..81079bb --- /dev/null +++ b/common/users/user.nix @@ -0,0 +1,9 @@ +{ + username, +}: +{ config, ... }: +{ + users.user.${username} = { + + }; +} diff --git a/common/users/users.nix b/common/users/users.nix new file mode 100644 index 0000000..5f3c1e9 --- /dev/null +++ b/common/users/users.nix @@ -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..*"; + }; + }; + 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; +}