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 208 additions and 128 deletions

View file

@ -19,7 +19,6 @@
../modules/arion ../modules/arion
../modules/borgbackup ../modules/borgbackup
../modules/nvidia.nix
]; ];
boot.tmp.useTmpfs = true; 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 { neovimIde = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;

View file

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

View file

@ -1,10 +1,19 @@
{ {
config, config,
modulesPath, modulesPath,
self,
... ...
}: { }: {
nixpkgs.hostPlatform = "x86_64-linux"; 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 = { boot = {
kernelModules = ["kvm-intel"]; kernelModules = ["kvm-intel"];
@ -45,9 +54,4 @@
zramSwap.enable = true; zramSwap.enable = true;
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware; 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; inherit (config.vars) mainUser hostName;
in { in {
imports = [ imports = [
@ -7,21 +11,30 @@ in {
../../modules/android.nix ../../modules/android.nix
../../modules/ags ../../modules/ags
../../modules/audio.nix ../../modules/audio.nix
../../modules/hyprland
../../modules/kmscon.nix ../../modules/kmscon.nix
../../modules/plymouth.nix ../../modules/plymouth.nix
../../modules/printer.nix ../../modules/printer.nix
../../modules/tailscale.nix ../../modules/tailscale.nix
./modules/security.nix ./modules/security.nix
self.nixosModules.desktop
]; ];
vars = { vars = {
mainUser = "matt"; mainUser = "matt";
hostName = "wim"; hostName = "wim";
promptMainColor = "purple"; promptMainColor = "purple";
fontSize = 12.5; };
roles.desktop = {
user = config.vars.mainUser;
mainMonitor = "eDP-1"; mainMonitor = "eDP-1";
isLaptop = true;
isTouchscreen = true;
fontSize = 12.5;
}; };
users.users.${mainUser} = { users.users.${mainUser} = {

View file

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

View file

@ -1,4 +1,5 @@
# Do not modify! This file is generated. # Do not modify! This file is generated.
{ {
inputs = { inputs = {
Hyprspace = { Hyprspace = {
@ -341,4 +342,4 @@
}; };
}; };
outputs = inputs: inputs.flakegen ./flake.in.nix inputs; outputs = inputs: inputs.flakegen ./flake.in.nix inputs;
} }

View file

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

View file

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

View file

@ -9,7 +9,8 @@
... ...
}: let }: let
inherit (lib) boolToString; inherit (lib) boolToString;
inherit (config.vars) mainUser hostName mainMonitor greetdDupe; inherit (config.vars) mainUser hostName;
cfgDesktop = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE; flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable; isTouchscreen = config.hardware.sensor.iio.enable;
@ -90,8 +91,8 @@ in {
'' ''
// //
export default { export default {
mainMonitor: '${mainMonitor}', mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString greetdDupe}, dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
hasFprintd: ${boolToString (hostName == "wim")}, 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 {config, ...}: let
inherit (config.vars) mainUser; cfg = config.roles.desktop;
in { in {
programs = { programs.dconf.enable = true;
dconf.enable = true;
};
home-manager.users.${mainUser} = { home-manager.users.${cfg.user} = {
dconf.settings = { dconf.settings = {
"org/virt-manager/virt-manager/connections" = { "org/virt-manager/virt-manager/connections" = {
autoconnect = ["qemu:///system"]; autoconnect = ["qemu:///system"];

View file

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

View file

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

View file

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

View file

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

View file

@ -4,27 +4,28 @@
lib, lib,
pkgs, pkgs,
self, self,
Vencord-src,
... ...
}: let }: let
inherit (lib) makeLibraryPath optionalString; inherit (lib) makeLibraryPath optionalString;
inherit (pkgs.writers) writeTOML; inherit (pkgs.writers) writeTOML;
inherit (config.vars) mainUser;
flakeDir = config.environment.variables.FLAKE; flakeDir = config.environment.variables.FLAKE;
cfg = config.roles.desktop;
in { in {
imports = [../dolphin.nix]; imports = [./dolphin.nix];
programs.kdeconnect.enable = true; programs.kdeconnect.enable = true;
home-manager.users.${mainUser} = { home-manager.users.${cfg.user} = {
imports = [ imports = [
../../home/foot.nix ./home/foot.nix
../../home/mpv.nix ./home/mpv.nix
../../home/obs.nix ./home/obs.nix
({config, ...}: let ({config, ...}: let
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
configDir = "${flakeDir}/modules/hyprland/config"; configDir = "${flakeDir}/modules/desktop/desktop-environment/config";
in { in {
xdg.configFile = { xdg.configFile = {
"dolphinrc".source = symlink "${configDir}/dolphinrc"; "dolphinrc".source = symlink "${configDir}/dolphinrc";
@ -98,16 +99,6 @@ in {
(pkgs.discord.override { (pkgs.discord.override {
withOpenASAR = true; withOpenASAR = true;
withVencord = 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]; buildInputs = [pkgs.makeWrapper];

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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