Skip to content

Instantly share code, notes, and snippets.

@Strum355
Created September 23, 2021 23:52
Show Gist options
  • Save Strum355/8e0c63d662f297ce23654e763bd4c6af to your computer and use it in GitHub Desktop.
Save Strum355/8e0c63d662f297ce23654e763bd4c6af to your computer and use it in GitHub Desktop.
wayland nix discord
{ 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 = [
<nixos-hardware/dell/xps/15-9500>
<nixos-hardware/dell/xps/15-9500/nvidia>
./hardware-configuration.nix
];
nixpkgs.overlays = [
(import ./vscode-overlay.nix)
(import ./go-overlay.nix)
(import ./electron-wayland.nix)
(import ./discord-overlay.nix)
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "noah-nixos";
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Dublin";
# networking.interfaces.enp0s20f0u1u4.useDHCP = true;
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# };
services.xserver.enable = true;
services.xserver.displayManager.gdm = {
enable = true;
debug = true;
nvidiaWayland = true;
wayland = true;
};
services.xserver.desktopManager.gnome = {
enable = true;
extraGSettingsOverrides = ''
[org.gnome.mutter]
experimental-features=['scale-monitor-framebuffer']
'';
};
services.xserver.videoDrivers = [ "modesetting" "nvidia" ];
hardware.nvidia = {
# nvidiaSettings = false; # not supported on wayland anyways, not even xwayland
powerManagement.enable = true;
powerManagement.finegrained = true;
modesetting.enable = true;
prime = {
offload.enable = true;
nvidiaBusId = "PCI:1:0:0";
intelBusId = "PCI:0:2:0";
};
};
# Configure keymap in X11
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
services.xserver.libinput.enable = true;
services.xserver.libinput.touchpad.tapping = true;
services.fprintd = {
enable = true;
package = pkgs.fprintd-tod;
tod = {
enable = true;
driver = pkgs.libfprint-2-tod1-goodix;
};
};
services.power-profiles-daemon.enable = lib.mkForce false;
services.tlp.enable = true;
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
nixpkgs.config.allowUnfree = true;
users.users.noah = {
isNormalUser = true;
extraGroups = [ "wheel" "video" "networkmanager" "docker" ];
shell = pkgs.fish;
};
environment.systemPackages = with pkgs; [
vim
wget
google-chrome-beta
firefox
discord
ansible
kitty
pass
stow
vscode
go
kotlin
coursier
pciutils
htop
jetbrains.idea-ultimate
jetbrains.idea-community
rnix-lsp
git
dmidecode
slack
nix-index
fish
makeWrapper
nix-prefetch-git
nvidia-offload
gnome.gnome-tweaks
tdesktop
thunderbird
lz4
tlp
cinnamon.nemo
cinnamon.mint-themes
cinnamon.mint-y-icons
(pkgs.callPackage ./adapta-nokto.nix {})
];
environment.sessionVariables = {
"NIX_AUTO_RUN" = "1";
"MOZ_ENABLE_WAYLAND" = "1";
"QT_QPA_PLATFORM" = "wayland";
"MOZ_ENABLE_XINPUT2" = "1";
"MOZ_DISABLE_RDD_SANDBOX" = "1";
};
environment.shells = [ pkgs.fish ];
# 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;
# };
services.openssh.enable = true;
system.stateVersion = "21.05";
}
self: super: {
discord = super.discord.overrideAttrs (
_: {
src = builtins.fetchTarball "https://dl.discordapp.net/apps/linux/0.0.16/discord-0.0.16.tar.gz";
}
);
}
self:
let
enableWayland = drv: bin: drv.overrideAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ self.makeWrapper ];
postFixup = (old.postFixup or "") + ''
wrapProgram $out/bin/${bin} \
--add-flags "--enable-features=UseOzonePlatform" \
--add-flags "--ozone-platform=wayland"
'';
}
);
in
super:
{
slack = enableWayland super.slack "slack";
discord = enableWayland super.discord "discord";
vscode = enableWayland super.vscode "code";
google-chrome-beta = (
super.google-chrome-beta.override {
commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment