structure and add like MatthiasBenaets

This commit is contained in:
2022-09-17 16:50:50 +02:00
parent 4065bc1e26
commit e454d95a99
30 changed files with 1791 additions and 229 deletions

147
hosts/configuration.nix Normal file
View File

@@ -0,0 +1,147 @@
#
# Main system configuration. More information available in configuration.nix(5) man page.
#
# flake.nix
# ├─ ./hosts
# │ └─ configuration.nix *
# └─ ./modules
# └─ ./editors
# └─ ./nvim
# └─ default.nix
#
{ config, lib, pkgs, inputs, user, location, ... }:
{
imports = # Import window or display manager.
[
#../modules/editors/nvim # ! Comment this out on first install !
];
users.users.${user} = { # System User
isNormalUser = true;
extraGroups = [ "wheel" "video" "audio" "camera" "networkmanager" "lp" "scanner" "kvm" "libvirtd" ];
shell = pkgs.zsh; # Default shell
};
#security.sudo.wheelNeedsPassword = true; # User does not need to give password when using sudo.
time.timeZone = "Europe/Berlin"; # Time zone and internationalisation
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = { # Extra locale settings that need to be overwritten
LC_TIME = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
};
};
console = {
font = "Lat2-Terminus16";
keyMap = "us"; # or us/azerty/etc
};
security.rtkit.enable = true;
sound = { # ALSA sound enable
enable = true;
mediaKeys = { # Keyboard Media Keys (for minimal desktop)
enable = true;
};
};
fonts.fonts = with pkgs; [ # Fonts
carlito # NixOS
vegur # NixOS
source-code-pro
jetbrains-mono
font-awesome # Icons
corefonts # MS
(nerdfonts.override { # Nerdfont Icons override
fonts = [
"FiraCode"
];
})
];
environment = {
variables = {
TERMINAL = "alacritty";
EDITOR = "nvim";
VISUAL = "nvim";
};
systemPackages = with pkgs; [ # Default packages install system-wide
vim
git
killall
pciutils
usbutils
wget
];
};
services = {
pipewire = { # Sound
enable = true;
#alsa = {
# enable = true;
# support32Bit = true;
#};
pulse.enable = true;
};
openssh = { # SSH: secure shell (remote connection to shell of server)
enable = true; # local: $ ssh <user>@<ip>
# public:
# - port forward 22 TCP to server
# - in case you want to use the domain name insted of the ip:
# - for me, via cloudflare, create an A record with name "ssh" to the correct ip without proxy
# - connect via ssh <user>@<ip or ssh.domain>
# generating a key:
# - $ ssh-keygen | ssh-copy-id <ip/domain> | ssh-add
# - if ssh-add does not work: $ eval `ssh-agent -s`
allowSFTP = true; # SFTP: secure file transfer protocol (send file to server)
# connect: $ sftp <user>@<ip/domain>
# commands:
# - lpwd & pwd = print (local) parent working directory
# - put/get <filename> = send or receive file
extraConfig = ''
HostKeyAlgorithms +ssh-rsa
''; # Temporary extra config so ssh will work in guacamole
};
#flatpak.enable = true; # download flatpak file from website - sudo flatpak install <path> - reboot if not showing up
# sudo flatpak uninstall --delete-data <app-id> (> flatpak list --app) - flatpak uninstall --unused
# List:
# com.obsproject.Studio
# com.parsecgaming.parsec
# com.usebottles.bottles
};
#xdg.portal = { # Required for flatpak
# enable = true;
# extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
#};
nix = { # Nix Package Manager settings
settings ={
auto-optimise-store = true; # Optimise syslinks
};
gc = { # Automatic garbage collection
automatic = true;
dates = "weekly";
options = "--delete-older-than 7d";
};
package = pkgs.nixFlakes; # Enable nixFlakes on system
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
autoUpgrade = { # Allow auto update
enable = true;
channel = "https://nixos.org/channels/nixos-unstable";
};
stateVersion = "22.05";
};
}

83
hosts/default.nix Normal file
View File

@@ -0,0 +1,83 @@
#
# These are the different profiles that can be used when building NixOS.
#
# flake.nix
# └─ ./hosts
# ├─ default.nix *
# ├─ configuration.nix
# ├─ home.nix
# └─ ./desktop OR ./laptop OR ./vm
# ├─ ./default.nix
# └─ ./home.nix
#
{ lib, inputs, nixpkgs, home-manager, nur, user, location, hyprland, ... }:
let
system = "x86_64-linux"; # System architecture
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # Allow proprietary software
};
lib = nixpkgs.lib;
in
{
desktop = lib.nixosSystem { # Desktop profile
inherit system;
specialArgs = { inherit inputs user location; }; # Pass flake variable
modules = [ # Modules that are used.
nur.nixosModules.nur
hyprland.nixosModules.default
./desktop
./configuration.nix
home-manager.nixosModules.home-manager { # Home-Manager module that is used.
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; }; # Pass flake variable
home-manager.users.${user} = {
imports = [(import ./home.nix)] ++ [(import ./desktop/home.nix)];
};
}
];
};
laptop = lib.nixosSystem { # Laptop profile
inherit system;
specialArgs = { inherit inputs user location hyprland; };
modules = [
hyprland.nixosModules.default
./laptop
./configuration.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = {
imports = [(import ./home.nix)] ++ [(import ./laptop/home.nix)];
};
}
];
};
vm = lib.nixosSystem { # VM profile
inherit system;
specialArgs = { inherit inputs user location; };
modules = [
./vm
./configuration.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user; };
home-manager.users.${user} = {
imports = [(import ./home.nix)] ++ [(import ./vm/home.nix)];
};
}
];
};
}

155
hosts/home.nix Normal file
View File

@@ -0,0 +1,155 @@
#
# General Home-manager configuration
#
# flake.nix
# ├─ ./hosts
# │ └─ home.nix *
# └─ ./modules
# ├─ ./editors
# │ └─ default.nix
# ├─ ./programs
# │ └─ default.nix
# ├─ ./services
# │ └─ default.nix
# └─ ./shell
# └─ default.nix
#
{ config, lib, pkgs, user, ... }:
{
imports = # Home Manager Modules
(import ../modules/editors) ++
(import ../modules/programs) ++
(import ../modules/services) ++
(import ../modules/shell);
home = {
username = "${user}";
homeDirectory = "/home/${user}";
packages = with pkgs; [
# Terminal
btop # Resource Manager
pfetch # Minimal fetch
ranger # File Manager
# Video/Audio
feh # Image Viewer
mpv # Media Player
pavucontrol # Audio control
stremio # Media Streamer
# Apps
firefox # Browser
google-chrome # Browser
remmina # XRDP & VNC Client
# File Management
okular # PDF viewer
gnome.file-roller # Archive Manager
pcmanfm # File Manager
rsync # Syncer $ rsync -r dir1/ dir2/
unzip # Zip files
unrar # Rar files
# General configuration
#git # Repositories
#killall # Stop Applications
#nano # Text Editor
#pciutils # Computer utility info
#pipewire # Sound
#usbutils # USB utility info
#wacomtablet # Wacom Tablet
#wget # Downloader
#zsh # Shell
#
# General home-manager
#alacritty # Terminal Emulator
#dunst # Notifications
#doom emacs # Text Editor
#flameshot # Screenshot
#libnotify # Dep for Dunst
neovim # Text Editor
#rofi # Menu
#udiskie # Auto Mounting
#vim # Text Editor
#
# Xorg configuration
#xclip # Console Clipboard
#xorg.xev # Input viewer
#xorg.xkill # Kill Applications
#xorg.xrandr # Screen settings
#xterm # Terminal
#
# Xorg home-manager
#picom # Compositer
#polybar # Bar
#sxhkd # Shortcuts
#
# Wayland configuration
autotiling # Tiling Script
swayidle # Idle Management Daemon
#wev # Input viewer
wl-clipboard # Console Clipboard
#
# Wayland home-manager
pamixer # Pulse Audio Mixer
swaylock-fancy # Screen Locker
waybar # Bar
#
# Desktop
blueman # Bluetooth
#deluge # Torrents
#discord # Chat
ffmpeg # Video Support (dslr)
#gmtp # Mount MTP (GoPro)
#gphoto2 # Digital Photography
#handbrake # Encoder
#heroic # Game Launcher
#hugo # Static Website Builder
#lutris # Game Launcher
#mkvtoolnix # Matroska Tool
#new-lg4ff # Logitech Drivers
#plex-media-player# Media Player
#polymc # MC Launcher
#steam # Games
#simple-scan # Scanning
#
# Laptop
blueman # Bluetooth
#light # Display Brightness
libreoffice # Office Tools
#simple-scan # Scanning
#
# Flatpak
#obs-studio # Recording/Live Streaming
];
file.".config/wall".source = ../modules/themes/wall.jpg;
pointerCursor = { # This will set cursor systemwide so applications can not choose their own
name = "Dracula-cursors";
package = pkgs.dracula-theme;
size = 16;
};
stateVersion = "22.05";
};
programs = {
home-manager.enable = true;
};
gtk = { # Theming
enable = true;
theme = {
name = "Dracula";
package = pkgs.dracula-theme;
};
iconTheme = {
name = "Papirus-Dark";
package = pkgs.papirus-icon-theme;
};
font = {
name = "JetBrains Mono Medium"; # or FiraCode Nerd Font Mono Medium
}; # Cursor is declared under home.pointerCursor
};
}

101
hosts/laptop/default.nix Normal file
View File

@@ -0,0 +1,101 @@
#
# Specific system configuration settings for desktop
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ ├─ default.nix *
# │ └─ hardware-configuration.nix
# └─ ./modules
# ├─ ./desktop
# │ └─ ./hyprland
# │ └─ hyprland.nix
# ├─ ./modules
# │ └─ ./programs
# │ └─ waybar.nix
# └─ ./hardware
# └─ default.nix
#
{ config, pkgs, user, ... }:
{
imports = # For now, if applying to other system, swap files
[(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix
[(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager
[(import ../../modules/desktop/virtualisation/docker.nix)] ++ # Docker
(import ../../modules/hardware); # Hardware devices
boot = { # Boot options
kernelPackages = pkgs.linuxPackages_latest;
loader = { # EFI Boot
systemd-boot.enable = true;
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
timeout = 1; # Grub auto select time
};
};
# hardware.sane = { # Used for scanning with Xsane
# enable = false;
# extraBackends = [ pkgs.sane-airscan ];
# };
# environment = {
# systemPackages = with pkgs; [
# simple-scan
# ];
# };
programs = { # No xbacklight, this is the alterantive
dconf.enable = true;
light.enable = true;
};
services = {
tlp.enable = true; # TLP and auto-cpufreq for power management
#logind.lidSwitch = "ignore"; # Laptop does not go to sleep when lid is closed
auto-cpufreq.enable = true;
blueman.enable = true;
printing = { # Printing and drivers for TS5300
enable = true;
drivers = [ pkgs.gutenprint ];
};
avahi = { # Needed to find wireless printer
enable = true;
nssmdns = true;
publish = { # Needed for detecting the scanner
enable = true;
addresses = true;
userServices = true;
};
};
#xserver = {
# libinput = { # Trackpad support & gestures
# touchpad = {
# tapping = true;
# scrollMethod = "twofinger";
# naturalScrolling = true; # The correct way of scrolling
# accelProfile = "adaptive"; # Speed settings
# #accelSpeed = "-0.5";
# disableWhileTyping = true;
# };
# };
# resolutions = [
# { x = 1600; y = 920; }
# { x = 1280; y = 720; }
# { x = 1920; y = 1080; }
# ];
#};
};
#temporary bluetooth fix
# systemd.tmpfiles.rules = [
# "d /var/lib/bluetooth 700 root root - -"
# ];
# systemd.targets."bluetooth".after = ["systemd-tmpfiles-setup.service"];
}

View File

@@ -0,0 +1,73 @@
#
# Hardware settings for Teclast F5 10" Laptop
# NixOS @ sda2
#
# flake.nix
# └─ ./hosts
# └─ ./laptop
# └─ hardware-configuration.nix *
#
# 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" "ehci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-label/ROOT";
fsType = "btrfs";
options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-label/ROOT";
fsType = "btrfs";
options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@home" ];
};
fileSystems."/boot" =
{ device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
};
swapDevices = [ ];
networking = {
useDHCP = false; # Deprecated
hostName = "nbf5";
networkmanager.enable = true;
interfaces = {
enp0s25 = {
useDHCP = true; # For versatility sake, manually edit IP on nm-applet.
#ipv4.addresses = [ {
# address = "192.168.0.51";
# prefixLength = 24;
#} ];
};
wlo1 = {
useDHCP = true;
#ipv4.addresses = [ {
# address = "192.168.0.51";
# prefixLength = 24;
#} ];
};
};
#defaultGateway = "192.168.0.1";
#nameservers = [ "192.168.0.4" ];
#firewall = {
# enable = false;
# #allowedUDPPorts = [ 53 67 ];
# #allowedTCPPorts = [ 53 80 443 9443 ];
#};
};
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; }

50
hosts/laptop/home.nix Normal file
View File

@@ -0,0 +1,50 @@
#
# Home-manager configuration for laptop
#
# flake.nix
# ├─ ./hosts
# │ └─ ./laptop
# │ └─ home.nix *
# └─ ./modules
# └─ ./desktop
# └─ ./hyprland
# └─ hyprland.nix
#
{ pkgs, ... }:
{
imports =
[
../../modules/desktop/hyprland/home.nix # Window Manager
];
home = { # Specific packages for laptop
packages = with pkgs; [
# Applications
#libreoffice # Office packages
# Display
light # xorg.xbacklight not supported. Other option is just use xrandr.
# Power Management
#auto-cpufreq # Power management
#tlp # Power management
];
};
programs = {
alacritty.settings.font.size = 11;
};
services = { # Applets
blueman-applet.enable = true; # Bluetooth
# network-manager-applet.enable = true; # Network
# cbatticon = {
# enable = true;
# criticalLevelPercent = 10;
# lowLevelPercent = 20;
# iconType = null;
# };
};
}