WIP refactor
This commit is contained in:
parent
6381cb0ea1
commit
7e7f04574b
13 changed files with 1150 additions and 166 deletions
35
common/boot/default.nix
Normal file
35
common/boot/default.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
ccfg = import ../config.nix;
|
||||
cfg = config.${ccfg.custom_config_key}.boot;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./grub.nix
|
||||
./systemd.nix
|
||||
];
|
||||
config = {
|
||||
assertions = [
|
||||
(
|
||||
let
|
||||
enabledBootloaders = lib.filter (x: x.enabled) [
|
||||
{
|
||||
name = "systemd";
|
||||
enabled = cfg.systemd.enable;
|
||||
}
|
||||
{
|
||||
name = "grub";
|
||||
enabled = cfg.grub.enable;
|
||||
}
|
||||
];
|
||||
in
|
||||
{
|
||||
assertion = lib.length enabledBootloaders <= 1;
|
||||
message =
|
||||
"Only one bootloader can be enabled at a time. Enabled: "
|
||||
+ lib.concatStringsSep ", " (map (x: x.name) enabledBootloaders);
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -5,20 +5,27 @@
|
|||
}:
|
||||
let
|
||||
ccfg = import ../config.nix;
|
||||
cfg_path = "${ccfg.custom_config_key}".boot.grub;
|
||||
cfg = config.${cfg_path};
|
||||
cfg_path = [
|
||||
ccfg.custom_config_key
|
||||
"boot"
|
||||
"grub"
|
||||
];
|
||||
cfg = lib.attrsets.getAttrFromPath cfg_path config;
|
||||
in
|
||||
{
|
||||
options.${ccfg.custom_config_key}.boot.grub = {
|
||||
enable = lib.mkEnableOption "Grub bootloader";
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/dev/sda";
|
||||
description = ''
|
||||
The device to install GRUB on.
|
||||
'';
|
||||
options =
|
||||
{ }
|
||||
// lib.attrsets.setAttrByPath cfg_path {
|
||||
enable = lib.mkEnableOption "Grub bootloader";
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/dev/sda";
|
||||
description = ''
|
||||
The device to install GRUB on.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,19 @@
|
|||
}:
|
||||
let
|
||||
ccfg = import ../config.nix;
|
||||
cfg_path = "${ccfg.custom_config_key}".boot.systemd;
|
||||
cfg = config.${cfg_path};
|
||||
cfg_path = [
|
||||
ccfg.custom_config_key
|
||||
"boot"
|
||||
"systemd"
|
||||
];
|
||||
cfg = lib.attrsets.getAttrFromPath cfg_path config;
|
||||
in
|
||||
{
|
||||
options.${cfg_path} = {
|
||||
enable = lib.mkEnableOption "Systemd bootloader";
|
||||
};
|
||||
options =
|
||||
{ }
|
||||
// lib.attrsets.setAttrByPath cfg_path {
|
||||
enable = lib.mkEnableOption "Systemd bootloader";
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader = {
|
||||
systemd-boot = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue