restructure x11

This commit is contained in:
Natsu Kagami 2022-04-20 13:05:02 -04:00
parent a4a16cc97c
commit 8b6dd79516
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
19 changed files with 406 additions and 312 deletions

View file

@ -1,60 +0,0 @@
{ pkgs, config, lib, ... }:
with lib;
{
imports = [ ./packages.nix ../modules/X11/xfce4-notifyd.nix ];
home.sessionVariables = {
# Set up Java font style
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd";
};
# X Session settings
xsession.enable = true;
# Wallpaper
home.file.wallpaper = {
source = ./. + "/wallpaper.jpg";
target = "wallpaper.jpg";
};
# Cursor
xsession.pointerCursor = {
package = pkgs.numix-cursor-theme;
name = "Numix-Cursor-Light";
size = 32;
};
# MIME set ups
xdg.enable = true;
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = {
"x-scheme-handler/http" = [ "firefox.desktop" ];
"x-scheme-handler/https" = [ "firefox.desktop" ];
"x-scheme-handler/ftp" = [ "firefox.desktop" ];
"x-scheme-handler/ftps" = [ "firefox.desktop" ];
"x-scheme-handler/mailspring" = [ "Mailspring.desktop" ];
};
# Mimic the clipboard stuff in MacOS
home.packages = [
(pkgs.writeShellScriptBin "pbcopy" ''
exec ${pkgs.xsel}/bin/xsel -ib
'')
(pkgs.writeShellScriptBin "pbpaste" ''
exec ${pkgs.xsel}/bin/xsel -ob
'')
];
# Notification system
services.X11.xfce4-notifyd.enable = true;
# IBus configuration
dconf.settings."desktop/ibus/general" = {
engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
reload-engines = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
};
dconf.settings."desktop/ibus/general/hotkey" = {
triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "<Super>z" ];
};
}

View file

@ -1,23 +0,0 @@
{ pkgs, config, lib, ... } :
{
# X resources for 4k monitor
home.file."4k.Xresources" = {
target = ".config/X11/.Xresources";
text = ''
Xft.dpi: 192
! These might also be useful depending on your monitor and personal preference:
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
'';
};
# Load 4k Xresources
xsession.initExtra = ''
xrdb -merge ~/.config/X11/.Xresources
feh --bg-fill ~/wallpaper.jpg
'';
}

View file

@ -1,145 +0,0 @@
{ pkgs, config, lib, ... }:
let
mod = "Mod4";
workspaces = [
"1: web"
"2: chat"
"3: code"
"4: music"
"5: extra"
"6: 6"
"7: 7"
"8: 8"
"9: 9"
"10: 10"
];
wsAttrs = builtins.listToAttrs (
map
(i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); })
(range 1 11)
);
remainder = x: y: x - (builtins.div x y) * y;
range = from: to:
let
f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1);
in
f from;
in
{
imports = [ ./i3/screenshot.nix ];
## i3 window manager
xsession.windowManager.i3 = {
enable = true;
config.assigns = {
"${wsAttrs."1"}" = [{ class = "^firefox$"; }];
"${wsAttrs."2"}" = [{ class = "^discord$"; }];
};
config.bars = [{
command = "${pkgs.i3-gaps}/bin/i3bar -t";
statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml";
position = "top";
colors = {
background = "#00000080";
statusline = "#ffffff";
separator = "#666666";
focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; };
activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; };
inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; };
urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
};
}];
config.focus.newWindow = "none";
config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; };
config.gaps.outer = 5;
config.gaps.inner = 5;
config.gaps.smartGaps = true;
config.modifier = mod;
config.terminal = "alacritty";
config.window.titlebar = false;
# Keybindings
config.keybindings = lib.mkOptionDefault ({
## vim-style movements
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
## Splits
"${mod}+v" = "split v";
"${mod}+Shift+v" = "split h";
## Run
"${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run";
"${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'";
} // (
builtins.listToAttrs (lib.flatten (map
(key: [
{
name = "${mod}+${key}";
value = "workspace ${builtins.getAttr key wsAttrs}";
}
{
name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}";
}
])
(builtins.attrNames wsAttrs))
)));
# Workspace
config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}";
config.startup = [
{ command = "firefox"; }
{ command = "discord"; }
{ command = "dex -ae i3"; }
{ command = "ibus-daemon -drxR"; }
];
};
# i3status
programs.i3status-rust.enable = true;
programs.i3status-rust.bars.default = {
icons = "material-nf";
theme = "native";
settings = {
icons_format = " <span font_family='FantasqueSansMono Nerd Font'>{icon}</span> ";
};
blocks = [
# {
# block = "bluetooth";
# mac = "5C:52:30:D8:E2:9D";
# format = "Airpods Pro {percentage}";
# format_unavailable = "Airpods Pro XX";
# }
{
block = "cpu";
format = "{utilization}";
}
{
block = "hueshift";
}
{
block = "memory";
}
{
block = "net";
}
{
block = "sound";
}
{
block = "time";
}
];
};
}

View file

@ -1,9 +0,0 @@
{ pkgs, config, lib, ... }:
with lib;
{
xsession.windowManager.i3.config = {
startup = [ { command = "${pkgs.flameshot}/bin/flameshot"; } ];
keybindings = mkOptionDefault { "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; };
};
}

View file

@ -1,39 +0,0 @@
{ pkgs, config, lib, ... }:
let
# Override nss to open links in Firefox (https://github.com/NixOS/nixpkgs/issues/78961)
discordPkg = pkgs.unstable.discord.override { nss = pkgs.unstable.nss; };
in
{
imports = [ ./alacritty.nix ./i3.nix ];
home.packages = (with pkgs; [
## GUI stuff
gnome.cheese # Webcam check
evince # PDF reader
gparted
pkgs.unstable.vscode
feh
deluge # Torrent client
mailspring
discordPkg
pavucontrol # PulseAudio control panel
## CLI stuff
xsel # Clipboard management
dex # .desktop file management, startup
sct # Display color temperature
]);
# Gnome-keyring
services.gnome-keyring.enable = true;
# Picom: X Compositor
services.picom = {
enable = true;
blur = true;
fade = true;
fadeDelta = 3;
shadow = true;
};
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

15
home/common-linux.nix Normal file
View file

@ -0,0 +1,15 @@
{ pkgs, config, lib, ... }:
with lib; {
imports = [ ./modules/linux/graphical ./modules/X11/xfce4-notifyd.nix ];
config = (mkIf (strings.hasSuffix "linux" pkgs.system) {
## Gnome-keyring
services.gnome-keyring = {
enable = true;
components = [ "pkcs11" "secrets" "ssh" ];
};
services.gpg-agent.enable = true;
services.gpg-agent.enableSshSupport = true;
services.gpg-agent.pinentryFlavor = "gtk2";
});
}

View file

@ -5,6 +5,8 @@
./kakoune/kak.nix
./fish/fish.nix
./modules/programs/my-broot.nix
./modules/programs/my-sway
./common-linux.nix
];
# Let Home Manager install and manage itself.

View file

@ -1,16 +1,13 @@
{ pkgs, config, lib, ... } :
{ pkgs, config, lib, ... }:
{
imports = [
# Common configuration
./common.nix
# Set up X11-specific common configuration
./X11/default.nix
./X11/hidpi.nix # Enable hiDPI
# We use our own firefox
./firefox.nix
# osu!
./osu.nix
# Common configuration
./common.nix
# We use our own firefox
./firefox.nix
# osu!
./osu.nix
];
# Home Manager needs a bit of information about you and the
@ -20,17 +17,22 @@
# More packages
home.packages = (with pkgs; [
# CLI stuff
python
zip
# TeX
texlive.combined.scheme-full
# CLI stuff
python
zip
# TeX
texlive.combined.scheme-full
# Java & sbt
openjdk11
sbt
# Java & sbt
openjdk11
sbt
]);
# Enable X11 configuration
linux.graphical.type = "x11";
linux.graphical.x11.hidpi = true;
linux.graphical.x11.enablei3 = true;
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards

View file

@ -42,13 +42,13 @@ map global goto f -docstring "current grep-jump match" '<esc>: grep-jump<ret>'
# System clipboard interactions
hook global RegisterModified '"' %{ nop %sh{
printf "%s" "$kak_main_reg_dquote" | pbcopy
printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null &
}}
map global user P -docstring "Paste before cursor from clipboard" '! pbpaste<ret>'
map global user p -docstring "Paste after cursor from clipboard" '<a-!> pbpaste<ret>'
map global user R -docstring "Replace selection with text from clipboard" '<a-d>! pbpaste<ret>'
define-command -params 0 -docstring "Copy line down" copyline %{
execute-keys -draft '<a-x>y'%val{count}'P'
execute-keys -draft 'xy'%val{count}'P'
}
map global normal <+> -docstring "Copy line down" ': copyline<ret>'
define-command -params 0 -docstring "Delete current character" delete-one %{

View file

@ -1,10 +1,8 @@
{ pkgs, config, lib, ... }:
with lib;
{
home.packages = [
];
programs.alacritty = {
programs.alacritty = mkIf (config.linux.graphical.type != null) {
enable = true;
package = pkgs.unstable.alacritty;
@ -16,7 +14,7 @@
};
shell = {
program = "/bin/sh";
args = [ "-ic" "fish" ];
args = [ "-ic" "${config.programs.fish.package}/bin/fish" ];
};
colors = {
# Default colors

View file

@ -0,0 +1,72 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.linux.graphical;
in
{
imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ];
options.linux.graphical = {
type = mkOption {
type = types.nullOr (types.enum [ "x11" "wayland" ]);
description = "Enable linux graphical configurations, with either 'x11' or 'wayland'";
default = null;
};
wallpaper = mkOption {
type = types.oneOf [ types.str types.path ];
description = "Path to the wallpaper file";
default = "";
};
};
config = mkIf (cfg.type != null) {
# Packages
home.packages = (with pkgs; [
## GUI stuff
gnome.cheese # Webcam check
evince # PDF reader
gparted
pkgs.unstable.vscode
feh
deluge # Torrent client
mailspring
unstable.discord
pavucontrol # PulseAudio control panel
## CLI stuff
dex # .desktop file management, startup
sct # Display color temperature
]);
# Cursor
xsession.pointerCursor = {
package = pkgs.numix-cursor-theme;
name = "Numix-Cursor-Light";
size = 32;
};
# MIME set ups
xdg.enable = true;
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = {
"x-scheme-handler/http" = [ "firefox.desktop" ];
"x-scheme-handler/https" = [ "firefox.desktop" ];
"x-scheme-handler/ftp" = [ "firefox.desktop" ];
"x-scheme-handler/ftps" = [ "firefox.desktop" ];
"x-scheme-handler/mailspring" = [ "Mailspring.desktop" ];
};
home.sessionVariables = {
# Set up Java font style
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd";
};
# IBus configuration
dconf.settings."desktop/ibus/general" = {
engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
reload-engines = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
};
dconf.settings."desktop/ibus/general/hotkey" = {
triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "<Super>z" ];
};
};
}

View file

@ -0,0 +1,28 @@
{ pkgs, config, lib, ... }:
with lib;
{
config = mkIf (config.linux.graphical.type == "wayland") {
# Additional packages
home.packages = with pkgs; [
wl-clipboard # Clipboard management
# Mimic the clipboard stuff in MacOS
(pkgs.writeShellScriptBin "pbcopy" ''
exec ${pkgs.wl-clipboard}/bin/wl-copy
'')
(pkgs.writeShellScriptBin "pbpaste" ''
exec ${pkgs.wl-clipboard}/bin/wl-paste -n
'')
];
# Notification system
programs.mako = {
enable = true;
borderRadius = 5;
};
# Forward wallpaper settings to sway
programs.my-sway.wallpaper = config.linux.graphical.wallpaper;
};
}

View file

@ -0,0 +1,35 @@
{ pkgs, config, lib, ... }:
with lib;
{
imports = [ ./x11/hidpi.nix ./x11/i3.nix ];
config = mkIf (config.linux.graphical.type == "x11") {
# X Session settings
xsession.enable = true;
# Additional packages
home.packages = with pkgs; [
xsel # Clipboard management
# Mimic the clipboard stuff in MacOS
(pkgs.writeShellScriptBin "pbcopy" ''
exec ${pkgs.xsel}/bin/xsel -ib
'')
(pkgs.writeShellScriptBin "pbpaste" ''
exec ${pkgs.xsel}/bin/xsel -ob
'')
];
# Notification system
services.X11.xfce4-notifyd.enable = true;
# Picom: X Compositor
services.picom = {
enable = true;
blur = true;
fade = true;
fadeDelta = 3;
shadow = true;
};
};
}

View file

@ -0,0 +1,31 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.linux.graphical.x11;
in
{
options.linux.graphical.x11.hidpi = mkEnableOption "Enable hiDPI mode for X11";
config = mkIf cfg.hidpi {
# X resources for 4k monitor
home.file."4k.Xresources" = {
target = ".config/X11/.Xresources";
text = ''
Xft.dpi: 192
! These might also be useful depending on your monitor and personal preference:
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
'';
};
# Load 4k Xresources
xsession.initExtra = ''
xrdb -merge ~/.config/X11/.Xresources
feh --bg-fill ~/wallpaper.jpg
'';
};
}

View file

@ -0,0 +1,153 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.linux.graphical.x11;
mod = "Mod4";
workspaces = [
"1: web"
"2: chat"
"3: code"
"4: music"
"5: extra"
"6: 6"
"7: 7"
"8: 8"
"9: 9"
"10: 10"
];
wsAttrs = builtins.listToAttrs (
map
(i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); })
(range 1 11)
);
remainder = x: y: x - (builtins.div x y) * y;
range = from: to:
let
f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1);
in
f from;
in
{
imports = [ ./i3/screenshot.nix ];
options.linux.graphical.x11.enablei3 = mkEnableOption "Enable i3";
config = mkIf (cfg.enablei3) {
## i3 window manager
xsession.windowManager.i3 = {
enable = true;
config.assigns = {
"${wsAttrs."1"}" = [{ class = "^firefox$"; }];
"${wsAttrs."2"}" = [{ class = "^discord$"; }];
};
config.bars = [{
command = "${pkgs.i3-gaps}/bin/i3bar -t";
statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml";
position = "top";
colors = {
background = "#00000080";
statusline = "#ffffff";
separator = "#666666";
focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; };
activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; };
inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; };
urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
};
}];
config.focus.newWindow = "none";
config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; };
config.gaps.outer = 5;
config.gaps.inner = 5;
config.gaps.smartGaps = true;
config.modifier = mod;
config.terminal = "alacritty";
config.window.titlebar = false;
# Keybindings
config.keybindings = lib.mkOptionDefault ({
## vim-style movements
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
## Splits
"${mod}+v" = "split v";
"${mod}+Shift+v" = "split h";
## Run
"${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run";
"${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'";
} // (
builtins.listToAttrs (lib.flatten (map
(key: [
{
name = "${mod}+${key}";
value = "workspace ${builtins.getAttr key wsAttrs}";
}
{
name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}";
}
])
(builtins.attrNames wsAttrs))
)));
# Workspace
config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}";
config.startup = [
{ command = "firefox"; }
{ command = "discord"; }
{ command = "dex -ae i3"; }
{ command = "ibus-daemon -drxR"; }
];
};
# i3status
programs.i3status-rust.enable = true;
programs.i3status-rust.bars.default = {
icons = "material-nf";
theme = "native";
settings = {
icons_format = " <span font_family='FantasqueSansMono Nerd Font'>{icon}</span> ";
};
blocks = [
# {
# block = "bluetooth";
# mac = "5C:52:30:D8:E2:9D";
# format = "Airpods Pro {percentage}";
# format_unavailable = "Airpods Pro XX";
# }
{
block = "cpu";
format = "{utilization}";
}
{
block = "hueshift";
}
{
block = "memory";
}
{
block = "net";
}
{
block = "sound";
}
{
block = "time";
}
];
};
};
}

View file

@ -0,0 +1,9 @@
{ pkgs, config, lib, ... }:
with lib;
{
xsession.windowManager.i3.config = mkIf (config.linux.graphical.x11.enablei3) {
startup = [{ command = "${pkgs.flameshot}/bin/flameshot"; }];
keybindings = mkOptionDefault { "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; };
};
}

View file

@ -4,17 +4,10 @@
imports = [
# Common configuration
./common.nix
# Set up X11-specific common configuration
# ./X11/default.nix
# ./X11/hidpi.nix # Enable hiDPI
# We use our own firefox
# ./firefox.nix
# osu!
# ./osu.nix
# Sway
./modules/programs/my-sway
# Alacritty
./X11/alacritty.nix
];
# Home Manager needs a bit of information about you and the
@ -35,10 +28,12 @@
sbt
]);
# Graphical set up
linux.graphical.type = "wayland";
linux.graphical.wallpaper = ./images/wallpaper_0.png;
# Enable sway
programs.my-sway.enable = true;
programs.my-sway.fontSize = 14.0;
programs.my-sway.wallpaper = ./images/wallpaper_0.png;
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage

View file

@ -12,6 +12,8 @@
# Fonts
../modules/personal/fonts
];
# Use the latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
@ -27,7 +29,7 @@
networking.wireless.iwd.enable = true; # Enables wireless support via iwd.
# Set your time zone.
# time.timeZone = "Europe/Amsterdam";
time.timeZone = "America/Toronto";
# 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
@ -48,6 +50,7 @@
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver.autorun = false;
# Enable the Plasma 5 Desktop Environment.
@ -64,14 +67,20 @@
# Configure keymap in X11
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
i18n.inputMethod.enabled = "ibus";
i18n.inputMethod.ibus.engines = (with pkgs.ibus-engines; [ bamboo mozc libpinyin ]);
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio.enable = true;
hardware.pulseaudio.package = pkgs.pulseaudioFull;
hardware.pulseaudio = {
enable = true;
extraModules = [ pkgs.pulseaudio-modules-bt ];
package = pkgs.pulseaudioFull;
};
# Enable bluetooth
hardware.bluetooth.enable = true;
@ -89,9 +98,30 @@
# $ nix search wget
environment.systemPackages = with pkgs; [
kakoune # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
fish
firefox
## System Monitoring tools
usbutils
pciutils
];
# Gnome-keyring is useful
services.gnome.gnome-keyring.enable = true;
## Environment variables
environment.variables = {
# Input method overrides
GTK_IM_MODULE = "ibus";
QT_IM_MODULE = "ibus";
"XMODIFIERS=@im" = "ibus";
# Basic editor setup
EDITOR = "kak";
VISUAL = "kak";
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;