Files
nixos/configuration.nix

623 lines
16 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{
config,
lib,
pkgs,
...
}@inputs:
let
user = "fredrikr";
in
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
#./nbfc.nix
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxKernel.packages.linux_zen;
boot.extraModulePackages = with config.boot.kernelPackages; [
acer-wmi-battery
];
boot.kernelModules = [
"acer-wmi-battery"
];
# boot.kernel.sysctl = {
# "net.ipv6.conf.all.disable_ipv6" = 1;
# "net.ipv6.conf.default.disable_ipv6" = 1;
# };
# DUAL BOOT SETUP
#boot.kernelPackages = pkgs.linuxPackages_latest;
#boot.loader = {
# efi = {
# canTouchEfiVariables = true;
# efiSysMountPoint = "/boot";
# };
# grub = {
# enable = true;
# devices = ["nodev"];
# efiSupport = true;
# useOSProber = true;
# configurationLimit = 5;
# };
# timeout = 3;
#};
networking.hostName = "nixos"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
time.timeZone = "Europe/Oslo";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_MESSAGES = "en_US.UTF-8";
LC_TIME = "nb_NO.UTF-8";
LC_MONETARY = "nb_NO.UTF-8";
};
console = {
font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
};
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-rime
fcitx5-mozc
fcitx5-gtk
qt6Packages.fcitx5-configtool
libsForQt5.fcitx5-qt
];
};
# i18n.inputMethod.fcitx5.engines = with pkgs.fcitx-engines; [ mozc ];
# i18n.inputMethod = {
# enabled = "ibus";
# ibus.engines = with pkgs.ibus-engines; [ mozc ];
# };
# TTY settings
# luckily this also changes the keyboard layout at boot (for e.g full disk encryption passwords)
console.keyMap = "dvorak-programmer";
# GUI settings, this includes login screen
#services.xserver.layout = "us";
#services.xserver.xkbVariant = "dvp";
#services.xserver.xkbOptions = "eurosign:e";
# Configure keymap in X11
# services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape";
# Enable the X11 windowing system.
services.autorandr.enable = true;
services.xserver = {
enable = true;
autorun = true;
autoRepeatDelay = 200;
autoRepeatInterval = 24;
# DVORAK + NO
xkb.layout = "us,no";
xkb.variant = "dvp,";
xkb.options = "compose:menu, grp:alt_shift_toggle, lv3:ralt_switch";
exportConfiguration = true;
desktopManager.runXdgAutostartIfNone = true;
windowManager = {
xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = hpkgs: [
hpkgs.xmobar
# hpkgs.xmonad_0_17_0
# hpkgs.xmonad-contrib_0_17_0
# hpkgs.xmonad-extras_0_17_0
# hpkgs.xmonad-screenshot
];
};
};
displayManager = {
lightdm = {
enable = true;
greeters.mini = {
enable = true;
user = "fredrikr";
extraConfig = ''
[greeter]
cursor-theme-name = Vanilla-DMZ
cursor-theme-size = 32
show-input-cursor = false
show-password-label = false
password-label-text = password
invalid-password-text = wrong password
[greeter-hotkeys]
mod-key = meta
shutdown-key = p
restart-key = r
hibernate-key = h
suspend-key = s
[greeter-theme]
text-color = "#282A36"
error-color = "#282A36"
background-image = ""
background-color = "#282A36"
border-color = "#FF5555"
password-border-color = "#FF5555"
password-background-color = "#282A36"
password-color = "#F8F8F2"
window-color = "#50FA7B"
'';
};
};
# sessionCommands = '' '';
};
synaptics = {
minSpeed = "7.0";
maxSpeed = "8.0";
};
};
services.displayManager.defaultSession = "none+xmonad";
services.libinput = {
enable = true;
mouse = {
accelProfile = "flat";
};
touchpad = {
accelProfile = "flat";
naturalScrolling = true;
disableWhileTyping = true;
accelSpeed = "0.7";
};
};
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
sound = {
# enable = true; deprecated
# mediaKeys.enable = true; deprecated
};
# hardware.pulseaudio.enable = true; use pipewire
# OR
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
services.actkbd =
let
volumeStep = "1%";
in
{
enable = true;
bindings = [
# "Mute" media key
{
keys = [ 113 ];
events = [ "key" ];
command = "amixer -q set Master toggle";
}
# "Lower Volume" media key
{
keys = [ 114 ];
events = [
"key"
"rep"
];
command = "amixer -q set Master ${volumeStep}- unmute";
}
# "Raise Volume" media key
{
keys = [ 115 ];
events = [
"key"
"rep"
];
command = "amixer -q set Master ${volumeStep}+ unmute";
}
];
};
# Enable touchpad support (enabled default in most desktopManager).
# services.libinput.enable = true;
services.blueman.enable = true;
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
# hsphfpd.enable = true; handled by pipewire
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
};
};
};
# Define a user account. Don't forget to set a password with passwd.
users.users.${user} = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
initialPassword = "password";
packages = with pkgs; [
# managed by home-manager
# firefox
discord
#tree
];
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = (
with pkgs;
[
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
xorg.xkill
haskellPackages.xmobar
feh
trayer
xclip
# xorg.xbacklight
# htop
usbutils
udiskie
udisks
# javaPackages.openjfx17
libGL
gtk3
zathura
libgcc
gcc
gdb
valgrind-light
gnumake
# qemu_full
powertop
gamemode
alsa-utils
acpi
libnotify
# fcitx5
# fcitx5-configtool
# kdePackages.dolphin
nnn
nix-tree
xsecurelock
]
);
# programs.steam.enable = true;
# programs.gamemode.enable = true;
# nixpkgs.config.allowUnfree = true;
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
networking.firewall = {
enable = true;
allowedTCPPorts = [
# 3389
# 5900
]; # rdp port
# trustedInterfaces = [
# "wlp0s20f3"
# "lo"
# "enp1s0"
# ];
# extraCommands = ''
# iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT
# '';
};
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "24.05"; # Did you read the comment?
# system.autoUpgrade = {
# enable = true;
# # flake = inputs.self.outPath;
# flags = [
# "--print-build-logs"
# ];
# dates = "05:00";
# randomizedDelaySec = "45min";
# };
# OVERLAYS
nixpkgs.overlays = [
(self: super: {
discord = super.discord.overrideAttrs (_: {
src = builtins.fetchTarball {
url = "https://discord.com/api/download?platform=linux&format=tar.gz";
sha256 = "0k9sk5pmjw7xq68h2s80q8fg48p31albrqrqafmmrxik5f8f96rn";
};
});
})
];
nix = {
# package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
optimise.automatic = true;
settings.auto-optimise-store = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
services.picom = {
enable = true;
vSync = true;
settings = {
backend = "glx";
blur = {
method = "gaussian";
size = 10;
deviation = 5.0;
};
};
};
# systemd.services.background-image = {
# wantedBy = [ "multi-user.target" ];
# enable = true;
# serviceConfig = {
# User = "root";
# Group = "root";
# Type = "oneshot";
# # ExecStart = "~/.fehbg";
# };
# script = "/home/fredrikr/.fehbg &";
# };
# Power button invokes suspend, not shutdown.
services.logind.settings.Login = {
HandleLidSwitch = "suspend-then-hibernate";
HandlePowerKey = "ignore";
};
programs.xss-lock = {
enable = true;
lockerCommand = # "${pkgs.xsecurelock}/bin/xsecurelock";
let
xsecurelock-custom = pkgs.writeShellScriptBin "xsecurelock-custom" ''
export XSECURELOCK_SAVER=saver_blank
export XSECURELOCK_AUTH=auth_pam_x11
export XSECURELOCK_BLANK_DPMS_STATE=off
export XSECURELOCK_SHOW_DATETIME=1
export XSECURELOCK_DATETIME_FORMAT="%H:%M"
export XSECURELOCK_BACKGROUND_COLOR="#282A36"
export XSECURELOCK_AUTH_FOREGROUND_COLOR="#282A36"
export XSECURELOCK_AUTH_BACKGROUND_COLOR="#50FA7B"
export XSECURELOCK_AUTH_WARNING_COLOR="#FF5555"
${pkgs.xsecurelock}/bin/xsecurelock
'';
in
"${xsecurelock-custom}/bin/xsecurelock-custom";
extraOptions = [ "--transfer-sleep-lock" ];
};
# video acceleration
# nixpkgs.config.packageOverrides = pkgs: {
# intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
# };
# hardware.opengl = { # hardware.graphics on unstable
# enable = true;
# extraPackages = with pkgs; [
# intel-media-driver # LIBVA_DRIVER_NAME=iHD
# intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
# libvdpau-va-gl
# ];
# };
environment.sessionVariables = {
# LIBVA_DRIVER_NAME = "iHD"; # Force intel-media-driver
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
SDL_IM_MODULE = "fcitx";
GLFW_IM_MODULE = "ibus"; # Some applications use GLFW
INPUT_METHOD = "fcitx";
};
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-wlr
];
config.common.default = "*";
};
services.devmon.enable = true;
services.gvfs.enable = true;
services.udisks2.enable = true;
fonts = {
# enableDefaultFonts = true;
packages = with pkgs; [
# (nerdfonts.override { fonts = [ "FiraCode" "Monoid" ]; })
nerd-fonts.fira-code
nerd-fonts.droid-sans-mono
mplus-outline-fonts.osdnRelease
# noto-fonts
# ubuntu_font_family
# unifont
# noto-fonts-cjk-sans
# noto-fonts-cjk-serif
# carlito
# dejavu_fonts
# ipafont
# kochi-substitute
# source-code-pro
# ttf_bitstream_vera
];
# fontconfig = {
# antialias = true;
# # defaultFonts = {
# # serif = [ "Ubuntu" ];
# # sansSerif = [ "Ubuntu" ];
# # monospace = [ "Ubuntu Source" ];
# # };
# # defaultFonts = {
# # monospace = [ "Monoid" ];
# # };
# defaultFonts = {
# monospace = [
# "DejaVu Sans Mono"
# "IPAGothic"
# ];
# sansSerif = [
# "DejaVu Sans"
# "IPAPGothic"
# ];
# serif = [
# "DejaVu Serif"
# "IPAPMincho"
# ];
# };
# };
};
xdg.mime = {
enable = true;
defaultApplications = {
"application/pdf" = "org.pwmt.zathura.desktop";
"image/png" = "feh.desktop";
"image/jpeg" = "feh.desktop";
"text/html" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop";
"x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop";
};
};
programs.ssh = {
startAgent = true;
agentTimeout = "1h";
extraConfig = ''
AddKeysToAgent yes
'';
};
powerManagement.powertop.enable = true;
# services.auto-cpufreq.enable = true;
programs.bash.interactiveShellInit = ''
if ![XTERM = "dumb"]; then
exec nu
fi
'';
services.gnome.gnome-keyring.enable = true;
services.gnome.gcr-ssh-agent.enable = false;
security.pam.services.login.enableGnomeKeyring = true;
security.pam.services.lightdm.enableGnomeKeyring = true;
services.dbus.enable = true;
services.upower.enable = true;
systemd.user.services.battery-low = {
description = "batter low notif";
script = ''
battery_level=$(${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -P -o '[0-9]+(?=%)')
if [ "$battery_level" -le 20 ] && [ "$(${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -c 'Discharging')" -eq 1 ]; then
${pkgs.libnotify}/bin/notify-send -u critical "battery low" "battery level: $battery_level%"
fi
'';
serviceConfig = {
Type = "oneshot";
};
};
systemd.user.timers.battery-low = {
description = "check battery level";
timerConfig = {
OnBootSec = "2min";
OnUnitActiveSec = "2min";
};
wantedBy = [ "timers.target" ];
};
systemd.sleep.extraConfig = ''
HibernateDelaySec=60min
'';
}