From def2ee00649387b2912e122e3b91f1032e7f3075 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Sun, 1 May 2022 10:32:31 +0200 Subject: [PATCH] alejandra reformatting --- extra_info.nix | 12 +- flake.nix | 56 ++++--- git/default.nix | 7 +- graphical.nix | 8 +- home.nix | 38 +++-- nixos/anbox.nix | 70 +++++---- nixos/configuration.nix | 34 +++-- nixos/hardware-configuration.nix | 43 +++--- nixos/home.nix | 6 +- nixos/localcfg.nix | 48 +++--- nixos/pkg.nix | 26 ++-- rustdev.nix | 7 +- wm/default.nix | 249 ++++++++++++++++--------------- wm/i3.nix | 55 ++++--- wm/i3like-utils.nix | 53 +++---- wm/i3like.nix | 19 ++- wm/sway.nix | 107 +++++++------ wm/terminal/default.nix | 24 +-- wm/terminal/foot.nix | 73 ++++----- wm/terminal/kitty.nix | 71 ++++----- 20 files changed, 540 insertions(+), 466 deletions(-) diff --git a/extra_info.nix b/extra_info.nix index 56c9d74..2526ec4 100644 --- a/extra_info.nix +++ b/extra_info.nix @@ -1,9 +1,11 @@ -{ config, lib, pkgs, ... }: - -with lib; -with builtins; - { + config, + lib, + pkgs, + ... +}: +with lib; +with builtins; { options = { extraInfo.email = mkOption { type = types.nullOr types.str; diff --git a/flake.nix b/flake.nix index e12387d..e831dd0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,37 +1,40 @@ { description = "NixOS configuration"; - inputs = - { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - nixpkgs-mozilla = { - url = "github:mozilla/nixpkgs-mozilla"; - flake = false; - }; - nix-alien.url = "github:thiagokokada/nix-alien"; - nix-ld.url = "github:Mic92/nix-ld/main"; - nvim-traxys = { - url = "github:traxys/nvim-flake"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - zsh-traxys = { - url = "github:traxys/zsh-flake"; - }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; + nixpkgs-mozilla = { + url = "github:mozilla/nixpkgs-mozilla"; + flake = false; + }; + nix-alien.url = "github:thiagokokada/nix-alien"; + nix-ld.url = "github:Mic92/nix-ld/main"; + nvim-traxys = { + url = "github:traxys/nvim-flake"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + zsh-traxys = { + url = "github:traxys/zsh-flake"; + }; + }; - outputs = { home-manager, nixpkgs, ... }@inputs: { + outputs = { + home-manager, + nixpkgs, + ... + } @ inputs: { nixosConfigurations = { ZeNixLaptop = nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; modules = [ - ({ pkgs, ... }: { + ({pkgs, ...}: { nixpkgs.overlays = [ inputs.nvim-traxys.overlay."${system}" - inputs.nix-alien.overlay + inputs.nix-alien.overlay (import inputs.nixpkgs-mozilla) (final: prev: { }) @@ -42,7 +45,12 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.users.traxys = { config, lib, pkgs, ... }: { + home-manager.users.traxys = { + config, + lib, + pkgs, + ... + }: { imports = [ ./home.nix ./graphical.nix diff --git a/git/default.nix b/git/default.nix index 2862172..242a3e1 100644 --- a/git/default.nix +++ b/git/default.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { programs.git = { enable = true; userName = "Quentin Boyer"; diff --git a/graphical.nix b/graphical.nix index 968acfb..087d572 100644 --- a/graphical.nix +++ b/graphical.nix @@ -1,6 +1,8 @@ -{ pkgs, config, ... }: - { + pkgs, + config, + ... +}: { home.packages = with pkgs; [ # Browser firefox-wayland @@ -10,7 +12,7 @@ # IM element-desktop - (discord.override { nss = pkgs.nss; }) + (discord.override {nss = pkgs.nss;}) signal-desktop # Mail diff --git a/home.nix b/home.nix index 59a9592..b351cf0 100644 --- a/home.nix +++ b/home.nix @@ -1,17 +1,15 @@ -{ config -, pkgs -, lib -, ... -}: - -let - rustVersion = (pkgs.rustChannelOf { channel = "stable"; }).rust; +{ + config, + pkgs, + lib, + ... +}: let + rustVersion = (pkgs.rustChannelOf {channel = "stable";}).rust; rsPlatform = pkgs.makeRustPlatform { cargo = rustVersion; rustc = rustVersion; }; -in -{ +in { home.packages = with pkgs; [ bitwarden-cli nodePackages.vscode-json-languageserver @@ -33,8 +31,8 @@ in linuxPackages.perf unzip tokei - gcc11 - nix-alien + gcc11 + nix-alien ]; services = { @@ -44,11 +42,11 @@ in }; programs = { - direnv = { - enable = true; - nix-direnv.enable = true; - enableZshIntegration = true; - }; + direnv = { + enable = true; + nix-direnv.enable = true; + enableZshIntegration = true; + }; home-manager = { enable = true; @@ -74,9 +72,9 @@ in }; programs.zsh = { - shellAliases = { - new-direnv = "nix flake new -t github:nix-community/nix-direnv"; - }; + shellAliases = { + new-direnv = "nix flake new -t github:nix-community/nix-direnv"; + }; }; # This value determines the Home Manager release that your diff --git a/nixos/anbox.nix b/nixos/anbox.nix index cb1c012..c415a23 100644 --- a/nixos/anbox.nix +++ b/nixos/anbox.nix @@ -1,43 +1,51 @@ -{ stdenv, lib, fetchFromGitHub, kernel, kmod, name, ... }: - -let anbox-modules = - fetchFromGitHub { +{ + stdenv, + lib, + fetchFromGitHub, + kernel, + kmod, + name, + ... +}: let + anbox-modules = fetchFromGitHub { owner = "choff"; repo = "anbox-modules"; rev = "8148a162755bf5500a07cf41a65a02c8f3eb0af9"; sha256 = "sha256-5YeKwLP0qdtmWbL6AXluyTmVcmKJJOFcZJ5NxXSSgok="; }; in -stdenv.mkDerivation rec { - inherit name; - version = "0"; + stdenv.mkDerivation rec { + inherit name; + version = "0"; - src = "${anbox-modules}/${name}"; + src = "${anbox-modules}/${name}"; - #sourceRoot = "${src}/${ashmem}"; - hardeningDisable = [ "pic" "format" ]; - nativeBuildInputs = kernel.moduleBuildDependencies; + #sourceRoot = "${src}/${ashmem}"; + hardeningDisable = ["pic" "format"]; + nativeBuildInputs = kernel.moduleBuildDependencies; - KERNEL_SRC = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; + KERNEL_SRC = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; - buildPhase = "make INSTALL_MOD_PATH=$out"; - installPhase = '' - modDir=$out/lib/modules/${kernel.modDirVersion}/kernel/updates/ - mkdir -p $modDir - mv ${name}_linux.ko $modDir/. - ''; + buildPhase = "make INSTALL_MOD_PATH=$out"; + installPhase = '' + modDir=$out/lib/modules/${kernel.modDirVersion}/kernel/updates/ + mkdir -p $modDir + mv ${name}_linux.ko $modDir/. + ''; - /* makeFlags = [ - "KERNELRELEASE=${kernel.modDirVersion}" - "KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" - "INSTALL_MOD_PATH=$(out)" - ]; */ + /* + makeFlags = [ + "KERNELRELEASE=${kernel.modDirVersion}" + "KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "INSTALL_MOD_PATH=$(out)" + ]; + */ - meta = with lib; { - description = "Kernel module for anbox - ${name}"; - homepage = "https://github.com/choff/anbox-modules"; - license = licenses.gpl2; - maintainers = [ ]; - platforms = platforms.linux; - }; -} + meta = with lib; { + description = "Kernel module for anbox - ${name}"; + homepage = "https://github.com/choff/anbox-modules"; + license = licenses.gpl2; + maintainers = []; + platforms = platforms.linux; + }; + } diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 6a8f6d2..3770780 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -1,18 +1,18 @@ # 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’). - -{ config, pkgs, ... }: - { - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - ./pkg.nix - #./home.nix - ./localcfg.nix - ]; + config, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ./pkg.nix + #./home.nix + ./localcfg.nix + ]; # 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 @@ -47,20 +47,22 @@ fonts.enableDefaultFonts = true; fonts = { fonts = with pkgs; [ - (nerdfonts.override { fonts = [ "Hack" ]; }) + (nerdfonts.override {fonts = ["Hack"];}) dejavu_fonts ]; fontconfig = { defaultFonts = { - serif = [ "DejaVu" ]; - sansSerif = [ "DejaVu Sans" ]; - monospace = [ "Hack" ]; + serif = ["DejaVu"]; + sansSerif = ["DejaVu Sans"]; + monospace = ["Hack"]; }; }; }; boot.kernelPackages = pkgs.linuxPackages; - /* nixpkgs.config.allowBroken = true; */ + /* + nixpkgs.config.allowBroken = true; + */ virtualisation.waydroid.enable = true; security.pam.services.swaylock = { diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix index b2d9a36..0655fba 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration.nix @@ -1,31 +1,32 @@ # 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") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - boot.kernelParams = [ "iomem=relaxed" ]; + boot.initrd.availableKernelModules = ["ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"]; + boot.initrd.kernelModules = ["dm-snapshot"]; + boot.kernelModules = ["kvm-intel"]; + boot.extraModulePackages = []; + boot.kernelParams = ["iomem=relaxed"]; - fileSystems."/" = - { - device = "/dev/disk/by-uuid/95baa216-c7f1-418d-be70-cd1d4102c837"; - fsType = "btrfs"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/95baa216-c7f1-418d-be70-cd1d4102c837"; + fsType = "btrfs"; + }; - fileSystems."/home" = - { - device = "/dev/disk/by-uuid/50e43b17-10c8-4bbe-893a-c709172867db"; - fsType = "btrfs"; - }; + fileSystems."/home" = { + device = "/dev/disk/by-uuid/50e43b17-10c8-4bbe-893a-c709172867db"; + fsType = "btrfs"; + }; swapDevices = [ ]; diff --git a/nixos/home.nix b/nixos/home.nix index f34d12e..7061e42 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -1,9 +1,7 @@ -{ ... }: - -{ +{...}: { imports = [ ]; home-manager.useGlobalPkgs = true; - home-manager.users.traxys = (import /etc/nixos/traxys/home.nix); + home-manager.users.traxys = import /etc/nixos/traxys/home.nix; } diff --git a/nixos/localcfg.nix b/nixos/localcfg.nix index 50def1f..f220331 100644 --- a/nixos/localcfg.nix +++ b/nixos/localcfg.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { boot = { initrd = { luks.devices = { @@ -32,24 +34,24 @@ }; }; -/* - services.xserver = { - enable = true; - videoDrivers = [ "nvidia" ]; - layout = "us"; - xkbVariant = "dvp"; - libinput.enable = true; - desktopManager.session = [ - { - name = "home-manager"; - start = '' - ${pkgs.runtimeShell} $HOME/.hm-xsession-dbg& - waitPID=$! - ''; - } - ]; - }; -*/ + /* + services.xserver = { + enable = true; + videoDrivers = [ "nvidia" ]; + layout = "us"; + xkbVariant = "dvp"; + libinput.enable = true; + desktopManager.session = [ + { + name = "home-manager"; + start = '' + ${pkgs.runtimeShell} $HOME/.hm-xsession-dbg& + waitPID=$! + ''; + } + ]; + }; + */ users = { users = { @@ -57,12 +59,12 @@ uid = 1000; isNormalUser = true; home = "/home/traxys"; - extraGroups = [ "wheel" "networkmanager" "adbusers" ]; + extraGroups = ["wheel" "networkmanager" "adbusers"]; shell = pkgs.zsh; }; localtimed.group = "localtimed"; }; - groups.localtimed = { }; + groups.localtimed = {}; }; # Set your time zone. @@ -70,7 +72,7 @@ services.printing = { enable = true; - drivers = [ pkgs.hplip pkgs.gutenprint pkgs.cnijfilter2 ]; + drivers = [pkgs.hplip pkgs.gutenprint pkgs.cnijfilter2]; }; services.avahi = { nssmdns = true; diff --git a/nixos/pkg.nix b/nixos/pkg.nix index 5c9f1ef..6b0fa03 100644 --- a/nixos/pkg.nix +++ b/nixos/pkg.nix @@ -1,10 +1,12 @@ -{ config, pkgs, lib, ... }: - -let - ashmem = config.boot.kernelPackages.callPackage ./anbox.nix { name = "ashmem"; }; - binder = config.boot.kernelPackages.callPackage ./anbox.nix { name = "binder"; }; -in { + config, + pkgs, + lib, + ... +}: let + ashmem = config.boot.kernelPackages.callPackage ./anbox.nix {name = "ashmem";}; + binder = config.boot.kernelPackages.callPackage ./anbox.nix {name = "binder";}; +in { xdg = { portal = { enable = true; @@ -30,11 +32,13 @@ in allowUnfree = true; }; - /* nixpkgs.config.packageOverrides = pkgs: { - steam = pkgs.steam.override { - nativeOnly = true; - }; - }; */ + /* + nixpkgs.config.packageOverrides = pkgs: { + steam = pkgs.steam.override { + nativeOnly = true; + }; + }; + */ programs.steam.enable = true; } diff --git a/rustdev.nix b/rustdev.nix index bb0de4e..530c6fc 100644 --- a/rustdev.nix +++ b/rustdev.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { home.sessionVariables = { RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache"; }; diff --git a/wm/default.nix b/wm/default.nix index 288f493..55717de 100644 --- a/wm/default.nix +++ b/wm/default.nix @@ -1,7 +1,10 @@ -{ config, lib, pkgs, ... }: - { - imports = [ ./terminal ./i3like.nix ]; + config, + lib, + pkgs, + ... +}: { + imports = [./terminal ./i3like.nix]; gtk = { enable = true; @@ -26,12 +29,12 @@ normal = "000000"; bright = "545454"; }; - red = { normal = "ff5555"; }; - green = { normal = "55ff55"; }; - yellow = { normal = "ffff55"; }; - blue = { normal = "5555ff"; }; - magenta = { normal = "ff55ff"; }; - cyan = { normal = "55ffff"; }; + red = {normal = "ff5555";}; + green = {normal = "55ff55";}; + yellow = {normal = "ffff55";}; + blue = {normal = "5555ff";}; + magenta = {normal = "ff55ff";}; + cyan = {normal = "55ffff";}; white = { normal = "bbbbbb"; bright = "ffffff"; @@ -45,121 +48,125 @@ }; }; - wm = let mod = config.wm.modifier; in - { - enable = true; - kind = "sway"; - modifier = "Mod4"; + wm = let + mod = config.wm.modifier; + in { + enable = true; + kind = "sway"; + modifier = "Mod4"; + font = { + name = "Hack Nerd Font"; + style = "Regular"; + size = 12.0; + }; + bar = { font = { - name = "Hack Nerd Font"; + name = "Hack Nerd Font Mono"; style = "Regular"; - size = 12.0; - }; - bar = { - font = { - name = "Hack Nerd Font Mono"; - style = "Regular"; - size = 11.0; - }; - }; - - wallpaper = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray}/share/backgrounds/nixos/nix-wallpaper-simple-dark-gray.png"; - - printScreen = { - enable = true; - keybind = "Print"; - }; - - menu = { - enable = true; - keybind = "${mod}+e"; - }; - - exit = { - enable = true; - keybind = "${mod}+Shift+e"; - }; - - notifications = { - enable = true; - font = "hack nerd font 10"; - defaultTimeout = 7000; - }; - - startup = [ - { command = "signal-desktop"; } - { command = "discord"; } - { command = "firefox"; } - { command = "element-desktop"; } - { command = "thunderbird"; } - { command = "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK"; } - { command = "hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"; } - ]; - - workspaces = { - moveModifier = "Shift"; - definitions = { - "1:" = { key = "ampersand"; }; - "2:" = { key = "bracketleft"; output = "DP-0"; }; - "3:" = { key = "braceleft"; }; - "4" = { key = "braceright"; }; - "5" = { key = "parenleft"; }; - "6" = { key = "equal"; }; - "7" = { key = "asterisk"; }; - "" = { - key = "parenright"; - output = "HDMI-0"; - assign = [ "Spotify" ]; - }; - "" = { - key = "w"; - output = "HDMI-0"; - assign = [ - "Element" - "Signal" - "Discord" - ]; - }; - "" = { - key = "m"; - output = "HDMI-0"; - assign = [ "Thunderbird" ]; - }; - }; - }; - - keybindings = { - "${mod}+Shift+l" = "exec ${pkgs.swaylock-fancy}/bin/swaylock-fancy"; - - # Media Keys - "XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ '+10%'"; - "XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ '-10%'"; - "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; - "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify play-pause"; - "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify next"; - "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify previous"; - - # Focus - "${mod}+Left" = "focus left"; - "${mod}+Right" = "focus right"; - "${mod}+Down" = "focus down"; - "${mod}+Up" = "focus up"; - "${mod}+Shift+Left" = "move left"; - "${mod}+Shift+Right" = "move right"; - "${mod}+Shift+Down" = "move down"; - "${mod}+Shift+Up" = "move up"; - - # Layout - "${mod}+u" = "fullscreen toggle"; - "${mod}+comma" = "layout tabbed"; - - # Misc - "${mod}+Shift+colon" = "kill"; - "${mod}+Shift+J" = "reload"; - "${mod}+Return" = "exec ${config.terminal.command}"; - "${mod}+p" = "mode resize"; - "${mod}+Shift+P" = "restart"; + size = 11.0; }; }; + + wallpaper = "${pkgs.nixos-artwork.wallpapers.simple-dark-gray}/share/backgrounds/nixos/nix-wallpaper-simple-dark-gray.png"; + + printScreen = { + enable = true; + keybind = "Print"; + }; + + menu = { + enable = true; + keybind = "${mod}+e"; + }; + + exit = { + enable = true; + keybind = "${mod}+Shift+e"; + }; + + notifications = { + enable = true; + font = "hack nerd font 10"; + defaultTimeout = 7000; + }; + + startup = [ + {command = "signal-desktop";} + {command = "discord";} + {command = "firefox";} + {command = "element-desktop";} + {command = "thunderbird";} + {command = "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK";} + {command = "hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK";} + ]; + + workspaces = { + moveModifier = "Shift"; + definitions = { + "1:" = {key = "ampersand";}; + "2:" = { + key = "bracketleft"; + output = "DP-0"; + }; + "3:" = {key = "braceleft";}; + "4" = {key = "braceright";}; + "5" = {key = "parenleft";}; + "6" = {key = "equal";}; + "7" = {key = "asterisk";}; + "" = { + key = "parenright"; + output = "HDMI-0"; + assign = ["Spotify"]; + }; + "" = { + key = "w"; + output = "HDMI-0"; + assign = [ + "Element" + "Signal" + "Discord" + ]; + }; + "" = { + key = "m"; + output = "HDMI-0"; + assign = ["Thunderbird"]; + }; + }; + }; + + keybindings = { + "${mod}+Shift+l" = "exec ${pkgs.swaylock-fancy}/bin/swaylock-fancy"; + + # Media Keys + "XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ '+10%'"; + "XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ '-10%'"; + "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify play-pause"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify next"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl -p spotify previous"; + + # Focus + "${mod}+Left" = "focus left"; + "${mod}+Right" = "focus right"; + "${mod}+Down" = "focus down"; + "${mod}+Up" = "focus up"; + "${mod}+Shift+Left" = "move left"; + "${mod}+Shift+Right" = "move right"; + "${mod}+Shift+Down" = "move down"; + "${mod}+Shift+Up" = "move up"; + + # Layout + "${mod}+u" = "fullscreen toggle"; + "${mod}+comma" = "layout tabbed"; + + # Misc + "${mod}+Shift+colon" = "kill"; + "${mod}+Shift+J" = "reload"; + "${mod}+Return" = "exec ${config.terminal.command}"; + "${mod}+p" = "mode resize"; + "${mod}+Shift+P" = "restart"; + }; + }; } diff --git a/wm/i3.nix b/wm/i3.nix index 1b9312b..810518c 100644 --- a/wm/i3.nix +++ b/wm/i3.nix @@ -1,28 +1,38 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with builtins; -with lib; -let +with lib; let cfg = config.wm; - common = import ./i3like-utils.nix { inherit config; }; + common = import ./i3like-utils.nix {inherit config;}; startupNotifications = - if cfg.notifications.enable then [{ - command = "${config.services.dunst.package}/bin/dunst"; - notification = false; - always = true; - }] else [ ]; + if cfg.notifications.enable + then [ + { + command = "${config.services.dunst.package}/bin/dunst"; + notification = false; + always = true; + } + ] + else []; wallpaperSet = - if cfg.wallpaper != null then [{ - command = "${pkgs.feh}/bin/feh --bg-scale ${cfg.wallpaper}"; - always = true; - notification = false; - }] else [ ]; + if cfg.wallpaper != null + then [ + { + command = "${pkgs.feh}/bin/feh --bg-scale ${cfg.wallpaper}"; + always = true; + notification = false; + } + ] + else []; startup = startupNotifications ++ wallpaperSet ++ cfg.startup; -in -{ +in { config = mkIf (cfg.enable && cfg.kind == "i3") { programs = { i3status-rust = { @@ -99,14 +109,15 @@ in assigns = common.assigns; fonts = common.mkFont cfg.font; modifier = cfg.modifier; - bars = [{ - fonts = common.mkFont cfg.bar.font; - statusCommand = "${config.programs.i3status-rust.package}/bin/i3status-rs ${config.home.homeDirectory}/.config/i3status-rust/config-bottom.toml"; - }]; + bars = [ + { + fonts = common.mkFont cfg.bar.font; + statusCommand = "${config.programs.i3status-rust.package}/bin/i3status-rs ${config.home.homeDirectory}/.config/i3status-rust/config-bottom.toml"; + } + ]; }; }; scriptPath = ".hm-xsession"; }; - }; } diff --git a/wm/i3like-utils.nix b/wm/i3like-utils.nix index 075aaab..c6d5670 100644 --- a/wm/i3like-utils.nix +++ b/wm/i3like-utils.nix @@ -1,47 +1,48 @@ -{ config }: - -with builtins; -let +{config}: +with builtins; let cfg = config.wm; - addKeyIf = cond: keybinds: newkey: if cond then newkey // keybinds else keybinds; + addKeyIf = cond: keybinds: newkey: + if cond + then newkey // keybinds + else keybinds; - keybindSolo = keys: submod: addKeyIf submod.enable keys { - "${submod.keybind}" = "exec ${submod.command}"; - }; - keydefs = [ cfg.printScreen cfg.menu cfg.exit ]; + keybindSolo = keys: submod: + addKeyIf submod.enable keys { + "${submod.keybind}" = "exec ${submod.command}"; + }; + keydefs = [cfg.printScreen cfg.menu cfg.exit]; keybindingsKeydef = foldl' keybindSolo cfg.keybindings keydefs; mod = cfg.modifier; ws_def = cfg.workspaces.definitions; get_ws = ws: getAttr ws ws_def; - workspaceFmt = name: - let key = (get_ws name).key; in - { - "${mod}+${key}" = "workspace ${name}"; - "${mod}+${cfg.workspaces.moveModifier}+${key}" = "move container to workspace ${name}"; - }; + workspaceFmt = name: let + key = (get_ws name).key; + in { + "${mod}+${key}" = "workspace ${name}"; + "${mod}+${cfg.workspaces.moveModifier}+${key}" = "move container to workspace ${name}"; + }; - workspaceAssign = name: - { - workspace = name; - output = (get_ws name).output; - }; + workspaceAssign = name: { + workspace = name; + output = (get_ws name).output; + }; classAssign = name: { - "${name}" = map (app: { class = "${app}"; }) ((get_ws name).assign); + "${name}" = map (app: {class = "${app}";}) ((get_ws name).assign); }; -in -{ +in { mkFont = mod: { - names = [ mod.name ]; + names = [mod.name]; style = mod.style; size = mod.size; }; - keybindings = (foldl' (x: y: x // y) { } (map workspaceFmt (attrNames ws_def))) + keybindings = + (foldl' (x: y: x // y) {} (map workspaceFmt (attrNames ws_def))) // keybindingsKeydef; workspaceOutputAssign = map workspaceAssign (filter (ws: (get_ws ws).output != null) (attrNames ws_def)); - assigns = foldl' (x: y: x // y) { } (map classAssign (attrNames ws_def)); + assigns = foldl' (x: y: x // y) {} (map classAssign (attrNames ws_def)); } diff --git a/wm/i3like.nix b/wm/i3like.nix index a7d5a9f..eed0c79 100644 --- a/wm/i3like.nix +++ b/wm/i3like.nix @@ -1,9 +1,12 @@ -{ config, lib, pkgs, ... }: - -with builtins; -with lib; { - imports = [ ./i3.nix ./sway.nix ]; + config, + lib, + pkgs, + ... +}: +with builtins; +with lib; { + imports = [./i3.nix ./sway.nix]; options = { wm = { @@ -13,7 +16,7 @@ with lib; description = "Manage window Manager"; }; kind = mkOption { - type = types.enum [ "i3" "sway" ]; + type = types.enum ["i3" "sway"]; default = "sway"; description = "WM to use"; }; @@ -156,12 +159,12 @@ with lib; assign = mkOption { type = types.listOf types.str; description = "Assign class elements"; - default = [ ]; + default = []; }; }; }); description = "Workspace descriptions"; - default = { }; + default = {}; }; moveModifier = mkOption { type = types.str; diff --git a/wm/sway.nix b/wm/sway.nix index 9223928..592b100 100644 --- a/wm/sway.nix +++ b/wm/sway.nix @@ -1,25 +1,36 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; -with builtins; -let +with builtins; let cfg = config.wm; - common = import ./i3like-utils.nix { inherit config; }; + common = import ./i3like-utils.nix {inherit config;}; startupNotifications = - if cfg.notifications.enable then [{ - command = "${pkgs.mako}/bin/mako"; - always = true; - }] else [ ]; + if cfg.notifications.enable + then [ + { + command = "${pkgs.mako}/bin/mako"; + always = true; + } + ] + else []; startup = startupNotifications ++ cfg.startup; -in -{ +in { config = mkIf (cfg.enable && cfg.kind == "sway") { - - home.packages = with pkgs; [ - sway - ] ++ (if cfg.wallpaper != null then [ pkgs.swaybg ] else [ ]); + home.packages = with pkgs; + [ + sway + ] + ++ ( + if cfg.wallpaper != null + then [pkgs.swaybg] + else [] + ); home.sessionVariables = { MOZ_ENABLE_WAYLAND = "1"; @@ -47,7 +58,7 @@ in "sway/workspaces" "sway/mode" ]; - modules-center = [ "sway/window" ]; + modules-center = ["sway/window"]; modules-right = [ "cpu" "memory" @@ -60,9 +71,9 @@ in modules = { "sway/workspaces" = { persistent_workspaces = { - "" = [ ]; - "" = [ ]; - "1:" = [ ]; + "" = []; + "" = []; + "1:" = []; }; numeric-first = true; }; @@ -89,7 +100,7 @@ in }; "battery" = { format = "{capacity}% {icon}"; - format-icons = [ "" "" "" "" "" ]; + format-icons = ["" "" "" "" ""]; }; "clock" = { format-alt = "{:%a, %d. %b %H:%M}"; @@ -104,39 +115,44 @@ in wm.menu.command = mkDefault "${pkgs.wofi}/bin/wofi --show drun,run --allow-images"; wm.exit.command = mkDefault "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'"; - - wayland.windowManager.sway = { enable = true; extraConfig = mkIf (cfg.wallpaper != null) '' - output "*" bg ${cfg.wallpaper} fill - ''; + output "*" bg ${cfg.wallpaper} fill + ''; config = { inherit startup; modifier = cfg.modifier; - bars = [{ - command = "waybar"; - }]; - input = - let - inputs = config.extraInfo.inputs; - inputsCfg = [ - (if inputs.keyboard != null then { + bars = [ + { + command = "waybar"; + } + ]; + input = let + inputs = config.extraInfo.inputs; + inputsCfg = [ + ( + if inputs.keyboard != null + then { name = inputs.keyboard; - value = - { - xkb_layout = "us"; - xkb_variant = "dvp"; - xkb_options = "compose:102"; - }; - - } else null) - (if inputs.touchpad != null then { + value = { + xkb_layout = "us"; + xkb_variant = "dvp"; + xkb_options = "compose:102"; + }; + } + else null + ) + ( + if inputs.touchpad != null + then { name = inputs.touchpad; - value = { dwt = "disable"; }; - } else null) - ]; - in + value = {dwt = "disable";}; + } + else null + ) + ]; + in builtins.listToAttrs inputsCfg; fonts = common.mkFont cfg.font; window = { @@ -146,7 +162,6 @@ in workspaceOutputAssign = common.workspaceOutputAssign; assigns = common.assigns; }; - }; home.file = { diff --git a/wm/terminal/default.nix b/wm/terminal/default.nix index 9c1c8f4..93122b9 100644 --- a/wm/terminal/default.nix +++ b/wm/terminal/default.nix @@ -1,19 +1,23 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; -with builtins; - -let - mkColor = mkOption { type = types.nullOr types.str; default = null; }; +with builtins; let + mkColor = mkOption { + type = types.nullOr types.str; + default = null; + }; mkColorPair = { normal = mkColor; bright = mkColor; }; cfg = config.terminal; cCfg = cfg.colors; -in -{ - imports = [ ./foot.nix ./kitty.nix ]; +in { + imports = [./foot.nix ./kitty.nix]; options = { terminal = { @@ -23,7 +27,7 @@ in description = "Manage terminal"; }; kind = mkOption { - type = types.enum [ "foot" "kitty" ]; + type = types.enum ["foot" "kitty"]; default = "foot"; description = "The terminal to be used"; }; diff --git a/wm/terminal/foot.nix b/wm/terminal/foot.nix index b440d96..1954333 100644 --- a/wm/terminal/foot.nix +++ b/wm/terminal/foot.nix @@ -1,55 +1,56 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; -with builtins; - -let +with builtins; let cfg = config.terminal; cCfg = cfg.colors; -in - -{ +in { config = mkIf (cfg.enable && cfg.kind == "foot") { - terminal.command = mkDefault "${pkgs.foot}/bin/foot"; + terminal.command = mkDefault "${pkgs.foot}/bin/foot"; programs.foot = { enable = true; settings = { - colors = - let - colorCfg = value: mkIf (value != null) value; - colorCfgNormal = color: colorCfg color.normal; - colorCfgBright = color: if color.bright != null then color.bright else colorCfgNormal color; - in - { - background = colorCfg cCfg.background; - foreground = colorCfg cCfg.foreground; + colors = let + colorCfg = value: mkIf (value != null) value; + colorCfgNormal = color: colorCfg color.normal; + colorCfgBright = color: + if color.bright != null + then color.bright + else colorCfgNormal color; + in { + background = colorCfg cCfg.background; + foreground = colorCfg cCfg.foreground; - regular0 = colorCfgNormal cCfg.black; - bright0 = colorCfgBright cCfg.black; + regular0 = colorCfgNormal cCfg.black; + bright0 = colorCfgBright cCfg.black; - regular1 = colorCfgNormal cCfg.red; - bright1 = colorCfgBright cCfg.red; + regular1 = colorCfgNormal cCfg.red; + bright1 = colorCfgBright cCfg.red; - regular2 = colorCfgNormal cCfg.green; - bright2 = colorCfgBright cCfg.green; + regular2 = colorCfgNormal cCfg.green; + bright2 = colorCfgBright cCfg.green; - regular3 = colorCfgNormal cCfg.yellow; - bright3 = colorCfgBright cCfg.yellow; + regular3 = colorCfgNormal cCfg.yellow; + bright3 = colorCfgBright cCfg.yellow; - regular4 = colorCfgNormal cCfg.blue; - bright4 = colorCfgBright cCfg.blue; + regular4 = colorCfgNormal cCfg.blue; + bright4 = colorCfgBright cCfg.blue; - regular5 = colorCfgNormal cCfg.magenta; - bright5 = colorCfgBright cCfg.magenta; + regular5 = colorCfgNormal cCfg.magenta; + bright5 = colorCfgBright cCfg.magenta; - regular6 = colorCfgNormal cCfg.cyan; - bright6 = colorCfgBright cCfg.cyan; + regular6 = colorCfgNormal cCfg.cyan; + bright6 = colorCfgBright cCfg.cyan; - regular7 = colorCfgNormal cCfg.white; - bright7 = colorCfgBright cCfg.white; + regular7 = colorCfgNormal cCfg.white; + bright7 = colorCfgBright cCfg.white; - selection-foreground = colorCfg cCfg.selectionForeground; - }; + selection-foreground = colorCfg cCfg.selectionForeground; + }; main = { font = "${cfg.font.family}:size=${toString cfg.font.size}"; }; diff --git a/wm/terminal/kitty.nix b/wm/terminal/kitty.nix index bdb038f..6316759 100644 --- a/wm/terminal/kitty.nix +++ b/wm/terminal/kitty.nix @@ -1,14 +1,14 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: with lib; -with builtins; - -let +with builtins; let cfg = config.terminal; cCfg = cfg.colors; -in - -{ +in { config = mkIf (cfg.enable && cfg.kind == "kitty") { terminal.command = mkDefault "${pkgs.kitty}/bin/kitty"; programs.kitty = { @@ -17,42 +17,43 @@ in name = cfg.font.family; size = cfg.font.size; }; - settings = - let - colorCfg = value: mkIf (value != null) "#${value}"; - colorCfgNormal = color: colorCfg color.normal; - colorCfgBright = color: if color.bright != null then "#${color.bright}" else colorCfgNormal color; - in - { - background = colorCfg cCfg.background; - foreground = colorCfg cCfg.foreground; + settings = let + colorCfg = value: mkIf (value != null) "#${value}"; + colorCfgNormal = color: colorCfg color.normal; + colorCfgBright = color: + if color.bright != null + then "#${color.bright}" + else colorCfgNormal color; + in { + background = colorCfg cCfg.background; + foreground = colorCfg cCfg.foreground; - color0 = colorCfgNormal cCfg.black; - color8 = colorCfgBright cCfg.black; + color0 = colorCfgNormal cCfg.black; + color8 = colorCfgBright cCfg.black; - color1 = colorCfgNormal cCfg.red; - color9 = colorCfgBright cCfg.red; + color1 = colorCfgNormal cCfg.red; + color9 = colorCfgBright cCfg.red; - color2 = colorCfgNormal cCfg.green; - color10 = colorCfgBright cCfg.green; + color2 = colorCfgNormal cCfg.green; + color10 = colorCfgBright cCfg.green; - color3 = colorCfgNormal cCfg.yellow; - color11 = colorCfgBright cCfg.yellow; + color3 = colorCfgNormal cCfg.yellow; + color11 = colorCfgBright cCfg.yellow; - color4 = colorCfgNormal cCfg.blue; - color12 = colorCfgBright cCfg.blue; + color4 = colorCfgNormal cCfg.blue; + color12 = colorCfgBright cCfg.blue; - color5 = colorCfgNormal cCfg.magenta; - color13 = colorCfgBright cCfg.magenta; + color5 = colorCfgNormal cCfg.magenta; + color13 = colorCfgBright cCfg.magenta; - color6 = colorCfgNormal cCfg.cyan; - color14 = colorCfgBright cCfg.cyan; + color6 = colorCfgNormal cCfg.cyan; + color14 = colorCfgBright cCfg.cyan; - color7 = colorCfgNormal cCfg.white; - color15 = colorCfgBright cCfg.white; + color7 = colorCfgNormal cCfg.white; + color15 = colorCfgBright cCfg.white; - selection_foreground = colorCfg cCfg.selectionForeground; - }; + selection_foreground = colorCfg cCfg.selectionForeground; + }; }; wayland.windowManager.sway.config.terminal = "${config.terminal.command}"; xsession.windowManager.i3.config.terminal = "${config.terminal.command}";