Welcome to my nixos configuration!. This is a configuration for a single laptop setup.
I use flake to manage my configs.
{
description = "A7R7's NixOS Flake";
nixConfig = {
<<nixConfig>>
};
inputs = {
<<inputs>>
};
outputs =
<<outputs>>
}
experimental-features = [ "nix-command" "flakes" ];
# nix community's cache server
extra-substituters = [
"https://nix-community.cachix.org"
"https://nixpkgs-wayland.cachix.org"
"https://anyrun.cachix.org"
"https://cuda-maintainers.cachix.org"
"https://hyprland.cachix.org"
"https://niri.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"niri.cachix.org-1:Wv0OmO7PsuocRKzfDoJ3mulSl7Z6oezYhGhR+3W2964="
];
## nixpkgs
nixpkgs-2305.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-2311.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs-2405.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
nur.url = "github:nix-community/NUR";
mynur = {
url = "github:A7R7/nur-packages";
inputs.nixpkgs.follows = "nixpkgs";
};
# mynur.url = "git+file:./?dir=./nurpkgs";
# mynur.url = "./nurpkgs";
# hyprland wm
hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
pyprland.url = "github:A7R7/pyprland";
niri.url = "github:sodiboo/niri-flake";
swayfx.url = "github:WillPower3309/swayfx";
ags.url = "github:Aylur/ags";
astal.url = "github:Aylur/Astal";
musnix.url = "github:musnix/musnix";
pip2nix.url = "github:nix-community/pip2nix";
emacs.url = "github:nix-community/emacs-overlay";
anyrun.url = "github:Kirottu/anyrun";
anyrun.inputs.nixpkgs.follows = "nixpkgs";
nbfc = {
url = "github:nbfc-linux/nbfc-linux";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs@{
self,
nixpkgs,
home-manager,
... }:
let
username = "aaron";
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
cudaVersion = "12";
};
overlays = with inputs; [
nur.overlay
mynur.overlay
emacs.overlay
niri.overlays.niri
swayfx.overlays.default
(final: prev: { v2311 = import inputs.nixpkgs-2311 {
inherit system;
config.allowUnfree = true;
};})
(final: prev: { v2405 = import inputs.nixpkgs-2405 {
inherit system;
config.allowUnfree = true;
};})
];
};
in
{
nixosConfigurations = {
Omen16 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs username system pkgs; };
modules = [
./host/configuration.nix
./host/omen16.nix
# home-manager.nixosModules.home-manager
# {
# home-manager.useGlobalPkgs = true;
# home-manager.useUserPackages = true;
# home-manager.users.aaron = import ./home/home.nix;
# home-manager.extraSpecialArgs = { inherit inputs username pkgs; };
# }
];
};
};
homeConfigurations = {
aaron = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = { inherit inputs username pkgs; };
modules = [ ./home/home.nix ];
};
};
};
{ config, pkgs, lib, inputs, username, system, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
inputs.musnix.nixosModules.musnix
inputs.niri.nixosModules.niri
];
<<host-config>>
}
system.stateVersion = "23.11";
nixpkgs.config.allowUnfree = true;
nix = {
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
settings = {
experimental-features = "nix-command flakes";
auto-optimise-store = true;
trusted-users = [ "${username}" ];
};
};
/etc/nixos/hardware-configuration.nix
boot = {
loader = {
# systemd-boot.enable = true;
grub = {
enable = true;
theme = pkgs.mynur.xenlism-grub-4k-nixos;
splashMode = "normal";
efiSupport = true;
useOSProber = true;
};
efi.canTouchEfiVariables = true;
efi.efiSysMountPoint = "/boot";
timeout = 10;
};
supportedFilesystems = [ "ntfs" ];
};
networking = {
networkmanager.enable = true;
};
musnix.enable = true;
# hardware.pulseaudio.enable = false;
hardware.bluetooth.enable = true;
security.rtkit.enable = true;
services. pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
time.timeZone = "Asia/Shanghai";
i18n = {
defaultLocale = "en_US.UTF-8";
supportedLocales = [
"en_US.UTF-8/UTF-8"
"zh_CN.UTF-8/UTF-8"
];
};
console = {
font = "Lat2-Terminus16";
useXkbConfig = true; # use xkbOptions in tty.
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "libvirtd" "adbusers" "audio"];
# shell = pkgs.elvish;
};
environment.systemPackages = with pkgs; [
vim neovim
wget
curl
git
stow
man
efibootmgr
gnumake
killall
home-manager
dash elvish fish nushell tcsh xonsh zsh
sddm-chili-theme
hicolor-icon-theme
# inputs.nbfc.packages.${system}.default
];
Shells. Yeah I’d like to try different shells.
environment.shells = with pkgs; [
dash elvish fish nushell tcsh xonsh zsh
];
This adds ~~/.local/bin~ to PATH.
environment.localBinInPath = true;
virtualisation = {
podman.enable = true;
libvirtd.enable = true;
waydroid.enable = true;
# virtualbox.host.enable = true;
# virtualbox.host.enableExtensionPack = true;
# virtualbox.guest.enable = true;
# virtualbox.guest.x11 = true;
# vmware.host.enable = true;
# vmware.guest.enable = true;
};
users.extraGroups.vboxusers.members = [ "user-with-access-to-virtualbox" ];
programs.bash = {
interactiveShellInit = ''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
''; # launches fish unless the parent process is already fish
};
services.xserver.desktopManager.gnome.enable = true;
services.gnome = {
evolution-data-server.enable = true;
glib-networking.enable = true;
gnome-keyring.enable = true;
gnome-online-accounts.enable = true;
at-spi2-core.enable = true; # avoid the warning "The name org.a11y.Bus was not provided by any .service files"
};
programs.hyprland = {
enable = true;
xwayland.enable = true;
package = inputs.hyprland.packages.${pkgs.system}.hyprland;
# enableNvidiaPatches = false; # deprecated
};
programs.wayfire = {
enable = true;
# package = pkgs.mynur.wayfire;
plugins = (with pkgs.wayfirePlugins; [
wcm
wf-shell
wayfire-plugins-extra
]);
# ++ [
# pkgs.mynur.swayfire
# ];
};
programs.niri = {
enable = true;
package = pkgs.niri-stable;
};
# programs.sway = {
# enable = true;
# package = pkgs.swayfx;
# wrapperFeatures.gtk = true;
# };
programs.steam = {
enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};
programs.adb.enable = true;
programs.dconf.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
# extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
};
# xdg.mimeApps.defaultApplications = {
# "mp4" = [ "umpv.desktop" "mpv.desktop" ];
# "png" = [ "feh.desktop"]
# }
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
sarasa-gothic
];
fonts.fontconfig = {
enable = true;
includeUserConf = true;
allowBitmaps = false;
hinting.enable = false;
};
services.xserver.enable = true;
services.xserver.excludePackages = [ pkgs.xterm ];
services.xserver.xkb.layout = "us,ara";
services.xserver.xkb.options = "grp:win_space_toggle";
services.xserver.displayManager.gdm.enable = true;
# services.displayManager.sddm = {
# enable = true;
# theme = "chili";
# };
# displayManager.lightdm.enable = true;
# displayManager.lightdm.greeters.slick.enable = true;
# services.dae = {
# enable = true;
# configFile = "/home/${username}/.config/dae/config.dae";
# };
services.sing-box = {
enable = true;
};
Syncthing is a continuouts file synchronization program using UPnP, which synchronize files WITHOUT centralized services.
services.syncthing = {
enable = true;
openDefaultPorts = true; # 22000/TCP and 22000/UDP
dataDir = "/home/${username}";
configDir = "/home/${username}/.config/syncthing";
user = "${username}";
group = "users";
# guiAdd.0:8384"; # To be able to access the web GUI
};
services.blueman.enable = true;
services.printing.enable = true;
services.printing.drivers = [ pkgs.hplipWithPlugin ];
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
services.ollama.enable = true;
services.flatpak.enable = true;
services.openssh.enable = true;
# userspace virtual filesystem
services.gvfs.enable = true;
# an automatic device mounting daemon
services.devmon.enable = true;
# allows applications to query and manipulate storage devices.
services.udisks2.enable = true;
# a DBus service for accessing the list of user accounts and information attached to those accounts.
# services.accounts-daemon.enable = true;
services.ratbagd.enable = true; # configuring gamming mouse
# a DBus service that provides power management support to applications.
services.upower.enable = true;
services.tlp = {
enable = false;
settings = {
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 20;
#Optional helps save long term battery health
START_CHARGE_THRESH_BAT0 = 40; # 40 and bellow it starts to charge
STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging
};
};
Polkit is used for controlling system-wide privileges. It provides an organized way for non-privileged processes to communicate with privileged ones, especially for those GUI applications.
security.polkit.enable = true;
# start polkit on login by creating a systemd user service
Becareful that packages installed by nix profile install
can conflict with packages defined here! Therefore, it is recommended to clear nix profile list before home-manager switch.
{ config, pkgs, inputs, ... }:
let
username = "aaron";
homeDirectory = "/home/aaron";
in
{
imports = [
./packages.nix
];
<<hm-config>>
}
home = {
username = username;
homeDirectory = homeDirectory;
stateVersion = "23.11";
sessionVariables = {
QT_XCB_GL_INTEGRATION = "none"; # kde-connect
NIXPKGS_ALLOW_UNFREE = "1";
# LD_LIBRARY_PATH="${pkgs.linuxPackages.nvidia_x11}/lib:$LD_LIBRARY_PATH";
# SHELL = "${pkgs.zsh}/bin/elvish";
};
sessionPath = [
"$HOME/.local/bin"
];
};
programs.home-manager.enable = true;
nixpkgs = {
config = {
allowUnfree = true;
# Workaround for https://github.com/nix-community/home-manager/issues/2942
allowUnfreePredicate = (_: true);
cudaSupport = true;
cudaVersion = "12";
};
};
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5 = {
addons = with pkgs; [
fcitx5-gtk
fcitx5-rime
fcitx5-lua
fcitx5-chinese-addons
librime
];
};
};
fonts.fontconfig.enable = true;
home.packages = with pkgs.v2405; [
(nerdfonts.override {
fonts = [
"CommitMono"
"DroidSansMono"
"FiraCode"
"Hack"
"IBMPlexMono"
"Monaspace"
"NerdFontsSymbolsOnly"
"RobotoMono"
];})
(google-fonts.override {
fonts = [
"Play"
];})
symbola
roboto roboto-serif
noto-fonts-monochrome-emoji
noto-fonts-emoji
noto-fonts-extra
source-han-mono
source-han-sans
source-han-serif
source-han-serif-vf-ttf
# commit-mono
# monaspace
# mynur.ibm-plex-nerd-font
ibm-plex
# corefonts
# vistafonts
# mynur.sarasa-gothic-nerd-font
fontforge-gtk
lxgw-wenkai
lxgw-neoxihei
wqy_zenhei
wqy_microhei
jigmo
lmmath
];
gtk.enable = true;
# gtk.theme = {
# name = "Fluent";
# package = pkgs.fluent-gtk-theme.override {
# tweaks = [ "blur" ];
# };
# };
gtk.iconTheme = {
name = "kora";
package = pkgs.kora-icon-theme;
};
# gtk.cursorTheme = {
# package = pkgs.whitesur-cursors;
# name = "whitesur-cursors";
# size = 32;
# };
home.pointerCursor = {
package = pkgs.whitesur-cursors;
name = "WhiteSur-cursors";
size = 32;
x11.enable = true;
gtk.enable = true;
};
xresources.properties = {
"Xcursor.size" = 32;
"Xft.dpi" = 172;
};
gtk.gtk3.bookmarks = [
"file://${homeDirectory}/Documents"
"file://${homeDirectory}/Music"
"file://${homeDirectory}/Pictures"
"file://${homeDirectory}/Videos"
"file://${homeDirectory}/Downloads"
"file://${homeDirectory}/Desktop"
"file://${homeDirectory}/Projects"
"file://${homeDirectory}/.config Config"
"file://${homeDirectory}/.local/share Local"
];
Bash is the default login shell. A login shell should be POSIX compliant, or it can cause errors.
programs.bash = {
enable = true; # this is needed for home.sessionVariables to work
};
programs.vscode = {
enable = true;
package = pkgs.vscode.fhs;
};
programs.obs-studio = {
enable = false;
plugins = with pkgs.obs-studio-plugins; [
wlrobs
# obs-backgroundremoval
obs-pipewire-audio-capture
];
};
programs.direnv = {
enable = true;
enableBashIntegration = true;
enableFishIntegration = true;
nix-direnv.enable = true;
};
programs.emacs = {
enable = true;
# package = pkgs.mynur.emacs;
package = pkgs.emacs-pgtk;
};
services.syncthing = {
enable = true;
tray = {enable = true;};
};
services.emacs.enable = true;
services.blueman-applet.enable = true;
{ inputs, pkgs, ... }:
{
home.packages = (with pkgs; [
<<hm-packages>>
]);
}
helix
lapce # a rust powered editor
libreoffice
# wpsoffice
neovide
marktext
# nur.repos.lschuermann.vivado-2020_1
These tools are for non-serious usage and quick testing. To seriously do development on nixos I have to write devshell.
gcc ccache cmake clang-tools bear
(python311.withPackages(ps: with ps; [
# pytorch-bin torchvision-bin
#(torchvision.override {torch = pytorch-bin; })
# required by lsp-bridge, holo-layer, and blink search
epc orjson sexpdata six paramiko rapidfuzz
pynput inflect pyqt6 pyqt6-sip
python-pam requests
numpy pandas toolz
scipy cython
# pyperclip
pillow
# imageio imageio-ffmpeg
# grad-cam
# opencv4
# onnxruntime
jupyter ipython matplotlib
# pip pipdeptree
# mynur.pix2tex
# mynur.pix2text
nvidia-ml-py
svgwrite
]))
poetry
# octave
nodejs
gjs
go
bun
sassc
typescript
meson
ninja
# eslint
maven
pkg-config
# rnix-lsp # WIP Language Server for Nix, unmaintained
nil
texliveFull
plantuml # draw plots
pyright
# javascript-typescript-langserver
rust-analyzer
mynur.jdtls
vscode-langservers-extracted
sqlite
# dbeaver
These are tools for packaging using nix.
niv
# nix-universal-prefetch
inputs.pip2nix.defaultPackage.${system}
nix-your-shell
any-nix-shell
nix-output-monitor
nix-du
nixfmt-classic
nixpkgs-fmt
manix # fast nix doc searcher
deploy-rs # Simple Rust rewrite of a simple Nix Flake deployment tool
doxygen
doxygen_gui
# mynur.logisim-ita
uncrustify
patchelf
gtk-engine-murrine
gnome-themes-extra
# mynur.tdlib # for building telegram clients
kitty
alacritty
wezterm
blackbox-terminal
cool-retro-term
gitstatus # 10x faster than git status
gitoxide # rust git client
gitui # magit like git client
cloc # compute lines
carapace # completion backend
starship # custom prompt
lf
thefuck #
bat # rust cat
eza # rust ls
ranger
nnn # cmdline file explorer
joshuto # rust ranger
yazi # faster rust ranger
file # tell file type
oterm # cmdline ollama client
fd
ripgrep
fzf
socat
jq
yq-go
acpi
inotify-tools
ffmpeg
libnotify
zoxide
autoconf
tree
ghostscript
_7zz
lazygit
hugo
pandoc
gh
zinit
just # cmdline executer, like make
# ueberzugpp # allow showing child window in terminal
pipes-rs
tty-clock
cava
cmatrix
fastfetch
uniscribe # describe unicodes
unipicker # pick unicodes
nerdfix # find nerd font icons
dwt1-shell-color-scripts # some colorful outputs
# daw
ardour
# synthesizer-plugin
zyn-fusion
surge
geonkick
# distrho
# sampler
x42-avldrums
drumkv1
drumgizmo
# effect processor
calf
lsp-plugins
# Qt-based Graph/Patchbay for PipeWire
qpwgraph
tauon
# lollypop
cider # Apple Music
spotify
v2311.gimp-with-plugins
inkscape
imagemagick # editing and manipulating digital images
# kdenlive
vlc
mpv
(kooha.overrideAttrs(old: rec {
pname = "kooha";
version = "2.3.0";
src = fetchFromGitHub {
owner = "SeaDve";
repo = "Kooha";
rev = "v${version}";
hash = "sha256-Z+PMSV6fipfHBrqGS24SOgGJS173Vct12sVzCGZL0IA=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";
hash = "sha256-m5y/VfjTJgK+/ZjsMo/9zPVxcV3kuwXb+HNdXR6hkV4=";
};
}))
zathura
# blender
firefox
floorp
chromium
qq
# discord
telegram-desktop
element-desktop
mastodon
thunderbird
weechat # IRC
# nur.repos.linyinfeng.wemeet
# nur.repos.xddxdd.dingtalk
# clash-verge-rev
hiddify-app
gui-for-singbox
# nur.repos.xddxdd.baidunetdisk
# tidal-dl
scdl # Download Music from Souncloud
# youtube-dl
prismlauncher
glfw-wayland-minecraft
zulu21
# steam-tui
# steamcmd
# steam
gamescope
Essentials
kanshi # manage monitor position on wayland
wlsunset # screen color temperature mnger
swayidle # idle mnger
# swaylock # lock mnger
wlogout # logout mnger
swaynotificationcenter # not only show notifications but also have a drawer
rofi-wayland-unwrapped # app launcher
inputs.anyrun.packages.${system}.anyrun-with-all-plugins # app launcher
eww # bar
waybar # bar
pavucontrol # sound control
brightnessctl # brightness control
playerctl # controlling media players that implement MPRIS
grim # wl raw screenshot
grimblast # wrapper around grim
slurp # reigon selection (outputs reigon coordinates)
swappy # Wayland native snapshot editing tool
wf-recorder # screen recording tool
hyprpaper # hyprland wallpaper utility
swww # dynamic wallpaper
swayimg # wallpaper utility from sway
mpvpaper # use mpv as wallpaper
wl-clipboard-rs # wayland clipboard
wev # wayland event viewer
imv # Image viewer
swayimg # Image viewer
feh # Image viewer
wayland-logout # kill a single instance of a wayland compositor
# gnome stuffs
nautilus # gnome's file manager
gnome-tweaks # gnome's file manager
gnome-characters
gnome-font-viewer # view system fonts
gnome-themes-extra
gtk-engine-murrine
nemo # cinnamon's file manager
doublecmd
# peazip # achiever
nsxiv # the best image viewer
adwaita-icon-theme
# hyprkeys # keybind retrieval utility
# hyprnome # gnome like workspace switch
# hyprshade # screen color filters
# wl-gammactl # set contrast, brightness and gamma on wl
v2311.hyprpicker # wlroots color picker
wayshot # screenshots tool
# bar and shell in gjs
inputs.ags.packages.${system}.default
inputs.astal.packages.${system}.default
# hyprland plugin set in python
inputs.pyprland.packages.${system}.default
gparted # disk partition manager
gnome-disk-utility # view disk info
fsearch # search files in disk
lshw
solaar # connect with logitech devices
iotop
btop
iftop # Display bandwidth usage on a network interface
logiops # Unofficial userspace driver for HID++ Logitech devices
powertop # Analyze power consumption on Intel-based laptops
mission-center
filelight # inspecting disk usage statistics
xorg.xhost # launch gui with sudo in cmdline
networkmanagerapplet # network manager, gtk frontend
wlr-randr # wlroots screen manager
pciutils # portable access to PCI bus configuration registers
piper # GTK frontend for ratbagd mouse config daemon
lm_sensors # reading hardware sensors
phoronix-test-suite # Automated Benchmarking
mangohud # monitoring FPS, temperatures, CPU/GPU load and more
sudo nixos-rebuild switch --flake . --impure
home-manager switch --flake .
nix flake update
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
sudo nix store gc --debug