refactor: start making flake exposed modules with desktop
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-06-27 00:56:27 -04:00
parent c119757766
commit 85a3c28438
49 changed files with 206 additions and 127 deletions

View file

@ -19,7 +19,6 @@
../modules/arion
../modules/borgbackup
../modules/nvidia.nix
];
boot.tmp.useTmpfs = true;

View file

@ -56,28 +56,6 @@ in {
'';
};
mainMonitor = mkOption {
type = types.str;
description = ''
The name of the main monitor used for Hyprland
and Regreet which also uses Hyprland
'';
# This is to allow a bash script to know whether this value exists
default = "null";
};
greetdDupe = mkOption {
type = types.bool;
description = ''
If we should duplicate regreet on all monitors
'';
default = true;
};
fontSize = mkOption {
type = types.nullOr types.float;
};
neovimIde = mkOption {
type = types.bool;
default = true;

View file

@ -1,4 +1,8 @@
{config, ...}: let
{
config,
self,
...
}: let
inherit (config.vars) mainUser hostName;
in {
imports = [
@ -7,7 +11,6 @@ in {
../../modules/android.nix
../../modules/ags
../../modules/audio.nix
../../modules/hyprland
../../modules/kmscon.nix
../../modules/printer.nix
../../modules/ratbag-mice.nix
@ -16,14 +19,22 @@ in {
./modules/gpu-replay.nix
./modules/nix-gaming.nix
self.nixosModules.desktop
];
vars = {
mainUser = "matt";
hostName = "binto";
promptMainColor = "purple";
};
roles.desktop = {
user = config.vars.mainUser;
mainMonitor = "desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
greetdDupe = false;
displayManager.duplicateScreen = false;
fontSize = 12.5;
};

View file

@ -1,10 +1,19 @@
{
config,
modulesPath,
self,
...
}: {
nixpkgs.hostPlatform = "x86_64-linux";
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
self.nixosModules.nvidia
];
nvidia = {
enable = true;
enableCUDA = true;
};
boot = {
kernelModules = ["kvm-intel"];
@ -45,9 +54,4 @@
zramSwap.enable = true;
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware;
nvidia = {
enable = true;
enableCUDA = true;
};
}

View file

@ -1,4 +1,8 @@
{config, ...}: let
{
config,
self,
...
}: let
inherit (config.vars) mainUser hostName;
in {
imports = [
@ -7,21 +11,30 @@ in {
../../modules/android.nix
../../modules/ags
../../modules/audio.nix
../../modules/hyprland
../../modules/kmscon.nix
../../modules/plymouth.nix
../../modules/printer.nix
../../modules/tailscale.nix
./modules/security.nix
self.nixosModules.desktop
];
vars = {
mainUser = "matt";
hostName = "wim";
promptMainColor = "purple";
fontSize = 12.5;
};
roles.desktop = {
user = config.vars.mainUser;
mainMonitor = "eDP-1";
isLaptop = true;
isTouchscreen = true;
fontSize = 12.5;
};
users.users.${mainUser} = {

View file

@ -50,6 +50,11 @@
nixpkgs.lib.genAttrs supportedSystems (system:
attrs system (mkPkgs system nixpkgs));
in {
nixosModules = {
desktop = import ./modules/desktop;
nvidia = import ./modules/nvidia.nix;
};
nixosConfigurations = {
# Desktops
wim = mkNixOS [

BIN
flake.nix

Binary file not shown.

View file

@ -1 +0,0 @@
../config/.eslintrc.json

View file

@ -1 +0,0 @@
../config/.stylelintrc.yml

View file

@ -9,7 +9,8 @@
...
}: let
inherit (lib) boolToString;
inherit (config.vars) mainUser hostName mainMonitor greetdDupe;
inherit (config.vars) mainUser hostName;
cfgDesktop = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable;
@ -90,8 +91,8 @@ in {
''
//
export default {
mainMonitor: '${mainMonitor}',
dupeLockscreen: ${boolToString greetdDupe},
mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
hasFprintd: ${boolToString (hostName == "wim")},
};
'';

View file

@ -0,0 +1,82 @@
{
config,
lib,
self,
...
}: let
inherit (lib) types;
inherit (lib.options) mkOption;
cfg = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE;
in {
imports = [
./display-manager
./desktop-environment
self.nixosModules.nvidia
];
config.assertions = [
{
assertion = lib.hasPrefix "/home/${cfg.user}/" flakeDir;
message = ''
Your $FLAKE environment variable needs to point to a directory in
the main users' home to use the desktop module.
'';
}
];
options.roles.desktop = {
user = mkOption {
type = types.str;
description = ''
The name of the user who is going to be using the "DE".
'';
};
mainMonitor = mkOption {
type = types.str;
description = ''
The name of the main monitor used for Hyprland
and Greetd which also uses Hyprland.
'';
# This is to allow a bash script to know whether this value exists
default = "null";
};
fontSize = mkOption {
type = types.float;
default = 12.0;
description = ''
The size of the font in GUIs.
'';
};
isLaptop = mkOption {
type = types.bool;
description = ''
If the computer is a laptop.
'';
default = false;
};
isTouchscreen = mkOption {
type = types.bool;
description = ''
If the computer has a touchscreen.
'';
default = false;
};
displayManager = {
duplicateScreen = mkOption {
type = types.bool;
description = ''
If we should duplicate the login prompt on all monitors.
'';
default = true;
};
};
};
}

View file

@ -1,11 +1,9 @@
{config, ...}: let
inherit (config.vars) mainUser;
cfg = config.roles.desktop;
in {
programs = {
dconf.enable = true;
};
programs.dconf.enable = true;
home-manager.users.${mainUser} = {
home-manager.users.${cfg.user} = {
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = ["qemu:///system"];

View file

@ -1,27 +1,26 @@
{
config,
hyprland,
pkgs,
lib,
pkgs,
...
}: let
inherit (lib) concatStringsSep optionals;
inherit (config.vars) mainUser;
isTouchscreen = config.hardware.sensor.iio.enable;
cfg = config.roles.desktop;
cfg =
hyprCfg =
config
.home-manager
.users
.${mainUser}
.${cfg.user}
.wayland
.windowManager
.hyprland;
in {
# SYSTEM CONFIG
imports = [
../dconf.nix
./dconf.nix
./packages.nix
./security.nix
@ -31,12 +30,12 @@ in {
dbus.enable = true;
gvfs.enable = true;
libinput.enable = true;
xserver.wacom.enable = isTouchscreen;
xserver.wacom.enable = cfg.isTouchscreen;
};
programs.hyprland = {
enable = true;
package = cfg.finalPackage;
package = hyprCfg.finalPackage;
portalPackage =
hyprland
.packages
@ -64,17 +63,17 @@ in {
};
# HOME-MANAGER CONFIG
home-manager.users.${mainUser} = {
home-manager.users.${cfg.user} = {
imports = [
./dev.nix
./home/dev.nix
# Plugins
./hyprgrass.nix
./hyprexpo.nix
# ./Hyprspace.nix
./home/hyprgrass.nix
./home/hyprexpo.nix
# ./home/Hyprspace.nix
./inputs.nix
./style.nix
./home/inputs.nix
./home/style.nix
];
wayland.windowManager.hyprland = {

View file

@ -1,9 +1,9 @@
{
config,
lib,
osConfig,
...
}: let
inherit (config.vars) fontSize;
cfg = osConfig.roles.desktop;
in {
programs = {
# https://codeberg.org/dnkl/foot/wiki#spawning-new-terminal-instances-in-the-current-working-directory
@ -35,7 +35,7 @@ in {
term = "xterm-256color";
font = "JetBrainsMono Nerd Font:size=${
lib.strings.floatToString fontSize
lib.strings.floatToString cfg.fontSize
}";
pad = "0x10";
};

View file

@ -1,15 +1,15 @@
{
osConfig,
hyprgrass,
lib,
osConfig,
pkgs,
...
}: let
inherit (lib) optionalAttrs;
inherit (lib) mkIf;
isTouchscreen = osConfig.hardware.sensor.iio.enable;
cfg = osConfig.roles.desktop;
in
optionalAttrs isTouchscreen {
mkIf cfg.isTouchscreen {
wayland.windowManager.hyprland = {
plugins = [hyprgrass.packages.${pkgs.system}.default];

View file

@ -1,6 +1,6 @@
{osConfig, ...}: let
inherit (osConfig.services.xserver) xkb;
inherit (osConfig.vars) mainMonitor;
inherit (osConfig.roles.desktop) mainMonitor;
miceNames = [
"logitech-g502-x"

View file

@ -4,27 +4,28 @@
lib,
pkgs,
self,
Vencord-src,
...
}: let
inherit (lib) makeLibraryPath optionalString;
inherit (pkgs.writers) writeTOML;
inherit (config.vars) mainUser;
flakeDir = config.environment.variables.FLAKE;
cfg = config.roles.desktop;
in {
imports = [../dolphin.nix];
imports = [./dolphin.nix];
programs.kdeconnect.enable = true;
home-manager.users.${mainUser} = {
home-manager.users.${cfg.user} = {
imports = [
../../home/foot.nix
../../home/mpv.nix
../../home/obs.nix
./home/foot.nix
./home/mpv.nix
./home/obs.nix
({config, ...}: let
symlink = config.lib.file.mkOutOfStoreSymlink;
configDir = "${flakeDir}/modules/hyprland/config";
configDir = "${flakeDir}/modules/desktop/desktop-environment/config";
in {
xdg.configFile = {
"dolphinrc".source = symlink "${configDir}/dolphinrc";
@ -98,16 +99,6 @@ in {
(pkgs.discord.override {
withOpenASAR = true;
withVencord = true;
# FIXME: remove this when vencord is up to date
vencord = pkgs.vencord.overrideAttrs {
src = pkgs.fetchFromGitHub {
owner = "Vendicated";
repo = "Vencord";
rev = "e9e789be7093e8b025f606cde69b3d89760c9380";
hash = "sha256-kBMyxV9XlrKEZ5whV81vA4EAZiYRpgIgal7fY5KGoVs=";
};
};
})
];
buildInputs = [pkgs.makeWrapper];

View file

@ -4,12 +4,11 @@
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (config.vars) mainUser;
inherit (lib) getExe mkIf;
isLaptop = config.services.logind.lidSwitch == "lock";
cfg = config.roles.desktop;
hmCfg = config.home-manager.users.${mainUser};
hmCfg = config.home-manager.users.${cfg.user};
agsPkg = hmCfg.programs.ags.finalPackage;
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
@ -23,12 +22,12 @@
text = ''
params=( "$@" )
user="$(id -u ${mainUser})"
user="$(id -u ${cfg.user})"
readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")"
run() {
export HYPRLAND_INSTANCE_SIGNATURE="$1"
sudo -Eu ${mainUser} hyprctl dispatch exec "''${params[@]}"
sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}"
}
i=0
@ -48,17 +47,11 @@
text = ''
ags -r 'Tablet.setLaptopMode()'
ags -b lockscreen -c /home/${mainUser}/.config/ags/lockscreen.js
ags -b lockscreen -c /home/${cfg.user}/.config/ags/lockscreen.js
'';
};
in {
imports = [
../greetd
];
services.gnome.gnome-keyring.enable = true;
services.acpid = mkIf isLaptop {
services.acpid = mkIf cfg.isLaptop {
enable = true;
lidEventCommands =
@ -69,11 +62,11 @@ in {
case "$state" in
*open*)
${runInDesktop}/bin/runInDesktop "ags -b lockscreen -r 'authFinger()'"
${getExe runInDesktop} "ags -b lockscreen -r 'authFinger()'"
;;
*close*)
${runInDesktop}/bin/runInDesktop ${lockPkg}/bin/lock
${getExe runInDesktop} ${getExe lockPkg}
;;
*)
@ -83,7 +76,7 @@ in {
'';
};
home-manager.users.${mainUser} = {
home-manager.users.${cfg.user} = {
home.packages = [
pkgs.gnome.seahorse
lockPkg
@ -107,7 +100,7 @@ in {
];
bind = [
"$mainMod, L, exec, ${lockPkg}/bin/lock"
"$mainMod, L, exec, ${getExe lockPkg}"
];
};
};

View file

@ -4,13 +4,13 @@
pkgs,
...
}: let
inherit (config.vars) mainUser;
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${mainUser}
.${cfg.user}
.wayland
.windowManager
.hyprland
@ -25,8 +25,8 @@ in {
home-manager.users.greeter = {
imports = [
astal.homeManagerModules.default
../../home/theme
../../home/wpaperd.nix
../home/theme
../home/wpaperd.nix
];
programs.astal.enable = true;
@ -41,7 +41,7 @@ in {
xdg.configFile = {
"astal" = {
source = ../ags/astal;
source = ./astal;
recursive = true;
};

View file

@ -0,0 +1 @@
../../../ags/config/.eslintrc.json

View file

@ -0,0 +1 @@
../../../ags/config/.stylelintrc.yml

View file

@ -19,5 +19,5 @@
"./node_modules"
],
"skipLibCheck": true
},
}
}

View file

@ -4,21 +4,23 @@
pkgs,
...
}: let
inherit (config.vars) mainUser;
inherit (import ./hyprland.nix {inherit config lib pkgs;}) hyprConf;
# Nix stuff
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${mainUser}
.${cfg.user}
.wayland
.windowManager
.hyprland
.finalPackage;
in {
imports = [./astal.nix];
imports = [
./astal.nix
];
services = {
displayManager.sessionPackages = [hyprland];
@ -33,7 +35,7 @@ in {
initial_session = {
command = "Hyprland";
user = mainUser;
user = cfg.user;
};
};
};

View file

@ -15,16 +15,17 @@
mapAttrsToList
optionalString
;
inherit (config.vars) mainUser;
inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors;
cfg = config.roles.desktop;
# Nix stuff
cfgHypr =
config
.home-manager
.users
.${mainUser}
.${cfg.user}
.wayland
.windowManager
.hyprland;

View file

@ -3,13 +3,13 @@
pkgs,
...
}: let
inherit (config.vars) mainUser greetdDupe mainMonitor;
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${mainUser}
.${cfg.user}
.wayland
.windowManager
.hyprland
@ -20,7 +20,7 @@
name = "dupeMonitors";
runtimeInputs = [hyprland pkgs.jq];
text = ''
main="${mainMonitor}"
main="${cfg.mainMonitor}"
names="($(hyprctl -j monitors | jq -r '.[] .description'))"
if [[ "$main" == "null" ]]; then
@ -43,7 +43,7 @@
# Check if user wants the greeter only on main monitor
in {
setupMonitors =
if (mainMonitor != "null" && !greetdDupe)
then "hyprctl dispatch focusmonitor ${mainMonitor}"
if (cfg.mainMonitor != "null" && !cfg.displayManager.duplicateScreen)
then "hyprctl dispatch focusmonitor ${cfg.mainMonitor}"
else "${dupeMonitors}/bin/dupeMonitors";
}

View file

@ -1,11 +1,12 @@
{
pkgs,
lib,
config,
osConfig,
...
}: let
inherit (config.vars) fontSize;
inherit (import ./gradience.nix {inherit pkgs lib;}) gradience;
cfg = osConfig.roles.desktop;
in {
home.packages = with pkgs; [
gnomeExtensions.user-themes
@ -27,7 +28,7 @@ in {
font = {
name = "Sans Serif";
size = fontSize;
size = cfg.fontSize;
};
gtk3 = {

View file

@ -1,12 +1,13 @@
{
config,
lib,
osConfig,
pkgs,
self,
...
}: let
inherit (config.vars) fontSize;
inherit (self.legacyPackages.${pkgs.system}) dracula;
cfg = osConfig.roles.desktop;
in {
home.packages = with pkgs; [
libsForQt5.qtstyleplugin-kvantum
@ -19,7 +20,7 @@ in {
};
xdg.configFile = let
floatFont = lib.strings.floatToString fontSize;
floatFont = lib.strings.floatToString cfg.fontSize;
qtconf =
# ini
''