chunk flake into modules (part 1)

This commit is contained in:
Franek 2025-03-23 18:37:32 +01:00
parent f188b9f398
commit cfd21c973d
18 changed files with 233 additions and 122 deletions

View File

@ -4,12 +4,6 @@
# DO NOT change this unless you know what you're doing!
system.stateVersion = "24.11";
environment.variables = {
XDG_SESSION_TYPE = "wayland";
XDG_CURRENT_DESKTOP = "Hyprland";
NIXPKGS_ALLOW_INSECURE = 1;
};
nixpkgs.config = {
allowInsecurePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
"fluffychat-linux"
@ -21,8 +15,6 @@
environment.systemPackages = with pkgs; [
alacritty
vim
bluez
xwayland
unzip
networkmanager
];
@ -31,6 +23,4 @@
boot.loader.grub.enable = false;
boot.loader.systemd-boot.enable = true;
programs.xwayland.enable = true;
}

View File

@ -2,8 +2,6 @@
imports = [
./hardware-configuration.nix
./modules.nix
./services.nix
./programs.nix
./users.nix
./networking.nix
];

View File

@ -1,12 +1,51 @@
{ inputs, ... }:
{ pkgs, inputs, ... }:
{
imports = [
../../modules/nvidia-support.nix
../../modules/fingerprint.nix
../../modules/apple-style.nix
../../modules/bluetooth.nix
../../modules/greetd.nix
inputs.nordvpn.nixosModules.nordvpn
];
# DEs
../../modules/desktop-environments/hyprland.nix
# Utilities
../../modules/nixos/nvidia-support.nix
../../modules/nixos/fingerprint.nix
../../modules/nixos/apple-style.nix
../../modules/nixos/bluetooth.nix
../../modules/nixos/greetd.nix
../../modules/nixos/audio.nix
# Apps
inputs.nordvpn.nixosModules.nordvpn
];
modules.hyprland = {
enable = true;
additionalPackages = with pkgs; [ hyprshot ];
};
modules.apple-style.enable = true;
modules.bluetooth.enable = true;
modules.nvidia.enable = true;
modules.audio.enable = true;
modules.fingerprint-fix = {
enable = true;
calibDataFile = ./calib-data.bin;
};
services = {
nordvpn.enable = true;
printing = {
enable = true;
drivers = with pkgs; [ hplipWithPlugin ];
};
};
programs = {
adb.enable = true;
thunar.enable = true;
thunar.plugins = with pkgs.xfce; [
thunar-archive-plugin
thunar-volman
];
};
}

View File

@ -1,11 +0,0 @@
{ pkgs, ... }:
{
programs.adb.enable = true;
programs.thunar.enable = true;
programs.thunar.plugins = with pkgs.xfce; [
thunar-archive-plugin
thunar-volman
];
}

View File

@ -1,37 +0,0 @@
{ pkgs, ... }:
{
services.greetd-hyprland.enable = true;
services.apple-style.enable = true;
services.bluetooth.enable = true;
services.nvidia.enable = true;
services.fingerprint-fix = {
enable = true;
calibDataFile = ./calib-data.bin;
};
services.nordvpn.enable = true;
services.upower.enable = true;
services.udev.enable = true;
services.udev.packages = [ pkgs.hyprland ];
services.printing = {
enable = true;
drivers = with pkgs; [ hplipWithPlugin ];
};
services.gvfs.enable = true;
services.geoclue2 = {
enableWifi = true;
geoProviderUrl = "https://api.beacondb.net/v1/geolocate";
};
services.dbus.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
}

View File

@ -13,6 +13,4 @@ in {
shell = preferredShell;
ignoreShellProgramCheck = true; # Will do it later in profile configuration
};
users.users.nordvpn.extraGroups = [ "networkmanager" ];
}

View File

@ -0,0 +1,66 @@
{ pkgs, config, lib, ... }:
{
options.modules.hyprland = {
enable = lib.mkEnableOption "Enable Hyprland";
additionalPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
description = "Additional Hyprland-related packages to install";
default = [];
};
};
config = lib.mkIf config.modules.hyprland.enable {
environment.systemPackages = with pkgs; [
hyprlock hypridle wl-clipboard cliphist swww
] ++ config.modules.hyprland.additionalPackages;
programs.hyprland.withUWSM = true;
programs.hyprland.enable = true;
programs.hyprland.xwayland.enable = true;
services.logind.extraConfig = ''
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=ignore
HandlePowerKey=ignore
'';
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
];
};
security.polkit.enable = true;
systemd.user.services.authentication-agent = {
description = "GNOME Authentication Agent";
wantedBy = ["graphical-session.target"];
wants = ["graphical-session.target"];
after = ["graphical-session.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
services = {
dbus.enable = true;
gvfs.enable = true;
upower.enable = true;
power-profiles-daemon.enable = true;
};
services.xserver.displayManager = {
gdm.enable = true;
startx.enable = true;
};
systemd.tmpfiles.rules = [
"d '/var/cache/greeter' - greeter greeter - -"
];
};
}

View File

@ -1,16 +0,0 @@
{ config, lib, pkgs, ... }:
{
options.services.greetd-hyprland.enable = lib.mkEnableOption "Enable GreetD with TUI-based login.";
config = lib.mkIf config.services.greetd-hyprland.enable {
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland";
};
};
};
};
}

View File

@ -0,0 +1,45 @@
{ config, pkgs, lib, ... }:
{
options.modules.darkman = {
enable = lib.mkEnableOption "Darkman service and integration";
customLightModeScript = lib.mkOption {
type = lib.types.str;
description = "Path to custom light mode script";
};
customDarkModeScript = lib.mkOption {
type = lib.types.str;
description = "Path to custom dark mode script";
};
};
config = lib.mkIf config.modules.darkman.enable {
home.packages = with pkgs; [ dconf ];
services.darkman = {
enable = true;
darkModeScripts = {
theme = ''
${pkgs.dconf}/bin/dconf write\
/org/gnome/desktop/interface/color-scheme "'prefer-dark'"
'';
custom = config.modules.darkman.customDarkModeScript;
pywalfox = "command -v pywalfox &>/dev/null && pywalfox dark && pywalfox update";
};
lightModeScripts = {
theme = ''
${pkgs.dconf}/bin/dconf write\
/org/gnome/desktop/interface/color-scheme "'prefer-light'"
'';
custom = config.modules.darkman.customLightModeScript;
pywalfox = "command -v pywalfox &>/dev/null && pywalfox light && pywalfox update";
};
settings.usegeoclue = true;
};
};
}

View File

@ -1,9 +1,9 @@
{ config, lib, pkgs, inputs, ... }:
{
options.services.apple-style.enable = lib.mkEnableOption "Enable Apple fonts and emojis";
options.modules.apple-style.enable = lib.mkEnableOption "Enable Apple fonts and emojis";
config = lib.mkIf config.services.apple-style.enable {
config = lib.mkIf config.modules.apple-style.enable {
fonts.fontDir.enable = true;
fonts.packages = [
inputs.apple-emoji.packages.${pkgs.system}.apple-emoji-nix

15
modules/nixos/audio.nix Normal file
View File

@ -0,0 +1,15 @@
{ config, lib, ... }:
{
options.modules.audio.enable = lib.mkEnableOption "Enable Pipewire audio";
config = lib.mkIf config.modules.audio.enable {
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}

View File

@ -1,9 +1,11 @@
{ config, lib, pkgs, ... }:
{
options.services.bluetooth.enable = lib.mkEnableOption "Enable Bluetooth";
options.modules.bluetooth.enable = lib.mkEnableOption "Enable Bluetooth";
config = lib.mkIf config.modules.bluetooth.enable {
environment.systemPackages = with pkgs; [ bluez ];
config = lib.mkIf config.services.bluetooth.enable {
# add compatibility layer
systemd.services.bluetooth.serviceConfig.ExecStart = lib.mkForce [
""

View File

@ -1,21 +1,23 @@
{ config, lib, pkgs, inputs, ... }:
{
options.services.fingerprint-fix.enable = lib.mkEnableOption "Enable support for fingerprint for P51S-like ThinkPads.";
options.services.fingerprint-fix.calibDataFile = lib.mkOption {
description = "Path to calibration data file.";
options.modules.fingerprint-fix = {
enable = lib.mkEnableOption "Enable support for fingerprint for P51S-like ThinkPads.";
calibDataFile = lib.mkOption {
description = "Path to calibration data file.";
};
};
imports = [
inputs.fingerprint-sensor.nixosModules."06cb-009a-fingerprint-sensor"
];
config = lib.mkIf config.services.fingerprint-fix.enable {
config = lib.mkIf config.modules.fingerprint-fix.enable {
# Needed because we're getting TLS error with open-fprintd-resume
systemd.services.validity-restart = let
targets = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" "suspend-then-hibernate.target" ];
in {
description = "Restart services to fix fingerprint integration";
description = "Restart.modules.to fix fingerprint integration";
wantedBy = targets;
after = targets;
serviceConfig.ExecStart = "systemctl restart open-fprintd python3-validity";
@ -24,7 +26,7 @@
services."06cb-009a-fingerprint-sensor" = {
enable = true;
backend = "python-validity";
calib-data-file = config.services.fingerprint-fix.calibDataFile;
calib-data-file = config.modules.fingerprint-fix.calibDataFile;
};
security.pam.services.su.fprintAuth = true;

20
modules/nixos/greetd.nix Normal file
View File

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
{
options.modules.greetd = {
enable = lib.mkEnableOption "Enable GreetD with TUI-based login.";
command = lib.mkOption {
type = lib.types.str;
description = "Command to run after successful login";
};
};
config = lib.mkIf config.modules.greetd.enable {
services.greetd = {
enable = true;
settings = {
default_session.command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd ${config.modules.greetd.Command}";
};
};
};
}

View File

@ -0,0 +1,13 @@
{ config, lib, ... }:
{
options.modules.nvidia.enable = lib.mkEnableOption "Enable NVIDIA kernel and modprobe configurations.";
config = lib.mkIf config.modules.nvidia.enable {
boot.kernelModules = [ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ];
boot.extraModprobeConfig = ''
options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
'';
};
}

View File

@ -1,13 +0,0 @@
{ config, lib, ... }:
{
options.services.nvidia.enable = lib.mkEnableOption "Enable NVIDIA kernel and modprobe configurations.";
config = lib.mkIf config.services.nvidia.enable {
boot.kernelModules = [ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ];
boot.extraModprobeConfig = ''
options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
'';
};
}

View File

@ -1,27 +1,24 @@
{ pkgs, ... }:
let
username = "sadorowo";
homeDirectory = "/home/${username}";
username = "sadorowo";
homeDirectory = "/home/${username}";
in {
imports = [
./packages.nix # Packages to install
./programs.nix # Programs to enable
./theme.nix # System-wide/GTK theme
./packages.nix
./programs.nix
./theme.nix
];
home = {
inherit username homeDirectory;
sessionVariables = {
NIXPKGS_ALLOW_UNFREE = "1";
NIXPKGS_ALLOW_INSECURE = "1";
NIXOS_OZONE_WL = "1";
TZ = "Europe/Warsaw";
LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH";
};
};
programs.home-manager.enable = true;
home.stateVersion = "24.11"; # DO NOT change this unless you know what you're doing!
home.stateVersion = "24.11";
}

View File

@ -2,11 +2,17 @@
{
imports = [
../../modules/home-manager/darkman.nix
inputs.ags.homeManagerModules.default
];
modules.darkman = {
enable = true;
customLightModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
customDarkModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
};
home.packages = with pkgs; [
hyprland hyprlock hypridle hyprshot wl-clipboard cliphist swww
pywal pywalfox-native
(python3.withPackages (py: with py; [
@ -21,8 +27,6 @@
}))
jq
bluez
dconf
starship
element-desktop
firefox-beta-bin
@ -36,7 +40,6 @@
fish
anydesk
fastfetch
greetd.greetd greetd.tuigreet
playerctl
adwaita-icon-theme
android-tools