Install nh and friends, modularize nixos conf.

This commit is contained in:
CronyAkatsuki 2025-01-29 21:26:50 +01:00
parent ea86d38cd1
commit 5054b13564
14 changed files with 302 additions and 209 deletions

View File

@ -27,11 +27,12 @@
home-manager, home-manager,
... ...
} @ inputs: { } @ inputs: {
nixosConfigurations.default = nixpkgs.lib.nixosSystem { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
modules = [ modules = [
./hosts/default/configuration.nix ./hosts/nixos/configuration.nix
inputs.stylix.nixosModules.stylix inputs.stylix.nixosModules.stylix
./modules/nixos
]; ];
}; };
}; };

View File

@ -1,207 +0,0 @@
{
config,
inputs,
pkgs,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.home-manager
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Get nicer hostname
networking.hostName = "nixos"; # Define your hostname.
# Enable flakes
nix.settings.experimental-features = ["nix-command" "flakes"];
# Enable bluetooth
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
# Setup gpu
hardware.graphics = {
enable = true;
enable32Bit = true;
};
# Allow for nvidia
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia.open = false;
hardware.nvidia.modesetting.enable = true;
hardware.nvidia.powerManagement.enable = true;
hardware.nvidia.nvidiaSettings = true;
hardware.nvidia.prime = {
offload = {
enableOffloadCmd = true;
enable = true;
};
nvidiaBusId = "PCI:1:0:0";
amdgpuBusId = "PCI:5:0:0";
};
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Zagreb";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "hr_HR.UTF-8";
LC_IDENTIFICATION = "hr_HR.UTF-8";
LC_MEASUREMENT = "hr_HR.UTF-8";
LC_MONETARY = "hr_HR.UTF-8";
LC_NAME = "hr_HR.UTF-8";
LC_NUMERIC = "hr_HR.UTF-8";
LC_PAPER = "hr_HR.UTF-8";
LC_TELEPHONE = "hr_HR.UTF-8";
LC_TIME = "hr_HR.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
options = "caps:escape";
};
# Enable the KDE Plasma Desktop Environment.
services.displayManager.sddm.enable = true;
services.desktopManager.plasma6.enable = true;
environment.plasma6.excludePackages = with pkgs.kdePackages; [
plasma-browser-integration
konsole
oxygen
];
# Enable sound with pipewire.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Define a user account. Don't forget to set a password with passwd.
users.users.crony = {
isNormalUser = true;
description = "Crony";
extraGroups = ["networkmanager" "wheel" "video" "input" "audio" "libvirtd"];
};
# Setup home manager
home-manager = {
extraSpecialArgs = {inherit inputs;};
backupFileExtension = "backup";
users = {
crony = import ./home.nix;
};
};
# Disable hibernation, sleep and other friends
systemd.targets = {
sleep = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
suspend = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
hibernate = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
"hybrid-sleep" = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile
environment.systemPackages = with pkgs; [
neovim
mangohud
];
# Getting gaming setup
programs.steam.enable = true;
programs.steam.gamescopeSession.enable = true;
programs.gamemode.enable = true;
# Installing zsh
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
environment.pathsToLink = [ "/share/zsh" ];
# Enable sytling using stylix
stylix.enable = true;
stylix.autoEnable = true;
stylix.image = ./wallpaper.png;
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-medium.yaml";
# Change Cursor
stylix.cursor.package = pkgs.bibata-cursors;
stylix.cursor.name = "Bibata-Modern-Ice";
# Change u those fonts
stylix.fonts = {
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
monospace = {
package = pkgs.nerd-fonts.caskaydia-cove;
name = "CaskaydiaCove Nerd Font";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
# Enable nixd to see nixpkgs path
nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
# Change terminal font size
stylix.fonts.sizes.terminal = 15;
# Change chrome settings
stylix.targets.chromium.enable = true;
# Enable zram swap device
zramSwap.enable = true;
# Nfs share
fileSystems."/mnt/share" = {
device = "192.168.0.4:/mnt/nfs";
fsType = "nfs";
};
# DO NOT CHANGE
system.stateVersion = "24.11"; # Did you read the comment?
}

View File

@ -0,0 +1,108 @@
{
inputs,
pkgs,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.home-manager
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Get nicer hostname
networking.hostName = "nixos"; # Define your hostname.
# Enable flakes
nix.settings.experimental-features = ["nix-command" "flakes"];
# Setup gpu
hardware.graphics = {
enable = true;
enable32Bit = true;
};
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Zagreb";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "hr_HR.UTF-8";
LC_IDENTIFICATION = "hr_HR.UTF-8";
LC_MEASUREMENT = "hr_HR.UTF-8";
LC_MONETARY = "hr_HR.UTF-8";
LC_NAME = "hr_HR.UTF-8";
LC_NUMERIC = "hr_HR.UTF-8";
LC_PAPER = "hr_HR.UTF-8";
LC_TELEPHONE = "hr_HR.UTF-8";
LC_TIME = "hr_HR.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
options = "caps:escape";
};
# Enable sound with pipewire.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Define a user account. Don't forget to set a password with passwd.
users.users.crony = {
isNormalUser = true;
description = "Crony";
extraGroups = ["networkmanager" "wheel" "video" "input" "audio" "libvirtd"];
};
# Setup home manager
home-manager = {
extraSpecialArgs = {inherit inputs;};
backupFileExtension = "backup";
users = {
crony = import ./home.nix;
};
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile
environment.systemPackages = with pkgs; [
neovim
mangohud
];
# Enable nixd to see nixpkgs path
nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"];
# Enable zram swap device
zramSwap.enable = true;
# Nfs share
fileSystems."/mnt/share" = {
device = "192.168.0.4:/mnt/nfs";
fsType = "nfs";
};
# DO NOT CHANGE
system.stateVersion = "24.11";
}

View File

@ -19,6 +19,9 @@
keepassxc keepassxc
restic restic
age age
nh
nix-output-monitor
nvd
]; ];
# Enable programs to get their themes # Enable programs to get their themes
@ -240,6 +243,7 @@
# Default environmental variables # Default environmental variables
home.sessionVariables = { home.sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
FLAKE = "/home/crony/Repos/nixos";
}; };
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.

View File

@ -0,0 +1,15 @@
{
lib,
config,
...
}: {
# Enable bluetooth
options = {
crony.bluetooth.enable = lib.mkEnableOption "enable bluetooth";
};
config = lib.mkIf config.crony.bluetooth.enable {
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
};
}

11
modules/nixos/default.nix Normal file
View File

@ -0,0 +1,11 @@
{lib, ...}: {
imports = [./bluetooth.nix ./nvidia.nix ./plasma.nix ./disable-hibernation.nix ./gaming.nix ./zsh.nix ./stylix.nix];
crony.bluetooth.enable = lib.mkDefault true;
crony.nvidia.enable = lib.mkDefault true;
crony.plasma.enable = lib.mkDefault true;
crony.hibernation.disable = lib.mkDefault true;
crony.gaming.enable = lib.mkDefault true;
crony.zsh.enable = lib.mkDefault true;
crony.stylix.enable = lib.mkDefault true;
}

View File

@ -0,0 +1,30 @@
{
config,
lib,
...
}: {
options = {
crony.hibernation.disable = lib.mkEnableOption "disable hibernation and friends";
};
config = lib.mkIf config.crony.hibernation.disable {
# Disable hibernation, sleep and other friends
systemd.targets = {
sleep = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
suspend = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
hibernate = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
"hybrid-sleep" = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
};
};
}

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

@ -0,0 +1,15 @@
{
config,
lib,
...
}: {
# Getting gaming setup
options = {
crony.gaming.enable = lib.mkEnableOption "enable gaming related stuff, like steam and gamemode";
};
config = lib.mkIf config.crony.gaming.enable {
programs.steam.enable = true;
programs.steam.gamescopeSession.enable = true;
programs.gamemode.enable = true;
};
}

27
modules/nixos/nvidia.nix Normal file
View File

@ -0,0 +1,27 @@
{
lib,
config,
...
}: {
# Allow for nvidia
options = {
crony.nvidia.enable = lib.mkEnableOption "enable nvidia";
};
config = lib.mkIf config.crony.nvidia.enable {
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia.open = false;
hardware.nvidia.modesetting.enable = true;
hardware.nvidia.powerManagement.enable = true;
hardware.nvidia.nvidiaSettings = true;
hardware.nvidia.prime = {
offload = {
enableOffloadCmd = true;
enable = true;
};
nvidiaBusId = "PCI:1:0:0";
amdgpuBusId = "PCI:5:0:0";
};
};
}

21
modules/nixos/plasma.nix Normal file
View File

@ -0,0 +1,21 @@
{
pkgs,
config,
lib,
...
}: {
options = {
crony.plasma.enable = lib.mkEnableOption "enable plasma";
};
config = lib.mkIf config.crony.plasma.enable {
# Enable the KDE Plasma Desktop Environment.
services.displayManager.sddm.enable = true;
services.desktopManager.plasma6.enable = true;
environment.plasma6.excludePackages = with pkgs.kdePackages; [
plasma-browser-integration
konsole
oxygen
];
};
}

51
modules/nixos/stylix.nix Normal file
View File

@ -0,0 +1,51 @@
{
pkgs,
config,
lib,
...
}: {
options = {
crony.stylix.enable = lib.mkEnableOption "enable stylix and style my system";
};
config = lib.mkIf config.crony.stylix.enable {
# Enable sytling using stylix
stylix.enable = true;
stylix.autoEnable = true;
stylix.image = ./wallpaper.png;
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-medium.yaml";
# Change Cursor
stylix.cursor.package = pkgs.bibata-cursors;
stylix.cursor.name = "Bibata-Modern-Ice";
# Change u those fonts
stylix.fonts = {
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
monospace = {
package = pkgs.nerd-fonts.caskaydia-cove;
name = "CaskaydiaCove Nerd Font";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
# Change terminal font size
stylix.fonts.sizes.terminal = 15;
# Change chrome settings
stylix.targets.chromium.enable = true;
};
}

View File

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

17
modules/nixos/zsh.nix Normal file
View File

@ -0,0 +1,17 @@
{
config,
lib,
pkgs,
...
}: {
options = {
crony.zsh.enable = lib.mkEnableOption "install and enable zsh for all users";
};
config = lib.mkIf config.crony.zsh.enable {
# Installing zsh
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
environment.pathsToLink = ["/share/zsh"];
};
}