Initial desktop config

This commit is contained in:
GHOSCHT 2023-10-13 20:52:26 +02:00
commit 5f4674ffa8
14 changed files with 827 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Ignore build outputs from performing a nix-build or `nix build` command
result
result-*

195
flake.lock Normal file
View file

@ -0,0 +1,195 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1695108154,
"narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "07682fff75d41f18327a871088d20af2710d4744",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"repo": "home-manager",
"type": "github"
}
},
"hyprland": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"nixpkgs": [
"nixpkgs-unstable"
],
"systems": "systems",
"wlroots": "wlroots",
"xdph": "xdph"
},
"locked": {
"lastModified": 1697151905,
"narHash": "sha256-sfuiRn7D5D2NzDkXXN/DUUcs2d1ddlf3VmzDBzDO2Tk=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "3a61350286de842c7f1566c38e2b42821080ddf4",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "Hyprland",
"type": "github"
}
},
"hyprland-protocols": {
"inputs": {
"nixpkgs": [
"hyprland",
"nixpkgs"
],
"systems": [
"hyprland",
"systems"
]
},
"locked": {
"lastModified": 1691753796,
"narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-protocols",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1696983906,
"narHash": "sha256-L7GyeErguS7Pg4h8nK0wGlcUTbfUMDu+HMf1UcyP72k=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "bd1cde45c77891214131cbbea5b1203e485a9d51",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1697059129,
"narHash": "sha256-9NJcFF9CEYPvHJ5ckE8kvINvI84SZZ87PvqMbH6pro0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5e4c2ada4fcd54b99d56d7bd62f384511a7e2593",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1697208312,
"narHash": "sha256-pLhWx1QA0hLBgA7KoOeYWxQYqOUYSdoTAoDEEhMGx80=",
"owner": "nix-community",
"repo": "NUR",
"rev": "90683b5b6b475583fb307cd9d557e91881dccbcd",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NUR",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"hyprland": "hyprland",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"wlroots": {
"flake": false,
"locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1696410538,
"narHash": "sha256-ecDhdYLXWHsxMv+EWG36mCNDvzRbu9qfjH7dLxL7aGM=",
"owner": "wlroots",
"repo": "wlroots",
"rev": "3406c1b17a4a7e6d4e2a7d9c1176affa72bce1bc",
"type": "gitlab"
},
"original": {
"host": "gitlab.freedesktop.org",
"owner": "wlroots",
"repo": "wlroots",
"rev": "3406c1b17a4a7e6d4e2a7d9c1176affa72bce1bc",
"type": "gitlab"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": [
"hyprland",
"hyprland-protocols"
],
"nixpkgs": [
"hyprland",
"nixpkgs"
],
"systems": [
"hyprland",
"systems"
]
},
"locked": {
"lastModified": 1694628480,
"narHash": "sha256-Qg9hstRw0pvjGu5hStkr2UX1D73RYcQ9Ns/KnZMIm9w=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "8f45a6435069b9e24ebd3160eda736d7a391cbf2",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

70
flake.nix Normal file
View file

@ -0,0 +1,70 @@
#
# flake.nix *
# ├─ ./hosts
# │ └─ default.nix
# ├─ ./darwin
# │ └─ default.nix
# └─ ./nix
# └─ default.nix
#
{
description = "Nix, NixOS and Nix Darwin System Flake Configuration";
inputs =
# References Used by Flake
{
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; # Stable Nix Packages (Default)
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Unstable Nix Packages
home-manager = {
# User Environment Manager
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
# NUR Community Packages
url = "github:nix-community/NUR"; # Requires "nur.nixosModules.nur" to be added to the host modules
};
hyprland = {
# Official Hyprland Flake
url = "github:hyprwm/Hyprland"; # Requires "hyprland.nixosModules.default" to be added the host modules
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
};
outputs = inputs @ {
self,
nixpkgs,
nixpkgs-unstable,
home-manager,
nur,
hyprland,
...
}:
# Function telling flake which inputs to use
let
vars = {
# Variables Used In Flake
user = "ghoscht";
location = "$HOME/.setup";
terminal = "alacritty";
editor = "nvim";
};
in {
nixosConfigurations = ( # NixOS Configurations
import ./hosts {
inherit (nixpkgs) lib;
inherit inputs nixpkgs nixpkgs-unstable home-manager nur hyprland vars; # Inherit inputs
}
);
homeConfigurations = ( # Nix Configurations
import ./nix {
inherit (nixpkgs) lib;
inherit inputs nixpkgs nixpkgs-unstable home-manager vars;
}
);
};
}

198
hosts/configuration.nix Normal file
View file

@ -0,0 +1,198 @@
{
config,
lib,
pkgs,
unstable,
inputs,
vars,
...
}: {
imports = import ../modules/desktops;
users.users.${vars.user} = {
# System User
isNormalUser = true;
extraGroups = ["wheel" "video" "audio" "camera" "networkmanager" "lp" "scanner" "kvm" "libvirtd" "i2c"];
};
boot.supportedFilesystems = ["ntfs"];
# Set default shell -> move to module
users.defaultUserShell = pkgs.fish;
environment.shells = with pkgs; [fish];
programs.fish.enable = true;
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
time.timeZone = "Europe/Berlin";
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
};
console = {
# font = "Lat2-Terminus16";
keyMap = "de";
};
security = {
rtkit.enable = true;
polkit.enable = true;
};
fonts.fonts = with pkgs; [
# Fonts
carlito # NixOS
vegur # NixOS
source-code-pro
jetbrains-mono
font-awesome # Icons
corefonts # MS
carlito
dejavu_fonts
ipafont
kochi-substitute
source-code-pro
ttf_bitstream_vera
(nerdfonts.override {
# Nerdfont Icons override
fonts = [
"JetBrainsMono"
];
})
];
environment = {
variables = {
# Environment Variables
TERMINAL = "${vars.terminal}";
EDITOR = "${vars.editor}";
VISUAL = "${vars.editor}";
};
systemPackages = with pkgs;
[
# System-Wide Packages
# Terminal
btop # Resource Manager
coreutils # GNU Utilities
git # Version Control
killall # Process Killer
nano # Text Editor
neovim
nix-tree # Browse Nix Store
pciutils # Manage PCI
tldr # Helper
usbutils # Manage USB
wget # Retriever
bat
# Video/Audio
alsa-utils # Audio Control
feh # Image Viewer
mpv # Media Player
pavucontrol # Audio Control
pipewire # Audio Server/Control
pulseaudio # Audio Server/Control
# Apps
appimage-run # Runs AppImages on NixOS
electron-mail
fcitx5
fcitx5-mozc
webcord
signal-desktop
alacritty
librewolf
# File Management
unzip # Zip Files
unrar # Rar Files
zip # Zip
# Other Packages Found @
# - ./<host>/default.nix
# - ../modules
]
++ (with unstable; [
# Apps
feishin
]);
};
programs = {
dconf.enable = true;
};
services = {
printing = {
# CUPS
enable = true;
};
pipewire = {
# Sound
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
};
};
nix = {
# Nix Package Manager Settings
settings = {
auto-optimise-store = true;
};
# gc = { # Garbage Collection
# automatic = true;
# dates = "weekly";
# options = "--delete-older-than 2d";
# };
package = pkgs.nixVersions.unstable; # Enable Flakes
registry.nixpkgs.flake = inputs.nixpkgs;
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
'';
};
nixpkgs.config.allowUnfree = true; # Allow Proprietary Software.
system = {
# NixOS Settings
stateVersion = "23.05";
};
home-manager.users.${vars.user} = {
# Home-Manager Settings
home = {
stateVersion = "23.05";
};
programs = {
home-manager.enable = true;
};
};
}

52
hosts/default.nix Normal file
View file

@ -0,0 +1,52 @@
{
lib,
inputs,
nixpkgs,
nixpkgs-unstable,
home-manager,
nur,
hyprland,
vars,
...
}: let
system = "x86_64-linux"; # System Architecture
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # Allow Proprietary Software
};
unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in {
desktop = lib.nixosSystem {
# Desktop Profile
inherit system;
specialArgs = {
# Pass Flake Variable
inherit inputs system unstable hyprland vars;
host = {
hostName = "desktop";
mainMonitor = "DP-3";
secondMonitor = "DP-1";
};
};
modules = [
# Modules Used
nur.nixosModules.nur
./desktop
./configuration.nix
home-manager.nixosModules.home-manager
{
# Home-Manager Module
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
}

51
hosts/desktop/default.nix Normal file
View file

@ -0,0 +1,51 @@
# NOTE: Dual booted with windows 11. Disable fast-boot in power plan and bios and turn off hibernate to get wifi and bluetooth working. This only works once but on reboot is borked again. So using the old school BLT dongle.
#
{
lib,
pkgs,
vars,
unstable,
...
}: {
imports = [
./hardware-configuration.nix
../../modules/hardware/nvidia.nix
../../modules/services/avahi.nix
];
boot = {
# Boot Options
loader = {
systemd-boot = {
enable = true;
configurationLimit = 3;
};
efi = {
canTouchEfiVariables = true;
};
timeout = 5;
};
kernelPackages = pkgs.linuxPackages_latest;
};
hardware = {
sane = {
# Scanning
enable = true;
extraBackends = [unstable.utsushi];
};
};
services.udev.packages = [unstable.utsushi];
hyprland.enable = true; # Window Manager
environment = {
systemPackages = with pkgs; [
# System-Wide Packages
discord # Messaging
obs-studio # Live Streaming
simple-scan # Scanning
];
};
}

View file

@ -0,0 +1,43 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-amd"];
boot.extraModulePackages = [];
fileSystems."/" = {
device = "/dev/disk/by-uuid/f9ba57fb-0b82-47e0-8189-7bbebc530e2b";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/BCF2-51D4";
fsType = "vfat";
};
swapDevices = [
{device = "/dev/disk/by-uuid/4834fbc3-3feb-4b93-b11f-8b9bd054c5c1";}
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1 @@
[./hyprland.nix]

View file

@ -0,0 +1,89 @@
#
# Hyprland Configuration
# Enable with "hyprland.enable = true;"
#
{
config,
lib,
system,
pkgs,
unstable,
hyprland,
vars,
host,
...
}:
with lib;
with host; {
options = {
hyprland = {
enable = mkOption {
type = types.bool;
default = false;
};
};
};
config = mkIf (config.hyprland.enable) {
#wlwm.enable = true; # Wayland Window Manager
environment = {
# variables = {
# #WLR_NO_HARDWARE_CURSORS="1"; # Needed for VM
# #WLR_RENDERER_ALLOW_SOFTWARE="1";
# XDG_CURRENT_DESKTOP = "Hyprland";
# XDG_SESSION_TYPE = "wayland";
# XDG_SESSION_DESKTOP = "Hyprland";
# };
# sessionVariables =
# if hostName == "desktop"
# then {
# GBM_BACKEND = "nvidia-drm";
# #__GL_GSYNC_ALLOWED = "0";
# #__GL_VRR_ALLOWED = "0";
# #WLR_DRM_NO_ATOMIC = "1";
# __GLX_VENDOR_LIBRARY_NAME = "nvidia";
# #_JAVA_AWT_WM_NONREPARENTING = "1";
#
# QT_QPA_PLATFORM = "wayland";
# QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
#
# GDK_BACKEND = "wayland";
# WLR_NO_HARDWARE_CURSORS = "1";
# MOZ_ENABLE_WAYLAND = "1";
# NIXOS_OZONE_WL = "1";
# }
# else {
# QT_QPA_PLATFORM = "wayland";
# QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
#
# GDK_BACKEND = "wayland";
# WLR_NO_HARDWARE_CURSORS = "1";
# MOZ_ENABLE_WAYLAND = "1";
# };
systemPackages = with pkgs; [
grim # Grab Images
slurp # Region Selector
wl-clipboard # Clipboard
wlr-randr # Monitor Settings
];
};
programs = {
hyprland = {
# Window Manager
enable = true;
package = hyprland.packages.${pkgs.system}.hyprland;
nvidiaPatches =
if hostName == "desktop"
then true
else false;
};
};
nix.settings = {
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
}; # Cache
};
}

View file

@ -0,0 +1,18 @@
{
config,
pkgs,
...
}: {
services.xserver.videoDrivers = ["nvidia"];
hardware = {
opengl.enable = true;
nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = true;
nvidiaSettings = true;
};
};
}

View file

@ -0,0 +1,16 @@
#
# Network Discoverability (for printers, scanners and such)
#
{
services = {
avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
addresses = true;
userServices = true;
};
};
};
}

View file

@ -0,0 +1 @@
[./avahi.nix]

37
nix/default.nix Normal file
View file

@ -0,0 +1,37 @@
#
# These are the diffent profiles that can be used when using Nix on other distros.
# Home-Manager is used to list and customize packages.
#
# flake.nix
# └─ ./nix
# ├─ default.nix *
# └─ <host>.nix
#
{
lib,
inputs,
nixpkgs,
home-manager,
vars,
...
}: let
system = "x86_64-linux"; # System Architecture
pkgs = nixpkgs.legacyPackages.${system};
in {
pacman = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {inherit inputs vars;};
modules = [
# Modules Used
./pacman.nix
{
home = {
username = "${vars.user}";
homeDirectory = "/home/${vars.user}";
packages = [pkgs.home-manager];
stateVersion = "22.05";
};
}
];
};
}

53
nix/pacman.nix Normal file
View file

@ -0,0 +1,53 @@
#
# Nix Setup using Home-manager
#
# flake.nix
# └─ ./nix
# ├─ default.nix
# └─ pacman.nix *
#
{
config,
inputs,
pkgs,
nixgl,
vars,
...
}: {
home = {
packages = [
pkgs.hello
];
activation = {
# Rebuild Script
linkDesktopApplications = {
# Add Packages To System Menu
after = ["writeBoundary" "createXdgUserDirectories"];
before = [];
data = "sudo /usr/bin/update-desktop-database"; # Updates Database
};
};
};
xdg = {
# Add Nix Packages to XDG_DATA_DIRS
enable = true;
systemDirs.data = ["/home/${vars.user}/.nix-profile/share"];
};
nix = {
# Nix Package Manager Settings
settings = {
auto-optimise-store = true;
};
package = pkgs.nixFlakes; # Enable Flakes
registry.nixpkgs.flake = inputs.nixpkgs;
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
'';
};
nixpkgs.config.allowUnfree = true; # Allow Proprietary Software.
}