diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..b7b7e12 --- /dev/null +++ b/LICENCE @@ -0,0 +1,30 @@ +Copyright Wanja Chresta (c) 2022 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Wanja Chresta nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/home-manager/.gitignore b/home-manager/.gitignore new file mode 100644 index 0000000..e676596 --- /dev/null +++ b/home-manager/.gitignore @@ -0,0 +1 @@ +**/secret.* diff --git a/home-manager/flake.nix b/home-manager/flake.nix new file mode 100644 index 0000000..f189998 --- /dev/null +++ b/home-manager/flake.nix @@ -0,0 +1,24 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs"; + + light-control-flake.url = "light-control"; + light-control-flake.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ self, ... }: { + homeConfiguration = args@{ ... }: { + imports = [ ./home.nix ]; + + nixpkgs = { + overlays = [ + (final: prev: + if inputs ? light-control-flake then { + light-control = inputs.light-control-flake.packages.${prev.system}.light-control; + } else {} + ) + ]; + }; + }; + }; +} \ No newline at end of file diff --git a/home-manager/gruvbox.nix b/home-manager/gruvbox.nix new file mode 100644 index 0000000..8f64d2d --- /dev/null +++ b/home-manager/gruvbox.nix @@ -0,0 +1,46 @@ +{ ... }: + +{ + dark0_hard = "#1d2021"; + dark0 = "#282828"; + dark0_soft = "#32302f"; + dark1 = "#3c3836"; + dark2 = "#504945"; + dark3 = "#665c54"; + dark4 = "#7c6f64"; + + gray_245 = "#928374"; + gray_244 = "#928374"; + + light0_hard = "#fb4934"; + light0 = "#fbf1c7"; + light0_soft = "#f2e5bc"; + light1 = "#ebdbb2"; + light2 = "#d5c4a1"; + light3 = "#bdae93"; + light4 = "#a89984"; + + bright_red = "#fb4934"; + bright_green = "#b8bb26"; + bright_yellow = "#fabd2f"; + bright_blue = "#83a598"; + bright_purple = "#d3869b"; + bright_aqua = "#8ec07c"; + bright_orange = "#fe8019"; + + neutral_red = "#cc241d"; + neutral_green = "#98971a"; + neutral_yellow = "#d79921"; + neutral_blue = "#458588"; + neutral_purple = "#b16286"; + neutral_aqua = "#689d6a"; + neutral_orange = "#d65d0e"; + + faded_red = "#9d0006"; + faded_green = "#79740e"; + faded_yellow = "#b57614"; + faded_blue = "#076678"; + faded_purple = "#8f3f71"; + faded_aqua = "#427b58"; + faded_orange = "#af3a03"; +} diff --git a/home-manager/home.nix b/home-manager/home.nix new file mode 100644 index 0000000..83b5f59 --- /dev/null +++ b/home-manager/home.nix @@ -0,0 +1,92 @@ +{ config, lib, pkgs, ... }: + +#let +# windowManager = pkgs.callPackage ./home-manager/windowManager.nix { inherit light-control; }; +#in windowManager // +{ + imports = + [ + includes/kitty.nix + includes/vim.nix + includes/firefox.nix + includes/development.nix + includes/windowManager.nix + ]; + + nixpkgs.config.allowUnfree = true; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = "monoid"; + home.homeDirectory = "/home/monoid"; + + home.keyboard = { + layout = "ch"; + }; + + home.sessionPath = [ ".local/bin" ]; + + home.packages = with pkgs; [ + ripgrep + pavucontrol + pulseaudio # for pactl + lutris + fceux # emulator + glirc + ]; + + gtk = { + enable = false; + theme = { + package = pkgs.gnome.gnome_themes_standard; + name = "Adwaita-Dark"; + }; + }; + + home.file = { + ".local/bin/rise-of-industry" = { + executable = true; + text = '' + #!/usr/bin/env bash + cd "$HOME/Games/Rise of Industry/" + steam-run ./start.sh + ''; + }; + }; + + programs.bash = { + enable = true; + + initExtra = '' + PROMPT_COLOR="0;34m" + export PS1="\[\033[$PROMPT_COLOR\]\[\e]0;\u@\h: \w\a\]\u:\w\\$\[\033[0m\] " + ''; + + shellAliases = { + ehome = '' + ${pkgs.neovim}/bin/nvim -O ~/src/dotconf/home-manager/home.nix ~/src/dotconf/home-manager/includes && \ + ${pkgs.git}/bin/git -C ~/src/dotconf/home-manager commit -a -m "Changes by monoid" && \ + sudo nixos-rebuild switch --update-input monoid-home + ''; + enix = '' + sudo -E ${pkgs.neovim}/bin/nvim -O /etc/nixos/configuration.nix /etc/nixos/includes/ && \ + sudo rebuildAndCommitSystem + ''; + }; + }; + + # 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 + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "20.09"; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = false; +} + +# vim: set sw=2 expandtabs=2 tabstop=2 diff --git a/home-manager/includes/development.nix b/home-manager/includes/development.nix new file mode 100644 index 0000000..ce1ca1a --- /dev/null +++ b/home-manager/includes/development.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +{ + home.packages = with pkgs; [ + ghc + go + ]; + + programs.git = { + enable = true; + + userEmail = "34962284+wchresta@users.noreply.github.com"; + userName = "wchresta"; + + extraConfig = { + core = { + editor = "nvim"; + }; + + pull = { + rebase = true; + }; + }; + }; + + programs.vscode = { + enable = true; + extensions = with pkgs.vscode-extensions; [ + ms-vscode.cpptools + ]; + }; +} diff --git a/home-manager/includes/firefox.nix b/home-manager/includes/firefox.nix new file mode 100644 index 0000000..4facd50 --- /dev/null +++ b/home-manager/includes/firefox.nix @@ -0,0 +1,48 @@ +{ pkgs, ... }: + +{ + programs.firefox = { + enable = true; + + profiles.main-profile = { + isDefault = true; + name = "main-profile"; + + settings = { + "browser.search.widget.inNavBar" = true; + "datareporting.policy.dataSubmissionPolicyAcceptedVersion" = 2; + "media.videocontrols.picture-in-picture.allow-multiple" = false; + "media.videocontrols.picture-in-picture.enabled" = false; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + }; + + userChrome = '' + @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); + + /* Recreates the basic functionality of the popular Roomy Bookmarks Toolbar add-on: + Hide bookamrks bar items label text, show on hover. */ + + .bookmark-item { + height: 16px !important; + margin: -2px 0 !important; + padding: 0 2px !important; + } + .bookmark-item > .toolbarbutton-text { + margin-top: -1px !important; + } + .bookmark-item:not(:hover):not([open="true"]) > .toolbarbutton-text { + display: none !important; + } + .bookmark-item > .toolbarbutton-icon { + height: 16px !important; + width: 16px !important; + margin: -2px 0 -2px 0 !important; + padding: 0px !important; + } + #PlacesToolbarItems > .bookmark-item:not(:hover):not([open="true"]) > .toolbarbutton-icon[label]:not([label=""]) { + margin-inline-end: 0px !important; + } + ''; + }; + }; +} diff --git a/home-manager/includes/kitty.nix b/home-manager/includes/kitty.nix new file mode 100644 index 0000000..b84bc89 --- /dev/null +++ b/home-manager/includes/kitty.nix @@ -0,0 +1,62 @@ +{ pkgs, ... }: + +let + gruvbox = import ../gruvbox.nix {}; +in { + programs.kitty = { + enable = true; + + font.package = pkgs.fira-code; + font.name = "Fira Code Regular 12"; + + settings = { + background = gruvbox.dark0; + foreground = gruvbox.light1; + + selection_background = gruvbox.light1; + selection_foreground = gruvbox.dark0; + + cursor = gruvbox.light4; + cursor_text_color = "background"; + + active_tab_background = gruvbox.dark0; + active_tab_foreground = gruvbox.light1; + active_tab_font_style = "bold"; + inactive_tab_background = gruvbox.dark0; + inactive_tab_foreground = gruvbox.light4; + inactive_tab_font_style = "normal"; + + # Black + color0 = gruvbox.dark3; + color8 = gruvbox.gray_244; + + # Red + color1 = gruvbox.neutral_red; + color9 = gruvbox.bright_red; + + # Green + color2 = gruvbox.neutral_green; + color10 = gruvbox.bright_green; + + # Yellow + color3 = gruvbox.neutral_yellow; + color11 = gruvbox.bright_yellow; + + # Blue + color4 = gruvbox.neutral_blue; + color12 = gruvbox.bright_blue; + + # Magenta + color5 = gruvbox.neutral_purple; + color13 = gruvbox.bright_purple; + + # Cyan + color6 = gruvbox.neutral_aqua; + color14 = gruvbox.bright_aqua; + + # White + color7 = gruvbox.light1; + color15 = gruvbox.light1; + }; + }; +} diff --git a/home-manager/includes/vim.nix b/home-manager/includes/vim.nix new file mode 100644 index 0000000..8b62a01 --- /dev/null +++ b/home-manager/includes/vim.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: + +{ + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + + extraConfig = '' + syntax on + filetype plugin indent on + + set tabstop=2 + set shiftwidth=2 + set ai + set mouse=a + set hlsearch + let mapleader="," + let maplocalleader="," + + set termguicolors + let g:gruvbox_italic=1 + colorscheme gruvbox + ''; + + plugins = with pkgs.vimPlugins; [ + vim-nix + vim-go + gruvbox-nvim + ]; + }; +} diff --git a/home-manager/includes/windowManager.nix b/home-manager/includes/windowManager.nix new file mode 100644 index 0000000..5fab09e --- /dev/null +++ b/home-manager/includes/windowManager.nix @@ -0,0 +1,233 @@ +{ pkgs, lib, ... }: + +let + gruvbox = import ../gruvbox.nix {}; + + useCustomI3 = false; +in rec { + home.file.".local/bin/swapMonitors" = { + executable = true; + text = '' + #!${pkgs.bash}/bin/bash + + DISPLAY_CONFIG=($(i3-msg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[]|"\(.name):\(.current_workspace)"')) + + for ROW in "''${DISPLAY_CONFIG[@]}" + do + IFS=':' + read -ra CONFIG <<< "''${ROW}" + if [ "''${CONFIG[0]}" != "null" ] && [ "''${CONFIG[1]}" != "null" ]; then + echo "moving ''${CONFIG[1]} right..." + i3-msg -- workspace --no-auto-back-and-forth "''${CONFIG[1]}" + i3-msg -- move workspace to output right + fi + done + ''; + }; + + xsession.enable = true; + xsession.windowManager.i3 = rec { + enable = true; + + package = if useCustomI3 then + pkgs.i3-gaps.overrideAttrs (old: old // { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pcre2 ]; + src = ~/src/i3; + }) else pkgs.i3-gaps; + + + config = rec { + modifier = "Mod4"; + + terminal = "kitty"; + + gaps = { + inner = 5; + smartBorders = "on"; + smartGaps = true; + }; + + colors = { + background = gruvbox.dark1; + focused = { + border = gruvbox.dark3; + background = gruvbox.dark1; + childBorder = gruvbox.dark3; + indicator = gruvbox.dark3; + text = gruvbox.light1; + }; + focusedInactive = { + border = gruvbox.dark1; + background = gruvbox.dark1; + childBorder = gruvbox.dark1; + indicator = gruvbox.dark1; + text = gruvbox.light2; + }; + unfocused = { + border = gruvbox.dark1; + background = gruvbox.dark1; + childBorder = gruvbox.dark2; + indicator = gruvbox.light2; + text = gruvbox.light2; + }; + + }; + + bars = [ + { + mode = "dock"; + hiddenState = "hide"; + position = "bottom"; + workspaceButtons = true; + workspaceNumbers = true; + + statusCommand = "${pkgs.i3status}/bin/i3status"; + trayOutput = "primary"; + + fonts = { + names = [ "Fira Code Regular" ]; + size = 10.0; + }; + + colors = { + background = gruvbox.dark0; + statusline = gruvbox.light1; + separator = gruvbox.dark2; + + focusedWorkspace = { border = gruvbox.neutral_blue; background = gruvbox.neutral_blue; text = gruvbox.light1; }; + activeWorkspace = { border = gruvbox.bright_blue; background = gruvbox.bright_blue; text = gruvbox.light1; }; + inactiveWorkspace = { border = gruvbox.dark2; background = gruvbox.dark2; text = gruvbox.light1; }; + urgentWorkspace = { border = gruvbox.neutral_red; background = gruvbox.neutral_red; text = gruvbox.dark2; }; + }; + } + ]; + + startup = let + emre-flower = builtins.fetchurl { + name = "emre-flower.jpg"; + url = "https://unsplash.com/photos/EfyQXFzu8Nw/download"; + sha256 = "1ls6yg13nayjsr6i1dmi1kwhhfyidn0vjri0m076bpfjw85z9a6k"; + }; + in [ + { command = "${pkgs.xorg.xrandr}/bin/xrandr --output HDMI-0 --mode 1920x1080 --pos 0x1080 --output DP-4 --primary --mode 3840x2160 --pos 1920x0"; + notification = false; + } + { command = "${pkgs.feh}/bin/feh --bg-fill ${emre-flower}"; + notification = false; + } + ]; + + keybindings = let + mod = modifier; + + workspaces = map toString [1 2 3 4 5 6 7 8 9 0]; + mkMoveCmd = (ws: { + name = "${mod}+${ws}"; + value = "[workspace=${ws}] move workspace to output current, workspace ${ws}"; + }); + myMoves = builtins.listToAttrs (map mkMoveCmd workspaces); + in lib.mkOptionDefault ({ + "${mod}+x" = "exec kitty"; + "${mod}+d" = ''exec "rofi -show run -modi run,drun,ssh"''; + "${mod}+f" = "exec firefox"; + "${mod}+q" = "kill"; + "${mod}+space" = "fullscreen"; + "${mod}+p" = "exec --no-startup-id swapMonitors"; + + # Pulse Audio controls + "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; # increase sound volume + "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; # decrease sound volume + "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound + } // ( + # Only define light-control actions if it exists in pkgs. Otherwise, ignore it. + if pkgs ? light-control then { + # Hue light control + "XF86MonBrightnessUp" = "exec --no-startup-id ${pkgs.light-control}/bin/light-control bri-up"; + "XF86MonBrightnessDown" = "exec --no-startup-id ${pkgs.light-control}/bin/light-control bri-down"; + } else {} + ) // myMoves); + }; + }; + + programs.rofi = { + enable = true; + theme = "gruvbox-dark"; + }; + + programs.i3status = { + enable = true; + enableDefault = false; + + general = { + colors = true; + color_good = gruvbox.bright_green; + color_degraded = gruvbox.bright_purple; + color_bad = gruvbox.bright_red; + interval = 1; + }; + + modules = { + "volume master" = { + position = 1; + settings = { + format = "♪: %volume"; + format_muted = "♪: muted (%volume)"; + device = "default"; + mixer = "Master"; + mixer_idx = 0; + }; + }; + + ipv6 = { position = 2; }; + + /* + "wireless _first_" = { + position = 2; + settings = { + format_up = "W: (%quality at %essid) %ip"; + format_down = "W: down"; + }; + }; + */ + + "ethernet _first_" = { + position = 3; + settings = { + format_up = "E: %ip (%speed)"; + format_down = "E: down"; + }; + }; + + "disk /" = { + position = 5; + settings = { format = "/ %avail"; }; + }; + + "disk /home/monoid/otherhome/" = { + position = 6; + settings = { format = "~2 %avail"; }; + }; + + + load = { + position = 7; + settings = { format = "load %1min"; }; + }; + + memory = { + position = 8; + settings = { + format = "mem %used / %available"; + threshold_degraded = "1G"; + format_degraded = "MEMORY < %available"; + }; + }; + + "tztime local" = { + position = 9; + settings = { format = "%Y-%m-%d %H:%M:%S"; }; + }; + }; + }; +} +