Skip to content

Instantly share code, notes, and snippets.

@ulysses4ever
Created April 6, 2021 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ulysses4ever/d667955933be956da75783fed8d8d0fe to your computer and use it in GitHub Desktop.
Save ulysses4ever/d667955933be956da75783fed8d8d0fe to your computer and use it in GitHub Desktop.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, lib, ... }:
let
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec -a "$0" "$@"
'';
in
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# [1]: https://github.com/fooblahblah/nixos/blob/master/configuration.nix
boot.cleanTmpDir = true;
boot.initrd.checkJournalingFS = false;
hardware.enableAllFirmware = true;
hardware.enableRedistributableFirmware = false;
powerManagement.enable = true;
system.autoUpgrade.enable = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
# Bluetooth
hardware.bluetooth.enable = true;
services.blueman.enable = true;
hardware.bluetooth.settings = {
General = {
Enable = "Source,Sink,Media,Socket";
};
};
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.supportedFilesystems = [ "ntfs" ];
networking.hostName = "lenovo-p14s"; # Define your hostname.
# Either NetworkManager or wireless service -- not both! (they conflict)
networking.networkmanager.enable = true;
#networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Set your time zone.
time.timeZone = "America/New_York";
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
networking.interfaces.enp0s31f6.useDHCP = true;
networking.interfaces.wlp0s20f3.useDHCP = true;
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
# Login and Desktop Management
environment.loginShellInit = ''
if [ "$(tty)" = "/dev/tty1" ] ; then
# Your environment variables
export QT_QPA_PLATFORM=wayland
export MOZ_ENABLE_WAYLAND=1
export MOZ_WEBRENDER=1
export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=sway
exec sway --my-next-gpu-wont-be-nvidia
fi
'';
services = {
xserver = {
enable = true;
desktopManager = {
xterm.enable = false;
};
displayManager = {
defaultSession = "sway"; # gnome"; # "none+i3"; # "xfce";
autoLogin = {
#enable = true;
#user = "artem";
};
lightdm = {
enable = true;
#autoLogin.timeout = 0;
#greeter.enable = false; # uncomment if autologin is on
};
gdm = {
enable = false;
autoLogin.delay = 0;
};
};
windowManager.i3 = {
enable = false;
extraPackages = with pkgs; [
dmenu #application launcher most people use
i3status # gives you the default i3 status bar
i3lock #default i3 screen locker
# i3blocks #if you are planning on using i3blocks over i3status
];
};
desktopManager.xfce.enable = true;
desktopManager.gnome3 = {
enable = true;
extraGSettingsOverrides = ''
[ org/gnome/desktop/peripherals/mouse ]
natural-scroll=true
[org.gnome.desktop.peripherals.touchpad]
tap-to-click=true
click-method='default'
[org/gnome/shell]
disable-user-extensions=false
'';
};
};
};
# Wayland with Nvidia drivers is complicated
#services.xserver.displayManager.gdm.wayland = false; # true didn't make any difference to me
# services.xserver.displayManager.gdm.nvidiaWayland = true;
#hardware.nvidia.modesetting.enable = true; # ?
#hardware.nvidia.nvidiaPersistenced = true; # ?
# NVIDIA Config
services.xserver.videoDrivers = [ "nvidia" ];
# --- or on certain laptops ---
#services.xserver.videoDrivers = [ "modesetting" "nvidia" ];
hardware.nvidia.prime = {
# sync.enable = true;
offload.enable = true; # -- fancier alternative: enable per app by running:
# $ nvidia-offload app
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
nvidiaBusId = "PCI:45:0:0";
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
intelBusId = "PCI:0:2:0";
};
# Configure keymap in X11
services.xserver.layout = "us,ru";
# Laptop power button to suspend
services.logind.extraConfig = "HandlePowerKey=suspend";
# Enable CUPS to print documents
services.printing.enable = true;
# Enable sound
sound.enable = true;
hardware.pulseaudio.enable = true;
hardware.pulseaudio.package = pkgs.pulseaudioFull;
# Hopefully helps to screen-share under Wayland
services.pipewire.enable = true;
xdg = {
portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
];
gtkUsePortal = true;
};
};
environment.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
};
# Needed by Steam (or so I heard)
hardware.opengl.driSupport32Bit = true;
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ];
hardware.pulseaudio.support32Bit = true;
# Enable touchpad support (enabled by default in most desktopManager).
services.xserver.libinput = {
enable = true;
touchpad = {
naturalScrolling = false;
tapping = true;
middleEmulation = true;
};
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.artem = {
isNormalUser = true;
createHome = true;
extraGroups = [ "wheel" "docker" "vboxusers" ]; # Enable ‘sudo’ for the user.
};
############
#
# Programs
#
# Lorri -- didn't work
# services.lorri.enable = true;
# Nano
programs.nano.nanorc = ''
set nowrap
set softwrap
set linenumbers
set tabsize 2
set tabstospaces
set autoindent
include "${pkgs.nano}/share/nano/extra/*"
'';
# Neovim
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
# Sway
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
extraPackages = with pkgs; [
swaylock swayidle xwayland
kitty
bemenu dmenu-wayland wofi # launchers: which one is bettter?
waybar
grim slurp
wlsunset
wl-clipboard
mako # notification daemon
wdisplays # monitor manager
xdg-desktop-portal-wlr # screen sharing engine
];
};
# Dconf
programs.dconf.enable = true;
# GNUPG for SSH keys management
# 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;
pinentryFlavor = "curses";
};
############
#
# Packages
#
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# Command-Line Tools
wget mc file patchelf
silver-searcher
lshw
lynx
openvpn openssl
parted
sudo
xorg.xbacklight
zip unzip
zlib
which
pciutils
nvidia-offload
direnv
htop
gnupg
inetutils
killall
aumix # cli sound control
imagemagick
# Extra
fd exa procs tldr
fish
starship
kitty
# Virtualization
# Gnome Desktop apps
gnome3.gedit
gnome3.gnome-terminal
gnome3.eog
gnome3.evince
#gnome3.shotwell
gnome3.gnome-tweak-tool
gnome3.dconf-editor
gnomeExtensions.appindicator
gnomeExtensions.dash-to-dock
transmission-gtk
# Text
#emacs # -- using Doom Emacs through Home Manager
emacs-all-the-icons-fonts
geany
texlive.combined.scheme-full
ott
libreoffice-fresh
aspellDicts.en enchant # helps with spell-checking in e.g. gEdit
# Media & More Desktop
firefox-wayland brave
zoom-us
tdesktop
ffmpeg vlc
steam
droidcam
dropbox dropbox-cli
# Develpoment
binutils gnumake gdb
docker
ghc cabal-install
haskellPackages.hpack ghcid
haskell-language-server
coq_8_12
gcc git
jdk ant maven
python
julia
# *** Experimental ***
# Command-Line
starship # nicer shell prompt
# Lighter Desktop apps
spaceFM # file manager
# styling for gtk apps
lxappearance
];
environment.gnome3.excludePackages = with pkgs.gnome3; [
];
############
#
# Fonts
#
fonts.fonts = with pkgs; [
nerdfonts
noto-fonts
noto-fonts-cjk
noto-fonts-emoji
liberation_ttf
fira-code
fira-code-symbols
mplus-outline-fonts
dina-font
paratype-pt-mono
paratype-pt-serif
paratype-pt-sans
inconsolata
ubuntu_font_family
iosevka
hasklig
jetbrains-mono
monoid
pkgs.emacs-all-the-icons-fonts
];
nixpkgs.config = {
allowUnfree = true;
oraclejdk.accept_license = true;
permittedInsecurePackages = [
"libplist-1.12"
];
# chromium.enablePepperFlash = false;
# firefox.enableAdobeFlash = true;
packageOverrides = pkgs: rec {
unstable = import <unstable> {
# pass the nixpkgs config to the unstable alias
# to ensure `allowUnfree = true;` is propagated:
config = config.nixpkgs.config;
};
};
};
security.sudo.wheelNeedsPassword = false;
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
virtualisation.docker.enable = true;
#virtualisation.virtualbox.host.enable = true;
#virtualisation.virtualbox.host.enableExtensionPack = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "20.09"; # Did you read the comment?
}
@akaihola
Copy link

In extraGSettingsOverrides, you have

      [ org/gnome/desktop/peripherals/mouse ]

and

      [org.gnome.desktop.peripherals.touchpad]

and

      [org/gnome/shell]

Which format is correct?

@ulysses4ever
Copy link
Author

That's a good question! I don't know if this works really: I use only Sway these days, and it has its own mouse config afair (and I don't experience gnome-shells's user extensions ofc). So you would need to experiment...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment