mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-24 09:48:30 +02:00
feat: refactoring configuration with options to make it more modular
This commit is contained in:
3
modules/nixos/base/default.nix
Normal file
3
modules/nixos/base/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
###################################################################################
|
||||
|
||||
# to install chrome, you need to enable unfree packages
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
nixpkgs.config.allowUnfree = lib.mkForce true;
|
||||
|
||||
# for nix server, we do not need to keep too much generations
|
||||
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
|
||||
|
||||
103
modules/nixos/desktop.nix
Normal file
103
modules/nixos/desktop.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfgWayland = config.modules.desktop.wayland;
|
||||
cfgXorg = config.modules.desktop.xorg;
|
||||
in {
|
||||
imports = [
|
||||
./base
|
||||
../base.nix
|
||||
|
||||
./desktop
|
||||
];
|
||||
|
||||
options.modules.desktop = {
|
||||
wayland = {
|
||||
enable = mkEnableOption "Wayland Display Server";
|
||||
};
|
||||
xorg = {
|
||||
enable = mkEnableOption "Xorg Display Server";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf cfgWayland.enable {
|
||||
####################################################################
|
||||
# NixOS's Configuration for Wayland based Window Manager
|
||||
####################################################################
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
wlr.enable = true;
|
||||
extraPortals = with pkgs; [
|
||||
xdg-desktop-portal-wlr
|
||||
];
|
||||
};
|
||||
|
||||
services = {
|
||||
xserver.enable = false; # disable xorg server
|
||||
# https://wiki.archlinux.org/title/Greetd
|
||||
greetd = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default_session = {
|
||||
# Wayland Desktop Manager is installed only for user ryan via home-manager!
|
||||
user = username;
|
||||
# .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others).
|
||||
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here.
|
||||
command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager
|
||||
# command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# fix https://github.com/ryan4yin/nix-config/issues/10
|
||||
security.pam.services.swaylock = {};
|
||||
})
|
||||
|
||||
(mkIf cfgXorg.enable {
|
||||
####################################################################
|
||||
# NixOS's Configuration for Xorg Server
|
||||
####################################################################
|
||||
|
||||
services = {
|
||||
gvfs.enable = true; # Mount, trash, and other functionalities
|
||||
tumbler.enable = true; # Thumbnail support for images
|
||||
|
||||
xserver = {
|
||||
enable = true;
|
||||
displayManager = {
|
||||
lightdm.enable = true;
|
||||
autoLogin = {
|
||||
enable = true;
|
||||
user = username;
|
||||
};
|
||||
# use a fake session to skip desktop manager
|
||||
# and let Home Manager take care of the X session
|
||||
defaultSession = "hm-session";
|
||||
};
|
||||
desktopManager = {
|
||||
runXdgAutostartIfNone = true;
|
||||
session = [
|
||||
{
|
||||
name = "hm-session";
|
||||
manage = "window";
|
||||
start = ''
|
||||
${pkgs.runtimeShell} $HOME/.xsession &
|
||||
waitPID=$!
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
# Configure keymap in X11
|
||||
xkb.layout = "us";
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./base/i18n.nix
|
||||
./base/misc.nix
|
||||
./base/networking.nix
|
||||
./base/remote-building.nix
|
||||
./base/user-group.nix
|
||||
./base/visualisation.nix
|
||||
|
||||
./base
|
||||
../base.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
{pkgs, ...}: {
|
||||
##########################################################################################################
|
||||
#
|
||||
# NixOS's Configuration for Wayland based Window Manager
|
||||
#
|
||||
# hyprland: project starts from 2022, support Wayland, envolving fast, good looking, support Nvidia GPU.
|
||||
#
|
||||
##########################################################################################################
|
||||
|
||||
imports = [
|
||||
./base/i18n.nix
|
||||
./base/misc.nix
|
||||
./base/networking.nix
|
||||
./base/remote-building.nix
|
||||
./base/user-group.nix
|
||||
./base/visualisation.nix
|
||||
|
||||
./desktop
|
||||
../base.nix
|
||||
];
|
||||
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
wlr.enable = true;
|
||||
extraPortals = with pkgs; [
|
||||
xdg-desktop-portal-wlr
|
||||
];
|
||||
};
|
||||
|
||||
services = {
|
||||
xserver.enable = false; # disable xorg server
|
||||
# https://wiki.archlinux.org/title/Greetd
|
||||
greetd = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default_session = {
|
||||
# Wayland Desktop Manager is installed only for user ryan via home-manager!
|
||||
user = "ryan";
|
||||
# .wayland-session is a script generated by home-manager, which links to the current wayland compositor(sway/hyprland or others).
|
||||
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config here.
|
||||
command = "$HOME/.wayland-session"; # start a wayland session directly without a login manager
|
||||
# command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd $HOME/.wayland-session"; # start wayland session with a TUI login manager
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# fix https://github.com/ryan4yin/nix-config/issues/10
|
||||
security.pam.services.swaylock = {};
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
{pkgs, ...}: {
|
||||
####################################################################
|
||||
#
|
||||
# NixOS's Configuration for Xorg Server
|
||||
#
|
||||
####################################################################
|
||||
|
||||
imports = [
|
||||
./base/i18n.nix
|
||||
./base/misc.nix
|
||||
./base/networking.nix
|
||||
./base/remote-building.nix
|
||||
./base/user-group.nix
|
||||
./base/visualisation.nix
|
||||
|
||||
./desktop
|
||||
../base.nix
|
||||
];
|
||||
|
||||
services = {
|
||||
gvfs.enable = true; # Mount, trash, and other functionalities
|
||||
tumbler.enable = true; # Thumbnail support for images
|
||||
|
||||
xserver = {
|
||||
enable = true;
|
||||
displayManager = {
|
||||
lightdm.enable = true;
|
||||
autoLogin = {
|
||||
enable = true;
|
||||
user = "ryan";
|
||||
};
|
||||
# use a fake session to skip desktop manager
|
||||
# and let Home Manager take care of the X session
|
||||
defaultSession = "hm-session";
|
||||
};
|
||||
desktopManager = {
|
||||
runXdgAutostartIfNone = true;
|
||||
session = [
|
||||
{
|
||||
name = "hm-session";
|
||||
manage = "window";
|
||||
start = ''
|
||||
${pkgs.runtimeShell} $HOME/.xsession &
|
||||
waitPID=$!
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
# Configure keymap in X11
|
||||
xkb.layout = "us";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user