~sumner/nixos-configuration

44573afc281ecf943a6303e24ef54246b2eacbd6 — Sumner Evans 8 months ago 18e36a3 home-manager
Made config a lot more sane
10 files changed, 115 insertions(+), 168 deletions(-)

M host-configurations/coruscant.nix
M host-configurations/jedha.nix
M host-configurations/mustafar/default.nix
D pkgs/sway-accel-rotate.nix
D services/clipmenu.nix
M services/default.nix
M services/window-manager/default.nix
M services/window-manager/i3wm.nix
D services/window-manager/picom.nix
M services/window-manager/sway.nix
M host-configurations/coruscant.nix => host-configurations/coruscant.nix +2 -0
@@ 2,4 2,6 @@
  # Set the hostname
  networking.hostName = "coruscant";
  hardware.ramSize = 32;
  xorg.enable = true;
  xorg.xkbVariant = "3l";
}

M host-configurations/jedha.nix => host-configurations/jedha.nix +3 -0
@@ 9,4 9,7 @@

  networking.interfaces.enp0s31f6.useDHCP = true;
  networking.interfaces.wlp4s0.useDHCP = true;

  xorg.enable = true;
  xorg.xkbVariant = "3l";
}

M host-configurations/mustafar/default.nix => host-configurations/mustafar/default.nix +1 -0
@@ 6,6 6,7 @@ in
  networking.hostName = "mustafar";
  hardware.ramSize = 8;
  hardware.isLaptop = true;
  wayland.enable = true;

  nixpkgs.overlays = [
    # sof-firmware so sleep works on Kohaku

D pkgs/sway-accel-rotate.nix => pkgs/sway-accel-rotate.nix +0 -14
@@ 1,14 0,0 @@
{ lib, pkgs }: with pkgs;
buildGoModule rec {
  pname = "sway-accel-rotate";
  version = "master";

  src = fetchFromGitHub {
    owner = "sumnerevans";
    repo = "sway-accel-rotate";
    rev = version;
    sha256 = "09m36l56zpwz8hl29dq55q7hmqyi9za2i3sa7yvddkxk0823c5ln";
  };

  vendorSha256 = "1m881s9vp4rsg7pajh03f204dqyn44hld0lgfnypz5gfhrzbs69c";
}

D services/clipmenu.nix => services/clipmenu.nix +0 -10
@@ 1,10 0,0 @@
{ config, pkgs, ... }:
{
  services.clipmenu.enable = true;

  # Force using rofi instead of dmenu.
  environment.variables = {
    CM_HISTLENGTH = "20";
    CM_LAUNCHER = "rofi";
  };
}

M services/default.nix => services/default.nix +0 -1
@@ 1,7 1,6 @@
{ config, pkgs, ... }:
{
  imports = [
    ./clipmenu.nix
    ./syncthing.nix
    ./window-manager/default.nix
  ];

M services/window-manager/default.nix => services/window-manager/default.nix +3 -17
@@ 1,22 1,11 @@
{ config, lib, pkgs, ... }: let
  editor = "${pkgs.neovim}/bin/nvim";
  terminal = "${pkgs.alacritty}/bin/alacritty";
  useSway = (lib.removeSuffix "\n" (builtins.readFile ./usesway)) == "Y";
in
{
  # Import the correct configs.
  imports = [ ./i3wm.nix ] ++ (if useSway then [ ./sway.nix ] else [ ./picom.nix ]);

  services.xbanish.enable = !useSway;

  environment.systemPackages = with pkgs; [
    arc-icon-theme
    arc-theme
    brightnessctl
    gnome-breeze
    rofi
    rofi-pass
    screenkey
  imports = [
    ./i3wm.nix
    ./sway.nix
  ];

  # Add some environment variables for when things get fired up with shortcuts


@@ 25,9 14,6 @@ in
    VISUAL = "${editor}";
    EDITOR = "${editor}";
    TERMINAL = "${terminal}";

    # Enable touchscreen in Firefox
    MOZ_USE_XINPUT2 = "1";
  };

  # Must have this for redshift or gammastep.

M services/window-manager/i3wm.nix => services/window-manager/i3wm.nix +61 -43
@@ 1,52 1,70 @@
{ config, pkgs, ... }: let
  isMustafar = config.networking.hostName == "mustafar";
{ config, lib, pkgs, ... }: with lib; let
  cfg = config.xorg;
in
{
  environment.systemPackages = with pkgs; [
    dunst
    flameshot
    lxappearance
    scrot
    xbindkeys
    xclip
    xorg.xbacklight
    xorg.xdpyinfo
    xorg.xprop
  ];

  services.xserver = {
    # Enable the X11 windowing system.
    enable = true;
    displayManager.startx.enable = true;

    # Use 3l
    layout = "us";
    xkbVariant = if isMustafar then "3l-cros" else "3l";

    # Enable touchpad support.
    libinput = {
      enable = true;
      touchpad.tapping = false;
  options = {
    xorg.enable = mkOption {
      type = types.bool;
      description = "Enable the Xorg stack";
      default = false;
    };

    # Enable i3
    windowManager.i3 = {
      enable = true;
      package = pkgs.i3-gaps;
    xorg.xkbvariant = mkOption {
      type = types.string;
      description = "The XKB variant to use";
      default = "";
    };
  };

  systemd.user.services.xmodmap = let
    xmodmapConfig = pkgs.writeText "Xmodmap.conf" ''
      ! Reverse scrolling
      ! pointer = 1 2 3 5 4 6 7 8 9 10 11 12
      keycode 9 = Caps_Lock Caps_Lock Caps_Lock
    '';
  in
    {
      description = "Run xmodmap on startup.";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];
      serviceConfig.ExecStart = "${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig}";
  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      dunst
      flameshot
      lxappearance
      scrot
      xbindkeys
      xclip
      xorg.xbacklight
      xorg.xdpyinfo
      xorg.xprop
    ];

    services.xbanish.enable = true;

    services.xserver = {
      # Enable the X11 windowing system.
      enable = true;
      displayManager.startx.enable = true;

      # Use 3l
      layout = "us";
      xkbVariant = mkIf (cfg.xkbVariant != "") cfg.xkbVariant;

      # Enable touchpad support.
      libinput = {
        enable = true;
        touchpad.tapping = false;
      };

      # Enable i3
      windowManager.i3 = {
        enable = true;
        package = pkgs.i3-gaps;
      };
    };

    systemd.user.services.xmodmap = let
      xmodmapConfig = pkgs.writeText "Xmodmap.conf" ''
        ! Reverse scrolling
        ! pointer = 1 2 3 5 4 6 7 8 9 10 11 12
        keycode 9 = Caps_Lock Caps_Lock Caps_Lock
      '';
    in
      {
        description = "Run xmodmap on startup.";
        wantedBy = [ "graphical-session.target" ];
        partOf = [ "graphical-session.target" ];
        serviceConfig.ExecStart = "${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig}";
      };
  };
}

D services/window-manager/picom.nix => services/window-manager/picom.nix +0 -42
@@ 1,42 0,0 @@
{ config, lib, pkgs, ... }: let
  useSway = (lib.removeSuffix "\n" (builtins.readFile ./usesway)) == "Y";
in
{
  services.picom = {
    enable = !useSway;

    # General
    vSync = true;

    # Fade
    fade = true;
    fadeDelta = 5;

    # Opacity
    inactiveOpacity = 0.8;
    opacityRules = [
      "100:class_g = 'obs'"
      "100:class_g = 'i3lock'"
    ];

    # Shadow
    shadow = true;
    shadowExclude = [
      "name = 'Notification'"
      "class_g = 'Conky'"
      "class_g ?= 'Notify-osd'"
      "class_g = 'Cairo-clock'"
      "class_g = 'i3-frame'"
      "_GTK_FRAME_EXTENTS@:c"
    ];

    # Custom styles for various window types
    wintypes = {
      tooltip = { shadow = true; opacity = 0.9; focus = true; full-shadow = false; };
      dock = { shadow = false; };
      dnd = { shadow = false; };
      popup_menu = { opacity = 0.9; };
      dropdown_menu = { opacity = 0.9; };
    };
  };
}

M services/window-manager/sway.nix => services/window-manager/sway.nix +45 -41
@@ 1,50 1,54 @@
{ pkgs, ... }: let
  rev = "master";
  url = "https://github.com/colemickens/nixpkgs-wayland/archive/${rev}.tar.gz";
  waylandOverlay = (import (builtins.fetchTarball url));
  sway-accel-rotate = pkgs.callPackage ../../pkgs/sway-accel-rotate.nix {};
{ config, lib, pkgs, ... }: with lib; let
  cfg = config.wayland;
in
{
  environment.variables = {
    GTK_THEME = "Arc-Dark";
    MOZ_ENABLE_WAYLAND = "1";
    XDG_CURRENT_DESKTOP = "sway";
    XDG_SESSION_TYPE = "wayland";
  options = {
    wayland.enable = mkOption {
      type = types.bool;
      description = "Enable the wayland stack";
      default = false;
    };
  };

  nixpkgs.overlays = [ waylandOverlay ];
  config = mkIf cfg.enable {
    nixpkgs.overlays = let
      rev = "master";
      url = "https://github.com/colemickens/nixpkgs-wayland/archive/${rev}.tar.gz";
      waylandOverlay = (import (builtins.fetchTarball url));
    in
      [ waylandOverlay ];

  xdg.portal = {
    enable = true;
    extraPortals = with pkgs; [ xdg-desktop-portal-wlr xdg-desktop-portal-gtk ];
    gtkUsePortal = true;
  };
    xdg.portal = {
      enable = true;
      extraPortals = with pkgs; [ xdg-desktop-portal-wlr xdg-desktop-portal-gtk ];
      gtkUsePortal = true;
    };

  # Make sway the graphical-session target.
  systemd.user.targets.sway-session = {
    description = "sway window manager session";
    bindsTo = [ "graphical-session.target" ];
    wants = [ "graphical-session-pre.target" ];
    after = [ "graphical-session-pre.target" ];
  };
    # Make sway the graphical-session target.
    systemd.user.targets.sway-session = {
      description = "sway window manager session";
      bindsTo = [ "graphical-session.target" ];
      wants = [ "graphical-session-pre.target" ];
      after = [ "graphical-session-pre.target" ];
    };

  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
    extraPackages = with pkgs; [
      clipman
      glib # for GTK settings
      grim
      mako # notification daemon
      slurp
      # sway-accel-rotate # auto screen rotate
      swaylock-effects # lockscreen
      v4l-utils
      wf-recorder
      wl-clipboard # clipboard management
      wofi
      xdg_utils
      xwayland # for legacy apps
    ];
    programs.sway = {
      enable = true;
      wrapperFeatures.gtk = true;
      extraPackages = with pkgs; [
        clipman
        glib # for GTK settings
        grim
        mako # notification daemon
        slurp
        swaylock-effects # lockscreen
        v4l-utils
        wf-recorder
        wl-clipboard # clipboard management
        wofi
        xdg_utils
        xwayland # for legacy apps
      ];
    };
  };
}