modularize desktop components

This commit is contained in:
Jonas Röger 2024-04-13 16:42:51 +02:00
parent d3da8ba3ac
commit e0176ec2d9
14 changed files with 141 additions and 96 deletions

View File

@ -1,6 +1,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
home.username = "jonas"; home.username = "jonas";
@ -17,31 +18,16 @@
# The home.packages option allows you to install Nix packages into your # The home.packages option allows you to install Nix packages into your
# environment. # environment.
home.packages = [ home.packages = with pkgs; [
# # Adds the 'hello' command to your environment. It prints a friendly chromium
# # "Hello, world!" when run. firefox
# pkgs.hello fzf
nil
# # It is sometimes useful to fine-tune packages, for example, by applying nixpkgs-fmt
# # overrides. You can do that directly here, just don't forget the poetry
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of thefuck
# # fonts? vim
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) vscode
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
pkgs.chromium
pkgs.firefox
pkgs.fzf
pkgs.nil
pkgs.nixpkgs-fmt
pkgs.poetry
pkgs.thefuck
pkgs.vscode
]; ];
# Home Manager is pretty good at managing dotfiles. The primary way to manage # Home Manager is pretty good at managing dotfiles. The primary way to manage
@ -75,7 +61,7 @@
# /etc/profiles/per-user/jonas/etc/profile.d/hm-session-vars.sh # /etc/profiles/per-user/jonas/etc/profile.d/hm-session-vars.sh
# #
home.sessionVariables = { home.sessionVariables = {
# EDITOR = "emacs"; EDITOR = "vim";
}; };
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
@ -117,4 +103,11 @@
theme = "bureau"; theme = "bureau";
}; };
}; };
# wayland.windowManager.hyprland = {
# enable = true;
# settings = {
# "$mod" = "SUPER";
# };
# };
} }

View File

@ -16,7 +16,6 @@
../../modules/hardware/bluetooth.nix ../../modules/hardware/bluetooth.nix
../../modules/hardware/printing.nix ../../modules/hardware/printing.nix
../../modules/hardware/sound.nix ../../modules/hardware/sound.nix
../../modules/desktop/x11-plasma.nix
../../modules/services/docker.nix ../../modules/services/docker.nix
]; ];
@ -29,7 +28,7 @@
users.users.jonas = { users.users.jonas = {
isNormalUser = true; isNormalUser = true;
description = "Jonas"; description = "Jonas";
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [ "networkmanager" "wheel" "docker"];
packages = with pkgs; [ ]; packages = with pkgs; [ ];
}; };
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;

View File

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, inputs, ... }: { pkgs, inputs, ... }:
{ {
imports = imports =
@ -16,11 +16,15 @@
../../modules/hardware/bluetooth.nix ../../modules/hardware/bluetooth.nix
../../modules/hardware/printing.nix ../../modules/hardware/printing.nix
../../modules/hardware/sound.nix ../../modules/hardware/sound.nix
../../modules/desktop/hyprland.nix
../../modules/services/docker.nix ../../modules/services/docker.nix
../../modules/desktop/dm
../../modules/desktop/de
]; ];
nix.settings.experimental-features = [ "nix-command" "flakes" ]; desktop.dm.name = "sddm";
desktop.dm.autologin = "jonas";
desktop.de.plasma.enable = true;
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true; # services.xserver.libinput.enable = true;
@ -29,7 +33,7 @@
users.users.jonas = { users.users.jonas = {
isNormalUser = true; isNormalUser = true;
description = "Jonas"; description = "Jonas";
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [ "networkmanager" "wheel" "docker"];
packages = with pkgs; [ ]; packages = with pkgs; [ ];
}; };
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;

View File

@ -6,18 +6,18 @@
{ {
imports = [ ]; imports = [ ];
boot.initrd.availableKernelModules = [ "sd_mod" "sr_mod" ]; boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" =
{ device = "/dev/disk/by-uuid/0bbdc54a-243c-4b40-8566-c12adff1417a"; { device = "/dev/disk/by-uuid/a28cd2c0-67f3-4492-9cd9-996fdbe2b8ef";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/5DE9-BA20"; { device = "/dev/disk/by-uuid/0134-2DF5";
fsType = "vfat"; fsType = "vfat";
}; };
@ -28,8 +28,8 @@
# still possible to use this option, but it's recommended to use it in conjunction # still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`. # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eth0.useDHCP = lib.mkDefault true; # networking.interfaces.enp0s3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
virtualisation.hypervGuest.enable = true; virtualisation.virtualbox.guest.enable = true;
} }

View File

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./hyprland.nix
./plasma.nix
];
}

View File

@ -0,0 +1,22 @@
{ lib, config, ... }:
let
cfg = config.desktop.de.hyprland;
in
{
options.desktop.de.hyprland = {
enable = lib.mkEnableOption "enable hyprland desktop environment";
};
config = lib.mkIf cfg.enable {
services = {
xserver.libinput.enable = true;
dbus.enable = true;
};
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
};
}

View File

@ -0,0 +1,14 @@
{ config, lib, ... }:
let
cfg = config.desktop.de.plasma;
in
{
options.desktop.de.plasma = {
enable = lib.mkEnableOption "Enable Plasma desktop environment with sddm";
};
config = lib.mkIf cfg.enable {
services.xserver.desktopManager.plasma5.enable = true;
};
}

View File

@ -0,0 +1,39 @@
{ config, lib, ... }:
let
cfg = config.desktop.dm;
in
{
options.desktop.dm = with lib; {
name = mkOption {
type = types.nullOr (types.enum ["sddm" "gdm"]);
default = null;
description = "The display manager to use.";
};
autologin = mkOption {
type = types.nullOr types.str;
default = null;
description = "The autologin username or null for no autologin.";
};
wayland = mkOption {
type = types.bool;
default = false;
description = "Enable wayland";
};
};
imports = [
./gdm.nix
./sddm.nix
];
config = {
services.xserver.enable = true;
services.xserver = {
layout = "de";
xkbVariant = "";
};
services.xserver.displayManager.autoLogin.enable = (cfg.autologin != null);
services.xserver.displayManager.autoLogin.user = cfg.autologin;
};
}

View File

@ -0,0 +1,12 @@
{ lib, config, ... }:
let
cfg = config.desktop.dm;
in
{
config = lib.mkIf (cfg.name == "gdm") {
services.xserver.displayManager.gdm = {
enable = true;
wayland = cfg.wayland;
};
};
}

View File

@ -0,0 +1,13 @@
{ lib, config, ... }:
let
cfg = config.desktop.dm;
in
{
config = lib.mkIf (cfg.name == "sddm") {
services.xserver.displayManager.sddm = {
enable = true;
wayland.enable = cfg.wayland;
};
};
}

View File

@ -1,8 +0,0 @@
{ config, pkgs, ... }:
{
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
}

View File

@ -1,29 +0,0 @@
{ config, pkgs, ... }:
{
# Import unstable plasma6 module
imports = [
"${nixpkgs-unstable}/nixos/modules/services/desktop-managers/plasma6.nix"
];
disable = [
"services/desktop-managers/plasma6.nix"
];
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.wayland.enable = true;
services.desktopManager.plasma6.enable = true;
# Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "jonas";
}

View File

@ -1,21 +0,0 @@
{ config, ... }:
{
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "jonas";
}

View File

@ -2,5 +2,4 @@
{ {
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
users.users.jonas.extraGroups = [ "docker" ];
} }