From 67073eb3dea5e33d23d1dba6c42fae7aabcf1ea0 Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Mon, 10 Jan 2022 09:53:42 +0100 Subject: [PATCH] initial commit --- alacritty.nix | 39 ++++++++ colors.nix | 101 +++++++++++++++++++ configuration.nix | 128 ++++++++++++++++++++++++ display.nix | 194 +++++++++++++++++++++++++++++++++++++ fonts.nix | 40 ++++++++ forks/i3-gaps-rounded.nix | 50 ++++++++++ git.nix | 15 +++ hardware-configuration.nix | 34 +++++++ kakoune.nix | 45 +++++++++ 9 files changed, 646 insertions(+) create mode 100644 alacritty.nix create mode 100644 colors.nix create mode 100644 configuration.nix create mode 100644 display.nix create mode 100644 fonts.nix create mode 100644 forks/i3-gaps-rounded.nix create mode 100644 git.nix create mode 100644 hardware-configuration.nix create mode 100644 kakoune.nix diff --git a/alacritty.nix b/alacritty.nix new file mode 100644 index 0000000..7fad0a4 --- /dev/null +++ b/alacritty.nix @@ -0,0 +1,39 @@ +{ pkgs, config, ... }: + +{ + home-manager.users."riley" = { + programs.alacritty = { + enable = true; + settings = { + + window.padding = { x = 8; y = 8; }; + + font = { + normal = { family = "Fira Code"; style = "Regular"; }; + bold = { family = "Fira Code"; style = "Medium"; }; + }; + + colors = let theme = (import ./colors.nix)."dark"; in { + + primary = { + background = "#" + theme.background.primary; + foreground = "#" + theme.foreground.primary; + }; + + normal = { + red = "#" + theme.red.normal; + blue = "#" + theme.blue.normal; + magenta = "#" + theme.purple.normal; + }; + + bright = { + red = "#" + theme.red.bright; + blue = "#" + theme.blue.bright; + magenta = "#" + theme.purple.bright; + }; + }; + }; + + }; + }; +} diff --git a/colors.nix b/colors.nix new file mode 100644 index 0000000..737d34f --- /dev/null +++ b/colors.nix @@ -0,0 +1,101 @@ +# Color schemes. + +{ + + # A simple dark theme with vibrant colors. + "dark" = rec { + + # Determines the background for applications such as the terminal, + # status bars or WM elements. + background = { + + primary = "1a1a1a"; + + normal = "212121"; + slight = "535353"; + + }; + + # Determines the foreground color of text. + foreground = { + + primary = "fafafa"; + + normal = "efefef"; + slight = "bdbdbd"; + + }; + + grayscales = [ + "121212" + background.primary + background.normal + "2a2a2a" + "323232" + "424242" + "4a4a4a" + background.slight + "646464" + "6a6a6a" + "757575" + "7a7a7a" + "868686" + "8a8a8a" + "979797" + "9a9a9a" + "a8a8a8" + "aaaaaa" + "b9b9b9" + foreground.slight + "cacaca" + "dadada" + "eaeaea" + foreground.normal + foreground.primary + ]; + + red = { + normal = "ff6161"; + bright = "ff3b3b"; + pastel = "ff8787"; + }; + + green = { + normal = ""; + bright = ""; + pastel = ""; + }; + + blue = { + normal = "3eafff"; + bright = "30c7ff"; + pastel = ""; + }; + + yellow = { + normal = ""; + bright = ""; + pastel = ""; + }; + + purple = { + normal = "bd78fa"; + bright = "dda1ff"; + pastel = ""; + }; + + cyan = { + normal = ""; + bright = ""; + pastel = ""; + }; + + orange = { + normal = ""; + bright = ""; + pastel = ""; + }; + + }; + +} diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..88b6795 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,128 @@ +# 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 = [ + + # Home-manager modules + + + ./hardware-configuration.nix + + # Programs + ./kakoune.nix + ./alacritty.nix + ./git.nix + + # Display server and related config + ./display.nix + ./fonts.nix + + ]; + + nixpkgs.config.allowUnfree = true; + nix.autoOptimiseStore = true; + nix.gc.automatic = true; + + boot = { + loader.systemd-boot = { + enable = true; + editor = false; + configurationLimit = 10; + }; + loader.efi.canTouchEfiVariables = true; + cleanTmpDir = true; + }; + + networking.hostName = "thor"; + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + # 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 + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.enp9s0.useDHCP = true; + + # 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"; + # }; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.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."riley" = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + + # Some utils + + wget + curl + git + + # Modern coreutils + + ripgrep + bottom + skim + exa + bat + lf + fd + + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.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. It‘s 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 = "21.11"; # Did you read the comment? + +} + diff --git a/display.nix b/display.nix new file mode 100644 index 0000000..e9f4995 --- /dev/null +++ b/display.nix @@ -0,0 +1,194 @@ +{ pkgs, config, lib, ... }: + +let theme = (import ./colors.nix)."dark"; + hex = (c: "#${c}"); + + # Keybinds that launch an application. + launchers = ({ browser }: mod: { + "${mod}+Tab" = "exec ${browser}"; + }); + + # Keybinds generated from a set of workspaces. + workspace = ({ numbered ? 0, named ? {} }: mod: with lib; + let nums = genAttrs (map toString (range 1 numbered)) id; + workspaces = named // nums; + genBinds = (n: k: { + + # Focus the workspace + "${mod}+${k}" = "workspace ${n}"; + + # Move a window to the workspace + "${mod}+Shift+${k}" = "move window to workspace ${n}"; + + }); + keybinds = mapAttrsToList genBinds workspaces; in + mkMerge (keybinds) + ); + + # Layout manipulation keybinds. + layout = (mod: { + + "${mod}+A" = "split v"; + "${mod}+S" = "split h"; + + "${mod}+F" = "fullscreen toggle"; + + }); + + # Directional keys are used for basic navigation. + directional = ({ left, right, up, down }: mod: { + + # Change window focus + "${mod}+${left}" = "focus left"; + "${mod}+${down}" = "focus down"; + "${mod}+${up}" = "focus up"; + "${mod}+${right}" = "focus right"; + + # Move windows + "${mod}+Shift+${left}" = "move left"; + "${mod}+Shift+${down}" = "move down"; + "${mod}+Shift+${up}" = "move up"; + "${mod}+Shift+${right}" = "move right"; + + }); + + # Media controls. + media = ({ mpc ? null }: mod: + if (mpc != null) + then (let cmd = "${mpc}/bin/${mpc.pname}"; in { + "${mod}+comma" = "exec ${cmd} prev"; + "${mod}+period" = "exec ${cmd} next"; + "${mod}+slash" = "exec ${cmd} toggle"; + }) + else {} + ); + + # Utility scripts and such. + scripts = (mod: {}); in + +{ + + services.xserver = { + enable = true; + windowManager.i3 = { + enable = true; + package = pkgs.i3; #-gaps; + }; + }; + + home-manager.users."riley" = + let browser = pkgs.google-chrome; + term = pkgs.alacritty; in + { + + home.packages = with pkgs; [ + + tdesktop + + xclip + + # Paste from clipboard + (writeShellApplication { + name = "xc.p"; + runtimeInputs = [ xclip ]; + text = "xclip -sel clip -o"; + }) + + # Copy to clipboard + (writeShellApplication { + name = "xc.c"; + runtimeInputs = [ xclip ]; + text = "xclip -sel clip -i"; + }) + + # Copy to clipboard with given mime type + (writeShellApplication { + name = "xc.t"; + runtimeInputs = [ xclip ]; + text = "xclip -sel clip -t \"$1\" -i"; + }) + + ] ++ [ + term + browser + ]; + + xsession.windowManager.i3 = { + enable = true; + + package = pkgs.i3; + + config = with lib; (rec { + + modifier = "Mod4"; + terminal = "${term}/bin/${term.pname}"; + + # Apply the modifier key to each of the keybinding generator functions + # and merge the resulting sets. + keybindings = let mod = modifier; in mkMerge (map (f: f (mod)) [ + (mod: { + "${mod}+Return" = "exec ${terminal}"; + "${mod}+BackSpace" = "kill"; + }) + (directional { + left = "H"; + right = "L"; + down = "J"; + up = "K"; + }) + (workspace { + numbered = 5; + named = { + "dev" = "0"; + "doc" = "minus"; + "net" = "equal"; + }; + }) + (launchers { + browser = "google-chrome-stable"; + }) + layout + (media { + mpc = pkgs.mpc_cli; + }) + scripts + ]); + + colors = { + focused = rec { + background = hex (theme.background.normal); + text = hex (theme."red".bright); + border = background; + childBorder = border; + indicator = border; + }; + unfocused = rec { + background = hex (theme.background.normal); + text = hex (theme.foreground.slight); + border = background; + childBorder = border; + indicator = border; + }; + focusedInactive = colors.unfocused; + }; + + window = { + border = 2; + commands = [ + { command = "border pixel 2"; criteria = { class = ".*"; }; } + ]; + }; + + fonts = { + names = [ "Source Sans 3" ]; + style = "Semibold"; + size = 10.0; + }; + + }); + + }; + + }; + +} diff --git a/fonts.nix b/fonts.nix new file mode 100644 index 0000000..14cd8b5 --- /dev/null +++ b/fonts.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: + +{ + fonts = { + + fonts = with pkgs; [ + twemoji-color-font + inter + source-code-pro + source-sans-pro + source-serif-pro + fira-code + fira-mono + fira + noto-fonts-emoji + hasklig + ]; + + fontconfig = { + enable = true; + defaultFonts = { + monospace = [ + "Fira Mono" + "Source Code Pro" + "Noto Color Emoji" + ]; + sansSerif = [ + "Source Sans" + ]; + serif = [ + "Source Serif" + ]; + emoji = [ + "Twitter Color Emoji" + ]; + }; + }; + + }; +} diff --git a/forks/i3-gaps-rounded.nix b/forks/i3-gaps-rounded.nix new file mode 100644 index 0000000..b5862e5 --- /dev/null +++ b/forks/i3-gaps-rounded.nix @@ -0,0 +1,50 @@ +{ + fetchFromGitHub, lib, stdenv, pkg-config, installShellFiles, libxcb, + xcbutilkeysyms, xcbutil, xcbutilwm, xcbutilxrm, libstartup_notification, libX11, pcre, + libev, yajl, xcb-util-cursor, perl, pango, perlPackages, libxkbcommon, xorgserver, + xvfb-run, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, findXMLCatalogs, + autoconf, autoreconfHook +}: + +with stdenv; mkDerivation rec { + pname = "i3-gaps-rounded"; + version = "4.16.1-non-git"; + + src = fetchFromGitHub { + owner = "resloved"; + repo = "i3"; + rev = "b521c18ca1bca1c16d3fd69214ad3972bffc9e42"; + sha256 = "0w4akd7mkdm4xlv2ai2hyjn45f1qgzj5g6n09hrcns1zv4nffcch"; + }; + + nativeBuildInputs = [ + pkg-config + installShellFiles + perl + asciidoc + xmlto + docbook_xml_dtd_45 + docbook_xsl + findXMLCatalogs + autoreconfHook + ]; + + buildInputs = [ + libxcb xcbutilkeysyms xcbutil xcbutilwm xcbutilxrm libxkbcommon + libstartup_notification libX11 pcre libev yajl xcb-util-cursor perl pango + perlPackages.AnyEventI3 perlPackages.X11XCB perlPackages.IPCRun + perlPackages.ExtUtilsPkgConfig perlPackages.InlineC + xorgserver xvfb-run + ]; + + doCheck = false; + + postPatch = '' + patchShebangs . + ''; + + buildPhase = '' + cd x86_64-pc-linux-gnu + make all + ''; +} diff --git a/git.nix b/git.nix new file mode 100644 index 0000000..a606ad4 --- /dev/null +++ b/git.nix @@ -0,0 +1,15 @@ +{ pkgs, config, ... }: + +{ + home-manager.users."riley".programs.git = { + enable = true; + + userEmail = "me@riley.lgbt"; + userName = "Riley Apeldoorn"; + + extraConfig = { + pull.rebase = false; + init.defaultBranch = "mistress"; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..0c46e4d --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,34 @@ +# 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/f3cdd2ab-62ba-4d72-8a28-b3adc0ec3997"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/3691-F2E6"; + fsType = "vfat"; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/e317d7a7-c11c-4f3a-afda-0fd949f5633c"; + fsType = "btrfs"; + }; + + swapDevices = [ { label = "swap"; } ]; + + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/kakoune.nix b/kakoune.nix new file mode 100644 index 0000000..7ddb17c --- /dev/null +++ b/kakoune.nix @@ -0,0 +1,45 @@ +{ lib, pkgs, ... }: + +let kakrc = pkgs.writeTextFile (rec { + name = "kakrc.kak"; + destination = "/share/kak/autoload/${name}"; + text = '' + add-highlighter global/ number-lines -separator ' │ ' -hlcursor + set-option global tabstop 4 + set global ui_options ncurses_assistant=cat + map global normal :buffer-next + eval %sh{ kak-lsp --kakoune -s $kak_session } + ''; + }); + theme = let x = (import ./colors.nix)."dark"; in pkgs.writeTextFile (rec { + name = "theme.kak"; + destination = "/share/kak/autoload/${name}"; + text = '' + face global LineNumbers rgb:${x.background.slight} + face global BufferPadding rgb:${x.background.slight} + face global LineNumberCursor rgb:${x.foreground.primary} + face global crosshairs_line "default,rgb:${x.background.normal}" + face global MenuForeground "default,blue" + face global MenuBackground "default,rgb:313131" + face global InlayHint rgb:828282 + + face global comment rgb:${x.background.slight} + ''; + }); +in { + environment.systemPackages = with pkgs; [ + (pkgs.kakoune.override { + plugins = with kakounePlugins; [ + + # Custom config + kakrc + theme + + # Kakoune language server support + kak-lsp + + ]; + }) + rnix-lsp + ]; +}