Extract desktops and bootloaders to common/

This commit is contained in:
Cameron Reed 2024-01-10 16:06:59 -07:00
parent ea5a00e6f8
commit e8d5c27c2d
7 changed files with 125 additions and 50 deletions

View File

@ -0,0 +1,45 @@
{ config, lib, ... }:
with lib; let
cfg = config.grub;
in {
options.grub = {
device = mkOption {
default = "";
example = "/dev/disk/by-id/wwn-0x500001234567890a";
type = types.str;
description = lib.mdDoc ''
The device on which the GRUB boot loader will be installed.
Setting this option also sets GRUB to use legacy boot.
For EFI, do not set this option.
'';
};
};
config = mkMerge [
{
boot.loader.grub = {
enable = true;
configurationLimit = 25;
default = "saved";
useOSProber = true;
memtest86.enable = true;
}
}
(mkIf (cfg.device == "") {
boot.loader = {
efi.canTouchEfiVariables = true;
grub = {
efiSupport = true;
device = "nodev";
};
};
})
(mkIf (cfg.device != "") { boot.loader.grub.device = cfg.device; })
];
}

View File

@ -0,0 +1,17 @@
{ pkgs, config, ... }:
{
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
editor = false;
configurationLimit = 5;
extraInstallCommands = ''
${pkgs.gnused}/bin/sed -i 's/^version Generation \([0-9]\+\).*$/version Generation \1/' /boot/loader/entries/nixos-generation-*
${pkgs.gnused}/bin/sed -i 's/^default .*$/default 00-arch.conf/' /boot/loader/loader.conf
'';
};
};
}

View File

@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
desktop = "hyprland";
programs.hyprland.enable = true;
environment.systemPackages = (with pkgs; [
waybar
dmenu
wmenu
]);
xdg.portal.wlr.enable = true;
}

21
common/desktop/sway.nix Normal file
View File

@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
desktop = "sway";
programs.sway = {
enable = true;
extraPackages = with pkgs; [
swaylock
swayidle
dmenu
wmenu
i3status
brightnessctl
wob
];
};
xdg.portal.wlr.enable = true;
}

10
common/options.nix Normal file
View File

@ -0,0 +1,10 @@
{ lib, ... }:
with lib; {
options = {
desktop = mkOption {
default = "";
type = types.str;
};
};
}

View File

@ -27,12 +27,10 @@ in {
packages = (with pkgs; [
direnv
nix-direnv
] ++ (lib.optionals (config.desktop != "") [
bibata-cursors
bibata-cursors-translucent
]) ++ (with pkgs.gnomeExtensions; [
gsconnect
dock-from-dash
]);
]));
};
};
};

View File

@ -1,16 +1,16 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
let common_dir=../../common;
in {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
# User configuration
../../common/users/users.nix
(common_dir + /options.nix)
(common_dir + /bootloader/systemd-boot.nix)
(common_dir + /users/users.nix)
(common_dir + /desktop/sway.nix)
];
@ -26,21 +26,7 @@
# Bootloader Configuration
boot.loader = {
efi.canTouchEfiVariables = true;
systemd-boot = {
enable = true;
editor = false;
configurationLimit = 5;
extraInstallCommands = ''
${pkgs.gnused}/bin/sed -i 's/^version Generation \([0-9]\+\).*$/version Generation \1/' /boot/loader/entries/nixos-generation-*
${pkgs.gnused}/bin/sed -i 's/^default .*$/default 00-arch.conf/' /boot/loader/loader.conf
'';
};
};
# Kernel Param Configuration
boot.kernelParams = [ "quiet" "splash" ];
@ -100,17 +86,21 @@
programs = {
zsh.enable = true;
vim.defaultEditor = true;
neovim = {
defaultEditor = true;
viAlias = true;
vimAlias = true;
};
};
environment.systemPackages = (with pkgs; [
vim
neovim
git
curl
wget
kitty
ranger
lf
tmux
firefox
greetd.tuigreet
@ -118,7 +108,6 @@
environment.shells = with pkgs; [ bash zsh ];
xdg.portal.wlr.enable = true;
nixpkgs.config.allowUnfree = true;
@ -197,26 +186,6 @@
# Desktop Environment Configuration
programs = {
sway = {
enable = true;
extraPackages = with pkgs; [
swaylock
swayidle
dmenu
wmenu
i3status
brightnessctl
wob
];
};
};
# User Configuration
user.cameron.enable = true;