Fix: nvidia offload working

WIP: change to zsh
This commit is contained in:
Patrick Großmann 2023-02-15 16:09:53 +01:00
parent 41a10f8cd7
commit a027558058
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
8 changed files with 178 additions and 309 deletions

View file

@ -6,7 +6,9 @@
pkgs,
lib,
...
}: {
}: let
shell = pkgs.zsh;
in {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
@ -91,6 +93,8 @@
services.autorandr.enable = true;
services.physlock.enable = true;
hardware.opengl.enable = true;
nixpkgs.config.allowUnfree = true;
powerManagement.powertop.enable = true;
@ -101,23 +105,23 @@
rekey.secrets.patrick.file = ./secrets/patrick.passwd.age;
# Define a user account. Don't forget to set a password with passwd.
users.users.patrick = {
inherit shell;
isNormalUser = true;
uid = 1000;
createHome = true;
extraGroups = ["wheel" "audio" "video" "input"];
group = "patrick";
shell = pkgs.fish;
passwordFile = config.rekey.secrets.patrick.path;
};
users.groups.patrick.gid = 1000;
rekey.secrets.root.file = ./secrets/root.passwd.age;
users.users.root = {
inherit shell;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDZixkix0KfKuq7Q19whS5FQQg51/AJGB5BiNF/7h/LM"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHxD4GOrwrBTG4/qQhm5hoSB2CP7W9g1LPWP11oLGOjQ"
];
shell = pkgs.fish;
passwordFile = config.rekey.secrets.root.path;
};
@ -137,7 +141,16 @@
gnome3.adwaita-icon-theme
];
programs.steam.enable = true;
programs.steam = {
enable = true;
package = pkgs.steam.override {
extraPkgs = pkgs:
with pkgs; [
libgdiplus
cups
];
};
};
# List services that you want to enable:
@ -173,8 +186,9 @@
services.udev.packages = with pkgs; [yubikey-personalization libu2f-host];
environment.shellInit = ''
gpg-connect-agent /bye
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpg-connect-agent /bye
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
umask 077
'';
# Copy the NixOS configuration file and link it from the resulting system

View file

@ -1,13 +1,4 @@
# REQUIRES (execute as root):
# umask 022
source ${HOME}/.zsh/plugins//powerlevel10k/share/zsh-powerlevel10k/config/p10k-lean-8colors.zsh
# zsh histdb
typeset -g HISTDB_FILE="$HOME/.zsh_history.db"
# Use emacs-like key bindings by default:
bindkey -e
@ -47,25 +38,6 @@ function bind2maps() {
done
}
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-smkx() {
emulate -L zsh
printf '%s' ${terminfo[smkx]}
}
function zle-rmkx() {
emulate -L zsh
printf '%s' ${terminfo[rmkx]}
}
function zle-line-init() {
zle-smkx
}
function zle-line-finish() {
zle-rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
fi
typeset -A key
key=(
Home "${terminfo[khome]}"
@ -89,8 +61,6 @@ bind2maps emacs viins -- Insert overwrite-mode
bind2maps vicmd -- Insert vi-insert
bind2maps emacs -- Delete delete-char
bind2maps viins vicmd -- Delete vi-delete-char
bind2maps emacs viins vicmd -- Up up-line-or-search
bind2maps emacs viins vicmd -- Down down-line-or-search
bind2maps emacs -- Left backward-char
bind2maps viins vicmd -- Left vi-backward-char
bind2maps emacs -- Right forward-char
@ -121,120 +91,6 @@ bind2maps emacs viins vicmd -- -s '^[[B' history-beginning-search-forward-end
bind2maps emacs viins vicmd -- -s '\eOA' history-beginning-search-backward-end
bind2maps emacs viins vicmd -- -s '\eOB' history-beginning-search-forward-end
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false
typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# os_icon # os identifier
context # user@hostname
dir # current directory
vcs # git status
prompt_char # prompt symbol
)
# The list of segments shown on the right. Fill it with less important segments.
# Right prompt on the last prompt line (where you are typing your commands) gets
# automatically hidden when the input line reaches it. Right prompt above the
# last prompt line gets hidden if it would overlap with left prompt.
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
status # exit code of the last command
command_execution_time # duration of the last command
background_jobs # presence of background jobs
direnv # direnv status (https://direnv.net/)
asdf # asdf version manager (https://github.com/asdf-vm/asdf)
virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html)
anaconda # conda environment (https://conda.io/)
pyenv # python environment (https://github.com/pyenv/pyenv)
goenv # go environment (https://github.com/syndbg/goenv)
nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv)
nvm # node.js version from nvm (https://github.com/nvm-sh/nvm)
nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
# node_version # node.js version
# go_version # go version (https://golang.org)
# rust_version # rustc version (https://www.rust-lang.org)
# dotnet_version # .NET version (https://dotnet.microsoft.com)
# php_version # php version (https://www.php.net/)
# laravel_version # laravel php framework version (https://laravel.com/)
# java_version # java version (https://www.java.com/)
# package # name@version from package.json (https://docs.npmjs.com/files/package.json)
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm)
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
jenv # java version from jenv (https://github.com/jenv/jenv)
plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/)
azure # azure account name (https://docs.microsoft.com/en-us/cli/azure)
gcloud # google cloud cli account and project (https://cloud.google.com/)
google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production)
#context # user@hostname
nordvpn # nordvpn connection status, linux only (https://nordvpn.com/)
ranger # ranger shell (https://github.com/ranger/ranger)
nnn # nnn shell (https://github.com/jarun/nnn)
vim_shell # vim shell indicator (:sh)
midnight_commander # midnight commander shell (https://midnight-commander.org/)
nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html)
# vpn_ip # virtual private network indicator
# load # CPU load
# disk_usage # disk usage
# ram # free RAM
# swap # used swap
todo # todo items (https://github.com/todotxt/todo.txt-cli)
timewarrior # timewarrior tracking status (https://timewarrior.net/)
# taskwarrior # taskwarrior task count (https://taskwarrior.org/)
time # current time
# ip # ip address and bandwidth usage for a specified network interface
# public_ip # public IP address
# proxy # system-wide http/https/ftp proxy
# battery # internal battery
# wifi # wifi speed
# example # example user-defined segment (see prompt_example function below)
)
# No color prompt symbol
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=
# Default prompt symbol.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='$'
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION=':'
# Prompt symbol in visual vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
# Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶'
# Default context color without privileges
typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=6
# Context color when running with privileges.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1
# Context color in SSH without privileges.
typeset -g POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND=2
# Context color in SSH with privileges.
typeset -g POWERLEVEL9K_CONTEXT_REMOTE_SUDO_FOREGROUND=1
# Context format when running with privileges: user@(bold)hostname.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n%B@%m'
# Context format when in SSH without privileges: user@hostname.
typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='ssh://%n%B@%m'
# Default context format (no privileges, no SSH): user@hostname.
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n%B@%m'
# No directory icons
typeset -g POWERLEVEL9K_DIR_{,NOT_WRITABLE_}VISUAL_IDENTIFIER_EXPANSION=""
# Disable instant prompt
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
# Don't show context unless running with privileges or in SSH.
# Tip: Remove the next line to always show context.
unset POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION
# Completion
autoload -Uz compinit
compinit
@ -357,7 +213,7 @@ done; unset compcom
compdef _hosts upgrade
# History settings
HISTFILE=~/.zsh_history
unset HISTFILE=~/.zsh_history
HISTSIZE=1000000
SAVEHIST=1005000
@ -380,8 +236,8 @@ setopt hist_verify
# Emit an error when a glob has no match
setopt nomatch
# Allow extended globbing
setopt extendedglob
# DisAllow extended globbing
setopt noextendedglob
# * shouldn't match dotfiles. ever.
setopt noglobdots
# Whenever a command completion is attempted, make sure the entire

View file

@ -1,20 +1,24 @@
{pkgs, ...}: let
prime-run = pkgs.writeShellScriptBin "prime-run" ''
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 "$@"
'';
in {
services.xserver.videoDrivers = ["nvidia"];
{
lib,
pkgs,
...
}: {
services.xserver.videoDrivers = lib.mkForce ["nvidia"];
environment.systemPackages = [prime-run];
hardware.nvidia = {
powerManagement = {
enable = true;
finegrained = true;
};
modesetting.enable = true;
prime = {
offload = {
enableOffloadCmd = true;
enable = true;
};
hardware.nvidia.prime = {
offload.enable = true;
intelBusId = "PCI:00:02:0";
nvidiaBusId = "PCI:59:00:0";
intelBusId = "PCI:00:02:0";
nvidiaBusId = "PCI:59:00:0";
};
};
}

View file

@ -4,8 +4,8 @@
...
}: {
imports = [
#./zsh.nix
./shells/fish.nix
./shells/zsh.nix
#./shells/fish.nix
./programs/htop.nix
./shells/alias.nix
];

View file

@ -4,124 +4,30 @@
lib,
...
}: {
imports = [
./starfish.nix
];
programs.atuin = {
enable = true;
settings.auto_sync = false;
};
programs.starship = {
enable = true;
settings = {
add_newline = false;
format = lib.concatStrings [
"$username"
"$hostname"
" $directory"
"$git_branch"
"$git_commit"
"$git_state"
"$git_status"
"$character"
];
right_format = lib.concatStrings [
"$nix_shell"
"( $cmd_duration)"
"$status"
"$jobs"
" $time"
];
username = {
style_user = "yellow";
style_root = "bold red";
show_always = true;
format = "[$user]($style)";
};
hostname = {
style = "red";
format = "@[$hostname]($style)";
};
directory = {
format = "[$path]($style)[$read_only]($read_only_style) ";
fish_style_pwd_dir_length = 1;
truncate_to_repo = false;
};
git_branch = {
format = "[$symbol$branch(:$remote_branch)]($style)";
};
git_status = {
conflicted = "$count";
ahead = "$count";
behind = "$count";
diverged = "$ahead_count$behind_count";
untracked = "?$count";
stashed = "\\$$count";
modified = "!$count";
staged = "+$count";
renamed = "$count";
deleted = "-$count";
format = lib.concatStrings [
"[( $conflicted)](red)"
"[( $stashed)](magenta)"
"[( $staged)](green)"
"[( $deleted)](red)"
"[( $renamed)](blue)"
"[( $modified)](yellow)"
"[( $untracked)](blue)"
"[( $ahead_behind)](green)"
];
};
nix_shell = {
heuristic = true;
format = "[$symbol$state( \($name\))]($style)";
};
cmd_duration = {
format = "[ $duration]($style) ";
style = "yellow";
};
status = {
disabled = false;
pipestatus = true;
style = "red";
pipestatus_format = "$pipestatus -> [$int( $signal_name)]($style)";
pipestatus_separator = "[ | ]($style)";
pipestatus_segment_format = "[$status]($style)";
format = "[$status( $signal_name)]($style) ";
};
time = {
disabled = false;
format = "[ $time]($style)";
style = "yellow";
};
};
};
programs.fish = with lib; {
enable = true;
interactiveShellInit = lib.mkMerge [
(lib.mkBefore ''
set -g ATUIN_NOBIND true
set -g fish_greeting
set -g fish_autosuggestion_enabled 0
set -g FZF_COMPLETE 2
set -g FZF_COMPLETE_OPTS "--bind=ctrl-space:select --multi"
set -g ATUIN_NOBIND true
set -g fish_greeting
set -g fish_autosuggestion_enabled 0
'')
(lib.mkAfter ''
bind \cr _atuin_search
# prefix search for up and down arrow
bind \e\[A history-prefix-search-backward
bind \e\[B history-prefix-search-forward
#Include atuin auto completions
atuin gen-completions --shell fish | source
bind \cr _atuin_search
# prefix search for up and down arrow
bind \e\[A history-prefix-search-backward
bind \e\[B history-prefix-search-forward
#Include atuin auto completions
atuin gen-completions --shell fish | source
set -g fzf_complete_opts --cycle --reverse --height=20%
'')
];
plugins = [
@ -130,8 +36,8 @@
src = pkgs.fetchFromGitHub {
owner = "oddlama";
repo = "fzf.fish";
rev = "63c8f8e65761295da51029c5b6c9e601571837a1";
sha256 = "036n50zr9kyg6ad408zn7wq2vpfwhmnfwab465km4dk60ywmrlcb";
rev = "8c8b21ae52306cab5cece0095802ae15d0b8e3f4";
sha256 = "07yhiqv2ag4k7fxrmqg8x66adr3gy5j1w2cs07pm0f1552jsz5jr";
};
}
];

View file

@ -0,0 +1,97 @@
{lib, ...}: {
programs.starship = {
enable = true;
settings = {
add_newline = false;
format = lib.concatStrings [
"$username"
"$hostname"
" $directory"
"$git_branch"
"$git_commit"
"$git_state"
"($git_status )"
"$character"
];
right_format = lib.concatStrings [
"$nix_shell"
"( $cmd_duration)"
"$status"
"$jobs"
" $time"
];
username = {
style_user = "yellow";
style_root = "bold red";
show_always = true;
format = "[$user]($style)";
};
hostname = {
style = "red";
format = "@[$hostname]($style)";
};
directory = {
format = "[$path]($style)[$read_only]($read_only_style) ";
fish_style_pwd_dir_length = 1;
truncate_to_repo = false;
};
git_branch = {
format = "[$symbol$branch(:$remote_branch)]($style)";
};
git_status = {
conflicted = "$count";
ahead = "$count";
behind = "$count";
diverged = "$ahead_count$behind_count";
untracked = "?$count";
stashed = "\\$$count";
modified = "!$count";
staged = "+$count";
renamed = "$count";
deleted = "-$count";
format = lib.concatStrings [
"[( $conflicted)](red)"
"[( $stashed)](magenta)"
"[( $staged)](green)"
"[( $deleted)](red)"
"[( $renamed)](blue)"
"[( $modified)](yellow)"
"[( $untracked)](blue)"
"[( $ahead_behind)](green)"
];
};
nix_shell = {
heuristic = true;
format = "[$symbol$state( \($name\))]($style)";
};
cmd_duration = {
format = "[ $duration]($style) ";
style = "yellow";
};
status = {
disabled = false;
pipestatus = true;
style = "red";
pipestatus_format = "$pipestatus -> [$int( $signal_name)]($style)";
pipestatus_separator = "[ | ]($style)";
pipestatus_segment_format = "[$status]($style)";
format = "[$status( $signal_name)]($style) ";
};
time = {
disabled = false;
format = "[ $time]($style)";
style = "yellow";
};
};
};
}

View file

@ -3,43 +3,33 @@
pkgs,
...
}: {
imports = [
./starfish.nix
];
programs.atuin = {
enable = true;
settings.auto_sync = false;
};
programs.zsh = {
enable = true;
initExtra = builtins.readFile ../../data/zsh/zshrc;
#initExtra = builtins.readFile ../../../data/zsh/zshrc;
plugins = [
{
name = "powerlevel10k";
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
src = pkgs.zsh-powerlevel10k;
}
{
name = "fzf-tab";
file = "share/fzf-tab/fzf-tab.plugin.zsh";
src = pkgs.zsh-fzf-tab;
}
{
name = "fast-syntax-highlighting";
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting;
}
{
name = "zsh-histdb";
file = "sqlite-history.zsh";
src = pkgs.fetchFromGitHub {
owner = "larkery";
repo = "zsh-histdb";
rev = "30797f0";
sha256 = "PQIFF8kz+baqmZWiSr+wc4EleZ/KD8Y+lxW2NT35/bg=";
owner = "aloxaf";
repo = "fzf-tab";
rev = "69024c27738138d6767ea7246841fdfc6ce0d0eb";
sha256 = "07wwcplyb2mw10ia9y510iwfhaijnsdcb8yv2y3ladhnxjd6mpf8";
};
}
{
name = "sd";
file = "sd.plugin.zsh";
name = "fast-syntax-highlighting";
src = pkgs.fetchFromGitHub {
owner = "ianthehenry";
repo = "sd";
rev = "v1.1.0";
sha256 = "X5RWCJQUqDnG2umcCk5KS6HQinTJVapBHp6szEmbc4U=";
owner = "zdharma-continuum";
repo = "fast-syntax-highlighting";
rev = "7c390ee3bfa8069b8519582399e0a67444e6ea61";
sha256 = "0gh4is2yzwiky79bs8b5zhjq9khksrmwlaf13hk3mhvpgs8n1fn0";
};
}
];

View file

@ -3,8 +3,10 @@
# in an ideal world this would happen automatically but
# with udev and X11 we truly do not live in an ideal world
fix = pkgs.writeShellScriptBin "fix-shit" ''
xinput --map-to-output "ELAN2514:00 04F3:2817" eDP-1
xinput --map-to-output "ELAN2514:00 04F3:2817 Stylus Pen (0)" eDP-1
xinput --map-to-output "ELAN2514:00 04F3:2817" eDP-1
xinput --map-to-output "ELAN2514:00 04F3:2817 Stylus Pen (0)" eDP-1
xset r rate 235 60
autorandr -c
'';
in {
home.packages = [fix];