feat!(flake): add NixOS config for homix

Copy and impove `home-manager` module integration from `nix-on-darwin` for `nixos`
Add `homix` *server* with NVIDIA drivers, `wayland` + `river`, Jellyfin, etc.
This commit is contained in:
reo101 2023-02-11 01:08:58 +02:00
parent 86809b8963
commit 406fe35116
7 changed files with 806 additions and 3 deletions

View file

@ -0,0 +1,219 @@
# 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).
{ inputs, outputs, config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
inputs.home-manager.nixosModules.home-manager
];
### Set boot options
boot = {
# Use the systemd-boot boot loader.
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
# Enable running aarch64 binaries using qemu
binfmt = {
emulatedSystems = [
"aarch64-linux"
"wasm32-wasi"
"x86_64-windows"
];
};
# Clean temporary directory on boot
cleanTmpDir = true;
# Enable support for nfs and ntfs
supportedFilesystems = [
"cifs"
"ntfs"
"nfs"
];
};
networking.hostName = "homix"; # 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/Sofia";
### 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";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkbOptions in tty.
# };
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes repl-flake
'';
settings = {
trusted-users = [
"root"
"reo101"
];
substituters = [
"https://rix101.cachix.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"rix101.cachix.org-1:2u9ZGi93zY3hJXQyoHkNBZpJK+GiXQyYf9J5TLzCpFY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
};
nixpkgs.config.allowUnfree = true;
### NVIDIA
services.xserver = {
videoDrivers = [ "nvidia" ];
};
hardware.opengl.enable = true;
hardware.nvidia = {
open = true;
# powerManagement.enable = true;
modesetting.enable = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
# package = config.boot.kernelPackages.nvidiaPackages.beta;
};
environment.sessionVariables = {
"_JAVA_AWT_WM_NONREPARENTING" = "1";
"LIBVA_DRIVER_NAME" = "nvidia";
"XDG_SESSION_TYPE" = "wayland";
"GBM_BACKEND" = "nvidia-drm";
"__GLX_VENDOR_LIBRARY_NAME" = "nvidia";
"WLR_NO_HARDWARE_CURSORS" = "1";
"MOZ_DISABLE_RDD_SANDBOX" = "1";
"EGL_PLATFORM" = "wayland";
};
### Wayland specific
services.xserver = {
enable = true;
displayManager = {
defaultSession = "river";
sessionPackages = with pkgs; [
river
];
gdm = {
enable = true;
wayland = true;
};
};
};
## X11 specific
services.xserver = {
layout = "us,bg";
xkbVariant = ",phonetic";
xkbOptions = "grp:lalt_lshift_toggle";
};
### Enable the OpenSSH daemon.
services.openssh.enable = true;
### Enable CUPS to print documents.
# services.printing.enable = true;
### Enable sound.
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse = {
enable = true;
};
jack = {
enable = true;
};
};
services.dbus.enable = true;
### Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
### Define a user account. Don't forget to set a password with `passwd`.
users.users.reo101 = {
isNormalUser = true;
shell = pkgs.zsh;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
};
home-manager = {
backupFileExtension = "hm-bak";
useUserPackages = true;
useGlobalPkgs = false;
extraSpecialArgs = { inherit inputs outputs; } ;
};
### Enable plymouth (bootscreen customizations)
boot.plymouth.enable = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
river
xdg-desktop-portal
neovim
wget
git
];
### Jellyfin
virtualisation.oci-containers.containers."jellyfin" = {
autoStart = true;
image = "docker.io/jellyfin/jellyfin:latest";
volumes = [
"/var/cache/jellyfin/config:/config"
"/var/cache/jellyfin/cache:/cache"
"/var/log/jellyfin:/log"
"/media:/media:ro"
];
ports = [ "8096:8096" ];
environment = {
JELLYFIN_LOG_DIR = "/log";
};
};
### Transmission
services.transmission = {
enable = 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. Its 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 = "22.11"; # Did you read the comment?
}

View file

@ -0,0 +1,37 @@
# 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" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/7f720420-41d8-4efd-bdf2-f445e52db998";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/5BF4-74EF";
fsType = "vfat";
};
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.eno1.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,106 @@
{ inputs, outputs, lib, config, pkgs, ... }:
{
imports = builtins.attrValues outputs.homeManagerModules;
home = {
username = "reo101";
homeDirectory = "/home/reo101";
stateVersion = "22.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
home.packages = with pkgs; [
# WM
river
# Terminals
wezterm
foot
# Core
neovim
git
firefox
discord
vifm
# Shell
zsh
starship
zoxide
# Dhall
dhall
dhall-lsp-server
# Nix
rnix-lsp
nil
direnv
# Torrents
tremc
# Zig
# zigpkgs."0.10.1"
zigpkgs.master
# inputs.zls-overlay.packages.x86_64-linux.default
];
nixpkgs = {
overlays = [
# inputs.neovim-nightly-overlay.overlay
inputs.zig-overlay.overlays.default
];
config.allowUnfree = true;
};
# Enable the GPG Agent daemon.
services.gpg-agent = {
enable = true;
defaultCacheTtl = 1800;
enableSshSupport = true;
};
programs.git = {
enable = true;
userName = "reo101";
userEmail = "pavel.atanasov2001@gmail.com";
# signing = {
# signByDefault = true;
# key = "0x52F3E1D376F692C0";
# };
};
reo101.shell = {
enable = true;
};
home.file = {
".config/nvim" = {
source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.local/src/reovim";
};
};
home.file.".config/river/init" = {
executable = true;
source = ./../river;
};
# home.file.".stack/config.yaml".text = lib.generators.toYAML {} {
# templates = {
# scm-init = "git";
# params = with config.programs.git; {
# author-name = userName;
# author-email = userEmail;
# github-username = userName;
# };
# };
# nix.enable = true;
# };
}

View file

@ -0,0 +1,158 @@
#!/usr/bin/env sh
# Super+Return to start an instance of foot (https://codeberg.org/dnkl/foot)
riverctl map normal Super Return spawn foot
# Super+Q to close the focused view
riverctl map normal Super Q close
# Super+Shift+Q to exit river
riverctl map normal Super+Shift Q exit
# export PATH="${HOME}/.local/bin:${PATH}"
riverctl map normal Super D PATH="${HOME}/.local/bin:${PATH}" dmenu_run
# Super+J and Super+K to focus the next/previous view in the layout stack
riverctl map normal Super J focus-view next
riverctl map normal Super K focus-view previous
# Super+Shift+J and Super+Shift+K to swap the focused view with the next/previous
# view in the layout stack
riverctl map normal Super+Shift J swap next
riverctl map normal Super+Shift K swap previous
# Super+Period and Super+Comma to focus the next/previous output
riverctl map normal Super Period focus-output next
riverctl map normal Super Comma focus-output previous
# Super+Shift+{Period,Comma} to send the focused view to the next/previous output
riverctl map normal Super+Shift Period send-to-output next
riverctl map normal Super+Shift Comma send-to-output previous
# Super+Space to bump the focused view to the top of the layout stack
riverctl map normal Super Space zoom
# Super+H and Super+L to decrease/increase the main ratio of rivertile(1)
riverctl map normal Super H send-layout-cmd rivertile "main-ratio -0.05"
riverctl map normal Super L send-layout-cmd rivertile "main-ratio +0.05"
# Super+Shift+H and Super+Shift+L to increment/decrement the main count of rivertile(1)
riverctl map normal Super+Shift H send-layout-cmd rivertile "main-count +1"
riverctl map normal Super+Shift L send-layout-cmd rivertile "main-count -1"
# Super+Alt+{H,J,K,L} to move views
riverctl map normal Super+Alt H move left 100
riverctl map normal Super+Alt J move down 100
riverctl map normal Super+Alt K move up 100
riverctl map normal Super+Alt L move right 100
# Super+Alt+Control+{H,J,K,L} to snap views to screen edges
riverctl map normal Super+Alt+Control H snap left
riverctl map normal Super+Alt+Control J snap down
riverctl map normal Super+Alt+Control K snap up
riverctl map normal Super+Alt+Control L snap right
# Super+Alt+Shif+{H,J,K,L} to resize views
riverctl map normal Super+Alt+Shift H resize horizontal "-100"
riverctl map normal Super+Alt+Shift J resize vertical "100"
riverctl map normal Super+Alt+Shift K resize vertical "-100"
riverctl map normal Super+Alt+Shift L resize horizontal "100"
# Super + Left Mouse Button to move views
riverctl map-pointer normal Super BTN_LEFT move-view
# Super + Right Mouse Button to resize views
riverctl map-pointer normal Super BTN_RIGHT resize-view
for i in $(seq 1 9); do
tags=$((1 << (i - 1)))
# Super+[1-9] to focus tag [0-8]
riverctl map normal Super "${i}" set-focused-tags $tags
# Super+Shift+[1-9] to tag focused view with tag [0-8]
riverctl map normal Super+Shift "${i}" set-view-tags $tags
# Super+Ctrl+[1-9] to toggle focus of tag [0-8]
riverctl map normal Super+Control "${i}" toggle-focused-tags $tags
# Super+Shift+Ctrl+[1-9] to toggle tag [0-8] of focused view
riverctl map normal Super+Shift+Control "${i}" toggle-view-tags $tags
done
# Super+0 to focus all tags
# Super+Shift+0 to tag focused view with all tags
all_tags=$(((1 << 32) - 1))
riverctl map normal Super 0 set-focused-tags "${all_tags}"
riverctl map normal Super+Shift 0 set-view-tags "${all_tags}"
# Super+Shift+Space to toggle float
riverctl map normal Super+Shift Space toggle-float
# Super+F to toggle fullscreen
riverctl map normal Super F toggle-fullscreen
# Super+{Up,Right,Down,Left} to change layout orientation
riverctl map normal Super Up send-layout-cmd rivertile "main-location top"
riverctl map normal Super Right send-layout-cmd rivertile "main-location right"
riverctl map normal Super Down send-layout-cmd rivertile "main-location bottom"
riverctl map normal Super Left send-layout-cmd rivertile "main-location left"
# Declare a passthrough mode. This mode has only a single mapping to return to
# normal mode. This makes it useful for testing a nested wayland compositor
riverctl declare-mode passthrough
# Super+F11 to enter passthrough mode
riverctl map normal Super F11 enter-mode passthrough
# Super+F11 to return to normal mode
riverctl map passthrough Super F11 enter-mode normal
# Various media key mapping examples for both normal and locked mode which do
# not have a modifier
for mode in normal locked
do
# Eject the optical drive (well if you still have one that is)
riverctl map "${mode}" None XF86Eject spawn "eject -T"
# Control pulse audio volume with pamixer (https://github.com/cdemoulins/pamixer)
riverctl map "${mode}" None XF86AudioRaiseVolume spawn "pamixer -i 5"
riverctl map "${mode}" None XF86AudioLowerVolume spawn "pamixer -d 5"
riverctl map "${mode}" None XF86AudioMute spawn "pamixer --toggle-mute"
# Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl)
riverctl map "${mode}" None XF86AudioMedia spawn "playerctl play-pause"
riverctl map "${mode}" None XF86AudioPlay spawn "playerctl play-pause"
riverctl map "${mode}" None XF86AudioPrev spawn "playerctl previous"
riverctl map "${mode}" None XF86AudioNext spawn "playerctl next"
# Control screen backlight brighness with light (https://github.com/haikarainen/light)
riverctl map "${mode}" None XF86MonBrightnessUp spawn "light -A 5"
riverctl map "${mode}" None XF86MonBrightnessDown spawn "light -U 5"
done
# Set background and border color
riverctl background-color 0x002b36
riverctl border-color-focused 0x93a1a1
riverctl border-color-unfocused 0x586e75
# Set keyboard repeat rate
riverctl set-repeat 50 300
# Make certain views start floating
riverctl float-filter-add app-id float
riverctl float-filter-add title "popup title with spaces"
# Set app-ids and titles of views which should use client side decorations
riverctl csd-filter-add app-id "tapy"
# Set and exec into the default layout generator, rivertile.
# River will send the process group of the init executable SIGTERM on exit.
riverctl default-layout rivertile
pipewire &
wireplumber &
waybar &
exec rivertile -view-padding 6 -outer-padding 6