Added hyprland, zsh, sddm, and xdg

This commit is contained in:
Joshua Yuen 2025-07-26 01:18:21 -04:00
parent a3eb62b416
commit b0eccdf769
Signed by: josh
GPG Key ID: 502720BC22ED411C
28 changed files with 479 additions and 47 deletions

View File

@ -3,30 +3,19 @@
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/26d499fc9f1d567283d5d56fcf367edd815dba1d.tar.gz";
in
{ {
imports = imports =
[ # Include the results of the hardware scan. [ # Include the results of the hardware scan.
# ./hardware-configuration.nix ./hardware-configuration.nix
./hyprland.nix ./hyprland.nix
./modules/main-user.nix
]; ];
# Use the systemd-boot EFI boot loader. # Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
# Virtual machine options # networking.hostName = "nixos"; # Define your hostname.
# virtualisation.vmVariant = {
# virtualisation = {
# memorySize = 8192;
# cores = 8;
# };
# };
networking.hostName = "nixos"; # Define your hostname.
# Pick only one of the below networking options. # Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
@ -76,21 +65,6 @@ in
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
# services.libinput.enable = true; # services.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.josh = {
isNormalUser = true;
initialPassword = "test";
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [
cowsay
lolcat
htop
firefox
pciutils
vim
];
};
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
# environment.systemPackages = with pkgs; [ # environment.systemPackages = with pkgs; [

View File

@ -1,5 +1,26 @@
{ {
"nodes": { "nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1753479839,
"narHash": "sha256-E/rPVh7vyPMJUFl2NAew+zibNGfVbANr8BP8nLRbLkQ=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "0b9bf983db4d064764084cd6748efb1ab8297d1e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-25.05",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1753345091, "lastModified": 1753345091,
@ -18,6 +39,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View File

@ -1,34 +1,39 @@
{ {
description = "NixOS configuration";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
home-manager.url = "github:nix-community/home-manager/release-25.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { self, nixpkgs, ... }: outputs = { nixpkgs, home-manager, ... } @ inputs: let
let
system = "x86_64-linux"; system = "x86_64-linux";
in host = "vm";
{ profile = "vm";
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { username = "josh";
in {
nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [ modules = [
{ nix.settings.experimental-features = ["nix-command" "flakes"]; }
./configuration.nix ./configuration.nix
]; ];
}; };
nixosConfigurations.nixosvm = nixpkgs.lib.nixosSystem { nixosvm = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = {
inherit inputs;
inherit host;
inherit profile;
inherit username;
};
modules = [ modules = [
{ ./hosts/${host}
nix.settings.experimental-features = ["nix-command" "flakes"];
virtualisation.vmVariant = {
virtualisation = {
memorySize = 8192;
cores = 8;
};
};
}
./configuration.nix
]; ];
}; };
}; };
};
} }

16
hosts/vm/default.nix Normal file
View File

@ -0,0 +1,16 @@
{
profile,
...
}:
{
imports = [
../../profiles/${profile}
../../modules/core
../../modules/options
./hardware.nix
./host-packages.nix
];
modules.hyprland.enable = true;
}

3
hosts/vm/hardware.nix Normal file
View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,9 @@
{
pkgs,
...
}:
{
environment.systemPackages = with pkgs; [
];
}

5
hosts/vm/variables.nix Normal file
View File

@ -0,0 +1,5 @@
{
# Set Display Manager
# 'gdm', 'sddm'
displayManager = "sddm";
}

20
modules/core/default.nix Normal file
View File

@ -0,0 +1,20 @@
{
host,
...
}: let
vars = import ../../hosts/${host}/variables.nix;
in {
imports = [
./hyprland.nix
./packages.nix
./system.nix
./user.nix
]
++ (
if vars.displayManager == "gdm"
then [ ./gdm.nix ]
else if vars.displayManager == "sddm"
then [ ./sddm.nix ]
else []
);
}

9
modules/core/gdm.nix Normal file
View File

@ -0,0 +1,9 @@
{
...
}:
{
services.xserver.displayManager.gdm = {
enable = true;
wayland.enable = true;
};
}

16
modules/core/hyprland.nix Normal file
View File

@ -0,0 +1,16 @@
{
config,
lib,
...
}:
with lib;
let
cfg = config.modules.hyprland;
in
{
config = mkIf cfg.enable {
programs.hyprland = {
enable = true;
};
};
}

View File

@ -0,0 +1,8 @@
{
config,
pkgs,
...
}:
{
}

12
modules/core/sddm.nix Normal file
View File

@ -0,0 +1,12 @@
{
...
}:
{
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
};
# To prevent getting stuck at shutdown
systemd.extraConfig = "DefaultTimeoutStopSec=10s";
}

14
modules/core/system.nix Normal file
View File

@ -0,0 +1,14 @@
{
...
}:
{
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
};
};
system.stateVersion = "25.05";
}

38
modules/core/user.nix Normal file
View File

@ -0,0 +1,38 @@
{
host,
inputs,
pkgs,
profile,
username,
...
}:
{
imports = [ inputs.home-manager.nixosModules.home-manager ];
home-manager = {
useUserPackages = true;
useGlobalPkgs = false;
backupFileExtension = "backup";
extraSpecialArgs = { inherit host inputs profile username; };
users.${username} = {
imports = [ ./../home ];
home = {
username = "${username}";
homeDirectory = "/home/${username}";
stateVersion = "25.05";
};
};
};
users.mutableUsers = true;
users.users.${username} = {
isNormalUser = true;
intialPassword = "changeme";
extraGroups = [
"wheel"
];
shell = pkgs.zsh;
ignoreShellProgramCheck = true;
};
nix.settings.allowed-users = [ "${username}" ];
}

View File

@ -0,0 +1,8 @@
{
...
}:
{
imports = [
./vm-guest-services.nix
];
}

View File

@ -0,0 +1,21 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.vm.guest-services;
in
{
options.vm.guest-services = {
enable = mkEnableOption "Enable Virtual Machine Guest Services";
};
config = mkIf cfg.enable {
services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true;
services.spice-webdavd.enable = true;
};
}

12
modules/home/default.nix Normal file
View File

@ -0,0 +1,12 @@
{
host,
...
}:
{
imports = [
./hyprland
./kitty.nix
./xdg.nix
./zsh
];
}

View File

@ -0,0 +1,16 @@
{
lib,
osConfig,
...
}:
with lib;
let
cfg = osConfig.modules.hyprland;
in
{
wayland.windowManager.hyprland.settings = {
bind = [
"$modifier,Return,exec,${cfg.terminal}"
];
};
}

View File

@ -0,0 +1,9 @@
{
...
}:
{
imports = [
./binds.nix
./hyprland.nix
];
}

View File

@ -0,0 +1,49 @@
{
config,
host,
lib,
osConfig,
pkgs,
...
}:
with lib;
let
cfg = osConfig.modules.hyprland;
in
{
config = mkIf cfg.enable {
home.packages = with pkgs; [
kitty
];
systemd.user.targets.hyprland-session.Unit.Wants = [
"xdg-desktop-autostart.target"
];
wayland.windowManager.hyprland = {
enable = true;
package = pkgs.hyprland;
systemd = {
enable = true;
enableXdgAutostart = true;
};
xwayland.enable = true;
settings = {
general = {
"$modifier" = "SUPER";
};
env = [
"NIXOS_OZONE_WL, 1"
"XDG_CURRENT_DESKTOP, Hyprland"
"XDG_SESSION_DESKTOP, Hyprland"
"XDG_SESSION_TYPE, wayland"
];
ecosystem = {
no_update_news = true;
};
};
};
};
}

18
modules/home/kitty.nix Normal file
View File

@ -0,0 +1,18 @@
{
lib,
osConfig,
pkgs,
...
}:
with lib;
let
cfg = osConfig.modules.hyprland;
in
{
config = mkIf (cfg.terminal == "kitty") {
programs.kitty = {
enable = true;
package = pkgs.kitty;
};
};
}

26
modules/home/xdg.nix Normal file
View File

@ -0,0 +1,26 @@
{
lib,
osConfig,
pkgs,
...
}:
with lib;
let
hyprlandCfg = osConfig.modules.hyprland;
in
{
xdg = {
enable = true;
mime.enable = true;
mimeApps.enable = true;
portal = {
enable = true;
extraPortals = mkIf hyprlandCfg.enable [
pkgs.xdg-desktop-portal-hyprland
];
configPackages = mkIf hyprlandCfg.enable [
pkgs.hyprland
];
};
};
}

View File

@ -0,0 +1,55 @@
{
config,
lib,
pkgs,
profile,
...
}:
{
imports = [
./zshrc-personal.nix
];
programs.zsh = {
enable = true;
autosuggestion.enable = true;
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"root"
];
};
historySubstringSearch.enable = true;
history = {
ignoreDups = false;
save = 100000;
size = 100000;
};
initContent = ''
# vi keybindings for menu select
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
# Tab to accept current selection
bind-key -M menuselect '^I' accept-and-infer-next-history
'';
shellAliases = {
".. " = "cd ..";
"..." = "cd../..";
ls = "ls --color=auto";
ll = "ls -al";
grep = "grep --color=auto";
back = "cd $OLDPWD";
gs = "git status";
ssha = "eval $(ssh-agent) && ssh-add";
};
};
}

View File

@ -0,0 +1,11 @@
{
pkgs,
...
}:
{
home.packages = with pkgs; [zsh];
home.file."./.zshrc-personal".text = ''
export EDITOR=vim
'';
}

View File

@ -0,0 +1,8 @@
{
...
}:
{
imports = [
./hyprland.nix
];
}

View File

@ -0,0 +1,24 @@
{
config,
lib,
...
}:
with lib;
let
cfg = config.modules.hyprland;
in
{
options.modules.hyprland = {
enable = mkEnableOption "Enable Hyprland";
terminal = mkOption {
type = types.enum [
"kitty"
"alacritty"
];
default = "kitty";
description = ''
The terminal to use for Hyprland.
'';
};
};
}

22
profiles/vm/default.nix Normal file
View File

@ -0,0 +1,22 @@
{
vm,
...
}:
{
imports = [
../../modules/drivers
];
virtualisation.vmVariant = {
virtualisation = {
memorySize = 8192;
cores = 8;
};
};
# drivers.amdgpu.enable = false;
# drivers.nvidia.enable = false;
# drivers.nvidia-prime.enable = false;
# drivers.intel.enable = false;
vm.guest-services.enable = true;
}

View File

@ -1,5 +1,7 @@
echo "Removing old qcow2 disk ..." echo "Removing old qcow2 disk ..."
rm -f ./nixos.qcow2 rm -f ./nixos.qcow2
echo "Building new VM ..." echo "Building new VM ..."
nix build .#nixosConfigurations.nixosvm.config.system.build.vm nix build .#nixosConfigurations.nixosvm.config.system.build.vm
echo "Done!" echo "Done!"