1
0
mirror of https://github.com/Andrey0189/nixos-config-reborn.git synced 2025-09-15 10:06:00 +03:00

here we go again

This commit is contained in:
andrey_varnavskiy
2024-11-23 12:01:38 +05:00
commit ae8789fac5
13 changed files with 729 additions and 0 deletions

48
flake.lock generated Normal file
View File

@@ -0,0 +1,48 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1732025103,
"narHash": "sha256-qjEI64RKvDxRyEarY0jTzrZMa8ebezh2DEZmJJrpVdo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a46e702093a5c46e192243edbd977d5749e7f294",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1732014248,
"narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "23e89b7da85c3640bbc2173fe04f4bd114342367",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@@ -0,0 +1,40 @@
{
description = "My system configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
#nixvim = {
# url = "github:nix-community/nixvim";
# inputs.nixpkgs.follows = "nixpkgs";
#};
};
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";
in {
# nixos - system hostname
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs system;
};
modules = [
./nixos/configuration.nix
];
};
homeConfigurations.amper = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [ ./home-manager/home.nix ];
};
};
}

19
home-manager/home.nix Normal file
View File

@@ -0,0 +1,19 @@
{
imports = [
./zsh.nix
./tmux.nix
# ./waybar.nix
];
home = {
username = "amper";
homeDirectory = "/home/amper";
stateVersion = "23.11";
};
programs.git = {
enable = true;
userName = "Andrey0189";
userEmail = "varnavsky06@gmail.com";
};
}

54
home-manager/tmux.nix Normal file
View File

@@ -0,0 +1,54 @@
{ pkgs, ... }: {
programs.tmux = {
enable = true;
baseIndex = 1;
mouse = true;
keyMode = "vi";
terminal = "screen-256color";
extraConfig = ''
set -as terminal-features ",alacritty*:RGB"
bind -n M-r source-file /nix/store/*tmuxtmux.conf \; display "Reloaded!"
bind C-p previous-window
bind C-n next-window
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
bind -n M-s split-window -v
bind -n M-v split-window -h
bind -n M-Enter new-window
bind -n M-c kill-window
bind -n M-q kill-session
'';
plugins = with pkgs; [
tmuxPlugins.cpu
{
plugin = tmuxPlugins.gruvbox;
}
{
plugin = tmuxPlugins.resurrect;
extraConfig = "set -g @resurrect-strategy-nvim 'session'";
}
{
plugin = tmuxPlugins.continuum;
extraConfig = ''
set -g @continuum-restore 'on'
set -g @continuum-save-interval '60' # minutes
'';
}
];
};
}

345
home-manager/waybar.nix Normal file
View File

@@ -0,0 +1,345 @@
{
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
margin = "9 13 10 18";
modules-left = ["hyprland/workspaces" "hyprland/language" "keyboard-state" "hyprland/submap"];
modules-center = ["clock" "custom/weather"];
modules-right = ["pulseaudio" "custom/mem" "cpu" "backlight" "battery" "tray"];
"hyprland/workspaces" = {
disable-scroll = true;
};
"hyprland/language" = {
format-en = "US";
format-ru = "RU";
min-length = 5;
tooltip = false;
};
"keyboard-state" = {
#numlock = true;
capslock = true;
format = "{icon} ";
format-icons = {
locked = " ";
unlocked = "";
};
};
"clock" = {
# timezone = "America/New_York";
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
format = "{:%a; %d %b, %I:%M %p}";
};
"custom/weather" = {
format = "{}";
tooltip = true;
interval = 1800;
exec = "$HOME/.config/waybar/scripts/wttr.py";
return-type = "json";
};
"pulseaudio" = {
# scroll-step = 1; # %, can be a float
reverse-scrolling = 1;
format = "{volume}% {icon} {format_source}";
format-bluetooth = "{volume}% {icon} {format_source}";
format-bluetooth-muted = " {icon} {format_source}";
format-muted = " {format_source}";
format-source = "{volume}% ";
format-source-muted = "";
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
portable = "";
car = "";
default = ["" "" ""];
};
on-click = "pavucontrol";
min-length = 13;
};
"custom/mem" = {
format = "{} ";
interval = 3;
exec = "free -h | awk '/Mem:/{printf $3}'";
tooltip = false;
};
"cpu" = {
interval = 2;
format = "{usage}% ";
min-length = 6;
};
"temperature" = {
# thermal-zone = 2;
# hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
critical-threshold = 80;
# format-critical = "{temperatureC}°C {icon}";
format = "{temperatureC}°C {icon}";
format-icons = ["" "" "" "" ""];
tooltip = false;
};
"backlight" = {
device = "intel_backlight";
format = "{percent}% {icon}";
format-icons = [""];
min-length = 7;
};
battery = {
states = {
warning = 30;
critical = 15;
};
format = "{capacity}% {icon}";
format-charging = "{capacity}% ";
format-plugged = "{capacity}% ";
format-alt = "{time} {icon}";
format-icons = ["" "" "" "" "" "" "" "" "" ""];
on-update = "$HOME/.config/waybar/scripts/check_battery.sh";
};
tray = {
icon-size = 16;
spacing = 0;
};
};
};
style =
''
* {
border: none;
border-radius: 0;
/* `otf-font-awesome` is required to be installed for icons */
font-family: JetBrains Mono;
font-weight: bold;
min-height: 20px;
}
window#waybar {
background: transparent;
}
window#waybar.hidden {
opacity: 0.2;
}
#workspaces {
margin-right: 8px;
border-radius: 10px;
transition: none;
background: #383c4a;
}
#workspaces button {
transition: none;
color: #7c818c;
background: transparent;
padding: 5px;
font-size: 18px;
}
#workspaces button.persistent {
color: #7c818c;
font-size: 12px;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
#workspaces button:hover {
transition: none;
box-shadow: inherit;
text-shadow: inherit;
border-radius: inherit;
color: #383c4a;
background: #7c818c;
}
#workspaces button.active {
background: #4e5263;
color: white;
border-radius: inherit;
}
#language {
padding-left: 16px;
padding-right: 8px;
border-radius: 10px 0px 0px 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#keyboard-state {
margin-right: 8px;
padding-right: 16px;
border-radius: 0px 10px 10px 0px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#custom-pacman {
padding-left: 16px;
padding-right: 8px;
border-radius: 10px 0px 0px 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#custom-mail {
margin-right: 8px;
padding-right: 16px;
border-radius: 0px 10px 10px 0px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#submap {
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#clock {
padding-left: 16px;
padding-right: 16px;
border-radius: 10px 0px 0px 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#custom-weather {
padding-right: 16px;
border-radius: 0px 10px 10px 0px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#pulseaudio {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#pulseaudio.muted {
background-color: #90b1b1;
color: #2a5c45;
}
#custom-mem {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#cpu {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#temperature {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#temperature.critical {
background-color: #eb4d4b;
}
#backlight {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#battery {
margin-right: 8px;
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
#battery.charging {
color: #ffffff;
background-color: #26A65B;
}
#battery.warning:not(.charging) {
background-color: #ffbe61;
color: black;
}
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#tray {
padding-left: 16px;
padding-right: 16px;
border-radius: 10px;
transition: none;
color: #ffffff;
background: #383c4a;
}
@keyframes blink {
to {
background-color: #ffffff;
color: #000000;
}
}
'';
};
}

36
home-manager/zsh.nix Normal file
View File

@@ -0,0 +1,36 @@
{ config, ... }: {
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases =
let
flakeDir = "~/flake";
in {
sw = "nh os switch";
upd = "nh os switch --update";
upg = "nh os switch";
hms = "nh home switch";
conf = "nvim ${flakeDir}/nixos/configuration.nix";
pkgs = "nvim ${flakeDir}/nixos/packages.nix";
ll = "ls -l";
v = "nvim";
se = "sudoedit";
microfetch = "microfetch && echo";
};
history.size = 10000;
history.path = "${config.xdg.dataHome}/zsh/history";
oh-my-zsh = {
enable = true;
plugins = [ "git" "sudo" ];
theme = "agnoster"; # blinks is also really nice
};
};
}

61
nixos/configuration.nix Normal file
View File

@@ -0,0 +1,61 @@
{ config, lib, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
./modules/zram.nix
./modules/bluetooth.nix
./modules/env.nix
./modules/boot.nix
./packages.nix
];
xdg.mime.defaultApplications = {
"inode/directory" = "lf";
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos";
networking.networkmanager.enable = true;
time.timeZone = "Asia/Tashkent";
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
services.pipewire = {
enable = true;
pulse.enable = true;
};
services.libinput.enable = true;
programs.zsh.enable = true;
users = {
defaultUserShell = pkgs.zsh;
users.amper = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
packages = with pkgs; [
];
};
};
services.getty.autologinUser = "amper";
programs.nh = {
enable = true;
# clean.enable = true;
# clean.extraArgs = "--keep-since 4d --keep 3";
flake = "/home/amper/flake";
};
system.stateVersion = "24.05"; # Did you read the comment?
}

View File

@@ -0,0 +1,39 @@
# 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 = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/69019f25-749c-4480-bbfc-72eef4c49313";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/12CE-A600";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices = [ ];
# 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.enp4s0f4u2.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp2s0.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,5 @@
{
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
services.blueman.enable = true;
}

4
nixos/modules/boot.nix Normal file
View File

@@ -0,0 +1,4 @@
{
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
}

12
nixos/modules/env.nix Normal file
View File

@@ -0,0 +1,12 @@
{
environment.sessionVariables = rec {
TERMINAL = "alacritty";
EDITOR = "nvim";
# Hint Electron apps to use Wayland
# NIXOS_OZONE_WL = "1";
XDG_BIN_HOME = "$HOME/.local/bin";
PATH = [
"${XDG_BIN_HOME}"
];
};
}

8
nixos/modules/zram.nix Normal file
View File

@@ -0,0 +1,8 @@
{
zramSwap = {
enable = true;
algorithm = "lz4";
memoryPercent = 100;
priority = 999;
};
}

58
nixos/packages.nix Normal file
View File

@@ -0,0 +1,58 @@
{ pkgs, ... }: {
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
vim
wget
alacritty
chromium
git
neovim
wofi
swww
imv
mpv
unzip
microfetch
gcc
home-manager
prismlauncher
telegram-desktop
waybar
bottom
xdg-desktop-portal-hyprland
wl-clipboard
cliphist
grimblast
obsidian
htop
lf
jetbrains.pycharm-professional
python311
blueman
teams-for-linux
silicon
tree
obs-studio
fuzzel
tmux
ffmpeg
yt-dlp
jre8
ripgrep
discord
zip
nodejs
];
fonts.packages = with pkgs; [
jetbrains-mono
noto-fonts
noto-fonts-emoji
twemoji-color-font
font-awesome
powerline-fonts
powerline-symbols
(nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
];
}