Compare commits

...

2 Commits

Author SHA1 Message Date
marc
c3dd5dda65 Modified polybar 2022-11-06 15:35:47 +01:00
marc
0f4b895d38 Added nvidia drivers and gaming profile 2022-11-04 19:32:53 +01:00
27 changed files with 442 additions and 210 deletions

View File

@@ -85,3 +85,9 @@ nixos-generate-config --dir <<host directory>> --no-filesystems
#+BEGIN_SRC bash
sudo nixos-install --impure --root /mnt --flake .#reykjavik
#+END_SRC
1. Set up the user
You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user:
#+BEGIN_SRC bash
passwd marc
#+END_SRC

View File

@@ -1,4 +1,7 @@
window:
opacity: 0.85
font:
size: 8
normal:
family: Iosevka Nerd Font
style: Regular

View File

@@ -0,0 +1,51 @@
include-file = colours.ini
include-directory = modules
[bar/base]
dpi = 96
width = 100%
height = 32
offset-x = 0
offset-y = 0
font-0 = "Iosevka:size=10;2"
font-1 = "Iosevka:size=16;2"
font-2 = "Iosevka:size=22;4"
background = ${colours.trans}
foreground = ${colours.white}
border-bottom-size = 5
border-top-size = 5
border-left-size = 10
border-right-size = 10
border-bottom-colour = ${colours.trans}
border-top-colour = ${colours.trans}
border-left-colour = ${colours.trans}
border-right-colour = ${colours.trans}
spacing = 0
padding-left = 0
padding-right = 0
module-margin-left = 0
[bar/bottom]
inherit = bar/base
bottom = true
modules-left = workspaces
modules-right = volume paddinglite battery
tray-position = center
tray-maxsize = 28
[bar/top]
inherit = bar/base
bottom = false
modules-left =
modules-center = date
modules-right = i3-mode

View File

@@ -0,0 +1,61 @@
[colours]
trans = #0000
white = #fff
black = #000
gray = #555
blue- = #498AD4
blue = #2B6CB6
blue+ = #173B63
xanadu- = #B3BCB6
xanadu = #808F85
xanadu+ = #606C64
green- = #CAE2CE
green = #91C499
green+ = #61A86D
linen- = #F9F5F0
linen = #F2E9DC
linen+ = #DEC6A6
pear- = #E8EB5C
pear = #CFD11A
pear+ = #8F9112
orange- = #FEB548
orange = #F18F01
orange+ = #A26201
[colours/date]
bg = ${colours.pear}
fg = ${colours.gray}
[colours/battery]
full-bg = ${colours.green+}
full-fg = ${colours.gray}
charging-bg = ${colours.green}
charging-fg = ${colours.gray}
discharging-bg = ${colours.green}
discharging-fg = ${colours.gray}
low-bg = ${colours.orange}
low-fg = ${colours.gray}
[colours/workspaces]
focused-bg = ${colours.linen+}
focused-fg = ${colours.gray}
unfocused-bg = ${colours.linen}
unfocused-fg = ${colours.gray}
urgent-bg = ${colours.orange-}
urgent-fg = ${colours.gray}
[colours/i3-mode]
bg = ${colours.orange}
fg = ${colours.gray}
[colours/volume]
volume-bg = ${colours.blue}
volume-fg = ${colours.white}
muted-bg = ${colours.blue-}
muted-fg = ${colours.white}

View File

@@ -0,0 +1,31 @@
[module/battery]
type = internal/battery
full-at = 100
low-at = 20
battery = BAT0
adapter = ADP0
poll-interval = 5
format-full = <label-full>
label-full = "%{T2}%{T-} %percentage%%"
label-full-background = ${colours/battery.full-bg}
label-full-foreground = ${colours/battery.full-fg}
label-full-padding = 1
format-charging = <label-charging>
label-charging = "%{T2}%{T-} %percentage%%"
label-charging-background = ${colours/battery.charging-bg}
label-charging-foreground = ${colours/battery.charging-fg}
label-charging-padding = 1
format-discharging = <label-discharging>
label-discharging = "%{T2}%{T-} %percentage%%"
label-discharging-background = ${colours/battery.discharging-bg}
label-discharging-foreground = ${colours/battery.discharging-fg}
label-discharging-padding = 1
format-low = <label-low>
label-low = "%{T2}%{T-} %percentage%%"
label-low-background = ${colours/battery.low-bg}
label-low-foreground = ${colours/battery.low-fg}
label-low-padding = 1

View File

@@ -0,0 +1,13 @@
[module/date]
type = internal/date
interval = 1.0
date = %A, %d %B %Y
time = %H:%M:%S
label = %date% · %time%
format = <label>
format-padding = 0
label-background = ${colours/date.bg}
label-foreground = ${colours/date.fg}
label-padding = 1

View File

@@ -0,0 +1,7 @@
[module/i3-mode]
type = internal/i3
format = <label-mode>
label-mode-background = ${colours/i3-mode.bg}
label-mode-foreground = ${colours/i3-mode.fg}
label-mode-padding = 2

View File

@@ -0,0 +1,13 @@
[module/padding]
type = custom/text
content = ||
content-padding = 1
content-foreground = ${colours.trans}
content-background = ${colours.trans}
[module/paddinglite]
type = custom/text
content = |
content-padding = .5
content-foreground = ${colours.trans}
content-background = ${colours.trans}

View File

@@ -0,0 +1,15 @@
[module/volume]
type = internal/pulseaudio
interval = 5
format-volume = <label-volume>
label-volume = %{T2}墳%{T-} %percentage%%
label-volume-padding = 1
label-volume-foreground = ${colours/volume.volume-fg}
label-volume-background = ${colours/volume.volume-bg}
format-muted = <label-muted>
label-muted = %{T2}ﱝ%{T-} muted
label-muted-padding = 1
label-muted-foreground = ${colours/volume.muted-fg}
label-muted-background = ${colours/volume.muted-bg}

View File

@@ -0,0 +1,22 @@
[module/workspaces]
type = internal/i3
format = <label-state>
index-sort = true
wrapping-scroll = false
strip-wsnumbers = true
pin-workspaces = true
label-focused = %index%
label-focused-background = ${colours/workspaces.focused-bg}
label-focused-foreground = ${colours/workspaces.focused-fg}
label-focused-padding = 2
label-unfocused = %index%
label-unfocused-background = ${colours/workspaces.unfocused-bg}
label-unfocused-foreground = ${colours/workspaces.unfocused-fg}
label-unfocused-padding = 2
label-urgent = %index%
label-urgent-background = ${colours/workspaces.urgent-bg}
label-urgent-foreground = ${colours/workspaces.urgent-fg}
label-urgent-padding = 2

View File

@@ -0,0 +1 @@
include-file = bars/bars.ini

View File

@@ -51,6 +51,7 @@
# - Reykjavik ----------------------------
reykjavik = lib.nixosSystem {
inherit system;
inherit pkgs;
modules = [
./system/modules

View File

@@ -4,8 +4,14 @@
home.stateVersion = "22.05";
samfelag = {
modules = {
app = {
spotify.enable = true;
};
};
profiles = {
desktop.enable = true;
gaming.enable = true;
};
};
}

View File

@@ -3,5 +3,6 @@
{
imports = [
./alacritty.nix
./spotify.nix
];
}

View File

@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.app.spotify;
in
{
options.samfelag.modules.app.spotify = {
enable = mkEnableOption "spotify";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
spotify
];
};
}

View File

@@ -17,6 +17,8 @@ let
};
});
system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown";
in {
options.samfelag.modules.desktop.i3 = {
@@ -44,6 +46,8 @@ in {
xsession.windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
config = {
modifier = mod;
@@ -57,11 +61,43 @@ in {
bars = [ ];
window = {
border = 1;
titlebar = false;
};
# gaps = {
# inner = 10;
# outer = 5;
# };
startup = [
{ command = "i3-msg workspace 1"; }
{ command = "systemctl --user restart polybar"; always = true; notification = false; }
];
modes = {
"resize" = {
"h" = "resize shrink width 10 px or 10 ppt";
"j" = "resize grow height 10 px or 10 ppt";
"k" = "resize shrink height 10 px or 10 ppt";
"l" = "resize grow width 10 px or 10 ppt";
"Left" = "resize shrink width 10 px or 10 ppt";
"Down" = "resize grow height 10 px or 10 ppt";
"Up" = "resize shrink height 10 px or 10 ppt";
"Right" = "resize grow width 10 px or 10 ppt";
"Return" = "mode \"default\"";
"Escape" = "mode \"default\"";
};
"${system_mode}" = {
"Return" = "mode \"default\"";
"Escape" = "mode \"default\"";
};
};
keybindings = {
"${mod}+q" = "kill";
@@ -107,6 +143,26 @@ in {
"${mod}+Shift+c" = "reload";
"${mod}+Shift+r" = "restart";
# - Modes ------------------------------
"${mod}+r" = "mode \"resize\"";
"${mod}+End" = "mode \"${system_mode}\"";
# - Media ------------------------------
# Pulse Audio controls
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%";
"Shift+XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1%";
"Shift+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%";
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
# Media player controls
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioPause" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioStop" = "exec playerctl stop";
# - Workspaces -------------------------
"${mod}+1" = "workspace 1";
"${mod}+2" = "workspace 2";

View File

@@ -2,6 +2,14 @@
let
cfg = config.samfelag.modules.desktop.polybar;
polybar_pkg = pkgs.polybar.override {
i3Support = true;
pulseSupport = true;
};
script = ''
polybar top &
polybar bottom &
'';
in {
options.samfelag.modules.desktop.polybar = {
@@ -12,211 +20,30 @@ in {
# - Configuration ----------------------------
services.polybar = {
enable = true;
home.packages = [
polybar_pkg
];
package = pkgs.polybar.override {
i3Support = true;
pulseSupport = true;
xdg.configFile."polybar/config.ini".source = ../../../config/.config/polybar/config.ini;
xdg.configFile."polybar/bars".source = ../../../config/.config/polybar/bars;
systemd.user.services.polybar = {
Unit = {
Description = "Polybar status bar";
PartOf = [ "tray.target" ];
X-Restart-Triggers = [ "${config.xdg.configFile."polybar/config.ini".source}" ];
};
config = {
# - Colors -------------------------------
"colors" = {
"background" = "#222";
"background-alt" = "#444";
"foreground" = "#dfdfdf";
"foreground-alt" = "#555";
"primary" = "#ffb52a";
"secondary" = "#e60053";
"alert" = "#bd2c40";
Service = {
Type = "forking";
Environment = "PATH=${polybar_pkg}/bin:/run/wrappers/bin";
ExecStart =
let scriptPkg = pkgs.writeShellScriptBin "polybar-start" script;
in "${scriptPkg}/bin/polybar-start";
Restart = "on-failure";
};
# - Mainbar ------------------------------
"bar/mainbar-i3" = {
"monitor" = "\${env:MONITOR}";
"monitor-strict" = "false";
"bottom" = "false";
"fixed-center" = "true";
"width" = "100%";
"height" = "30";
"background" = "\${colors.background}";
"foreground" = "\${colors.foreground}";
"radius" = "0.0";
"line-size" = "2";
"line-color" = "#000000";
"border-color" = "#000000";
"padding-left" = "1";
"padding-right" = "1";
"module-margin-left" = "0";
"module-margin-right" = "0";
"font-0" = "\"Iosevka:style=Regular:size=15;2\"";
"font-1" = "\"Iosevka:size=16;3\"";
"font-2" = "\"Iosevka:style=Regular:pixelsize=10;1\"";
"font-3" = "\"Iosevka:style=Solid:pixelsize=10;1\"";
"font-4" = "\"Iosevka:pixelsize=10;1\"";
"modules-left" = "i3";
"modules-center" = "date";
"modules-right" = "wifi pulseaudio battery";
"separator" = "\" : \"";
"tray-position" = "left";
"tray-detached" = "false";
"tray-maxsize" = "20";
"tray-background" = "\${colors.background}";
"tray-offset-x" = "0";
"tray-offset-y" = "0";
"tray-padding" = "4";
"tray-scale" = "1.0";
"enable-ipc" = "true";
"click-left" = "";
"click-middle" = "";
"click-right" = "";
"scroll-up" = "i3wm-wsnext";
"scroll-down" = "i3wm-wsprev";
"double-click-left" = "";
"double-click-middle" = "";
"double-click-right" = "";
"cursor-click" = "";
"cursor-scroll" = "";
};
# - Module: i3 ---------------------------
"module/i3" = {
"type" = "internal/i3";
"format" = "<label-state> <label-mode>";
"index-sort" = "true";
"wrapping-scroll" = "false";
"label-mode-padding" = "2";
"label-mode-foreground" = "#000";
"label-mode-background" = "\${colors.primary}";
"label-focused" = "%index%";
"label-focused-background" = "\${colors.background-alt}";
"label-focused-underline" = "\${colors.secondary}";
"label-focused-padding" = "2";
"label-unfocused" = "%index%";
"label-unfocused-padding" = "2";
"label-visible" = "%index%";
"label-visible-background" = "\${self.label-focused-background}";
"label-visible-underline" = "\${colors.primary}";
"label-visible-padding" = "\${self.label-focused-padding}";
"label-urgent" = "%index%";
"label-urgent-background" = "\${colors.alert}";
"label-urgent-padding" = "2";
};
# - Module: date -------------------------
"module/date" = {
"type" = "internal/date";
"interval" = "1";
"date" = "%A, %d %B %Y";
"time" = "%H:%M:%S";
"time-alt" = "%H:%M:%S %Z (%z)";
"date-alt" = "%Y-%m-%d";
"format-prefix" = "";
"format-prefix-foreground" = "\${colors.foreground-alt}";
"format-underline" = "";
"label" = "%date% · %time%";
};
# - Module: pulseaudio -------------------
"module/pulseaudio" = {
"type" = "internal/pulseaudio";
"format-volume" = "<label-volume> <bar-volume>";
"label-volume" = "VOL %percentage%%";
"label-volume-foreground" = "\${colors.foreground-alt}";
"label-muted" = "muted";
"label-muted-foreground" = "#666";
"bar-volume-width" = "10";
"bar-volume-foreground-0" = "#55aa55";
"bar-volume-foreground-1" = "#55aa55";
"bar-volume-foreground-2" = "#55aa55";
"bar-volume-foreground-3" = "#55aa55";
"bar-volume-foreground-4" = "#55aa55";
"bar-volume-foreground-5" = "#f5a70a";
"bar-volume-foreground-6" = "#ff5555";
"bar-volume-gradient" = "false";
"bar-volume-indicator" = "|";
"bar-volume-indicator-font" = "0";
"bar-volume-fill" = "-";
"bar-volume-fill-font" = "0";
"bar-volume-empty" = "-";
"bar-volume-empty-font" = "0";
"bar-volume-empty-foreground" = "\${colors.foreground-alt}";
};
# - Module: battery ----------------------
"module/battery" = {
"type" = "internal/battery";
"battery" = "BAT0";
"adapter" = "AC";
"full-at" = "98";
"format-charging-prefix" = "\"\"";
"format-charging" = "<label-charging>";
"format-charging-foreground" = "#55aa55";
"format-charging-underline" = "";
"format-discharging-prefix" = "\"\"";
"format-discharging" = "<label-discharging>";
"format-discharging-foreground" = "#f5a70a";
"format-discharging-underline" = "";
"format-full" = "FULL BATTERY";
"format-full-foreground" = "#55aa55";
"format-full-underline" = "\${self.format-charging-underline}";
"ramp-capacity-0" = "";
"ramp-capacity-1" = "";
"ramp-capacity-2" = "";
"ramp-capacity-foreground" = "\${colors.foreground-alt}";
};
};
script = "polybar --reload mainbar-i3 &";
# #!/usr/bin/env bash
# # Terminate already running bar instances
# killall -q polybar
#
# # Wait until the processes have been shut down
# while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
#
# for m in $(polybar --list-monitors | cut -d":" -f1); do
# WIRELESS=$(ls /sys/class/net/ | grep ^wl | awk 'NR==1{print $1}') MONITOR=$m polybar --reload mainbar-i3 &
# done
#
# echo "Bars launched..."
# '';
Install = { WantedBy = [ "tray.target" ]; };
};
};
}

View File

@@ -4,5 +4,6 @@
imports = [
./common.nix
./desktop.nix
./gaming.nix
];
}

View File

@@ -35,6 +35,8 @@ in
app.alacritty.enable = true;
};
services.picom.enable = true;
home.packages = with pkgs; [
rofi
firefox

24
home/profiles/gaming.nix Normal file
View File

@@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.profiles.gaming;
in
{
options.samfelag.profiles.gaming = {
enable = mkEnableOption "gaming profile";
};
config = mkIf cfg.enable {
# - Dependencies -----------------------------
samfelag.modules = {
};
home.packages = with pkgs; [
lutris
];
};
}

View File

@@ -3,26 +3,32 @@
{
imports = [
./hardware.nix
./nvidia.nix
];
# - Basic --------------------------------------
networking.hostName = "reykjavik";
samfelag.modules.user = {
name = "marc";
};
# - Bootloader ---------------------------------
boot.loader.systemd-boot.enable = true;
# - Services -----------------------------------
# - Modules ------------------------------------
samfelag.profiles.desktop = {
samfelag.modules = {
user.name = "marc";
bluetooth.enable = true;
};
# - Profiles -----------------------------------
samfelag.profiles = {
desktop = {
enable = true;
laptop = true;
};
gaming.enable = true;
};
system.stateVersion = "22.05";

View File

@@ -0,0 +1,29 @@
{ config, pkgs, ... }:
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 "$@"
'';
in
{
environment.systemPackages = [ nvidia-offload ];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.opengl.enable = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
hardware.nvidia.prime = {
offload.enable = true;
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
intelBusId = "PCI:0:2:0";
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
nvidiaBusId = "PCI:1:0:0";
};
}

View File

@@ -0,0 +1,17 @@
{ config, lib, pkgs, self, ... }:
let
cfg = config.samfelag.modules.bluetooth;
in
{
options.samfelag.modules.bluetooth = {
enable = lib.mkEnableOption "bluetooth";
};
config = lib.mkIf cfg.enable {
hardware.bluetooth.enable = true;
services.blueman.enable = true;
};
}

View File

@@ -2,6 +2,7 @@
{
imports = [
./bluetooth.nix
./tailscale.nix
./user.nix
];

View File

@@ -33,6 +33,7 @@
environment.systemPackages = with pkgs; [
curl
git
htop
pciutils
psmisc
vim

View File

@@ -4,5 +4,6 @@
imports = [
./common.nix
./desktop.nix
./gaming.nix
];
}

View File

@@ -0,0 +1,19 @@
{ config, pkgs, lib, ... }:
let
cfg = config.samfelag.profiles.gaming;
in
{
options.samfelag.profiles.gaming = {
enable = lib.mkEnableOption "gaming profile";
};
config = lib.mkIf cfg.enable {
programs.steam = {
enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};
};
}