add files

This commit is contained in:
Sean Buckley 2020-09-18 09:54:09 -04:00
commit ca2edd4ae8
18 changed files with 549 additions and 0 deletions

0
.update-on-nixos-rebuild Normal file
View file

11
modules/auto-update.nix Normal file
View file

@ -0,0 +1,11 @@
{ config, pkgs, ... }:
{
system.autoUpgrade = {
enable = true;
allowReboot = true;
};
nix.gc = {
automatic = true;
options = "--delete-older-than 30d";
};
}

35
modules/baseline.nix Normal file
View file

@ -0,0 +1,35 @@
{ config, pkgs, ... }:
{
time.timeZone = "US/Eastern";
boot = {
zfs.forceImportAll = false;
zfs.forceImportRoot = false;
kernelParams = [ "amdgpu.gpu_recovery=1" "panic=30" ];
};
nixpkgs.config.allowUnfree = true;
environment.variables.NIXPKGS_ALLOW_UNFREE = "1";
systemd.tmpfiles.rules = [ "e /nix/var/log - - - 30d" ];
zramSwap = {
enable = true;
algorithm = "zstd";
};
hardware = {
cpu.amd.updateMicrocode = true;
cpu.intel.updateMicrocode = true;
};
services = {
earlyoom.enable = true;
avahi = {
enable = true;
nssmdns = true;
publish.enable = true;
publish.addresses = true;
};
};
}

48
modules/cli.nix Normal file
View file

@ -0,0 +1,48 @@
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
pwgen pv tree tmux psmisc ncdu git file sqlite usbutils entr ffmpeg gcc
python3 hugo openssl wget lm_sensors htop zip unzip dnsutils whois
tcpdump rsync
(writeScriptBin "nix-roots" "nix-store --gc --print-roots | grep -v ^/proc/")
(vim_configurable.customize {
name="vim";
vimrcConfig.customRC=''
syntax enable
set nowrap ruler scrolloff=9 backspace=start,indent
set autoindent expandtab tabstop=4 shiftwidth=4
'';
})
(writeScriptBin "zfsram" ''
#!${pkgs.python3}/bin/python
for ln in open('/proc/spl/kstat/zfs/arcstats').readlines():
if ln.startswith('size '):
print(str(int(ln.split(' ')[-1])/(1024*1024*1024))[:5],'GB')
'')
];
programs.bash.interactiveShellInit = ''
stty -ixon
echo $XDG_SESSION_TYPE
alias p=python3
alias buildsys='nix build -f "<nixpkgs/nixos>" --no-link system'
alias channel='
echo " Local: $(cat /nix/var/nix/profiles/per-user/root/channels/nixos/.git-revision)";\
echo "Remote: $(curl --silent -L https://channels.nixos.org/nixos-unstable/git-revision)"
'
function _update_ps1() {
PS1="\n$(${pkgs.powerline-go}/bin/powerline-go \
-colorize-hostname \
-cwd-mode=dironly \
-modules=user,host,cwd,nix-shell,git,jobs \
# -git-assume-unchanged-size 0 \
)$ "
}
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
'';
}

View file

@ -0,0 +1,28 @@
{ stdenv, fetchFromGitHub, glib, gettext }:
stdenv.mkDerivation rec {
pname = "gnome-shell-extension-bottompanel";
version = "1901";
src = fetchFromGitHub {
owner = "Thoma5";
repo = "gnome-shell-extension-bottompanel";
rev = "3d9573896b122e9ccb02262249ca986f8dad1ebd";
sha256 = "0lp25na5plz8vp8zjsikcadgy5hyx59ys2sbd4haagcalyv7jj4q";
};
phases = [ "installPhase" ];
installPhase = ''
mkdir -p "$out/share/gnome-shell/extensions"
cp -r "$src" "$out/share/gnome-shell/extensions/bottompanel@tmoer93"
chmod +w "$out/share/gnome-shell/extensions/bottompanel@tmoer93"
sed -i 's/.*_rightPanelBarrier.*/if(Main.layoutManager._rightPanelBarrier)&/' "$out/share/gnome-shell/extensions/bottompanel@tmoer93/extension.js"
'';
meta = with stdenv.lib; {
description = "Move your GNOME 3 shell panel to the bottom";
homepage = https://github.com/Thoma5/gnome-shell-extension-bottompanel;
};
}

7
modules/gnome/dash-to-panel.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -x
dconf write /org/gnome/shell/extensions/dash-to-panel/panel-size 40
dconf write /org/gnome/shell/extensions/dash-to-panel/group-apps false
dconf write /org/gnome/shell/extensions/dash-to-panel/isolate-workspaces true
dconf write /org/gnome/shell/extensions/dash-to-panel/show-window-previews false

34
modules/gnome/default.nix Normal file
View file

@ -0,0 +1,34 @@
{ pkgs, ... }:
{
environment = {
gnome3.excludePackages = with pkgs.gnome3; [ epiphany vinagre gnome-software ];
systemPackages = with pkgs; [
numix-icon-theme
gnome3.gnome-tweaks
gnome3.gnome-boxes qemu_kvm
(callPackage ./bottom-panel.nix {})
(writeScriptBin "red" ''
x="$(gsettings get org.gnome.settings-daemon.plugins.color night-light-enabled)"
[ "$x" = "true" ] && x=false || x=true
echo "Nightlight: $x"
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled $x
'')
] ++ (with pkgs.gnomeExtensions; [
appindicator
dash-to-panel
drop-down-terminal
sound-output-device-chooser
]);
};
services.xserver = {
enable = true;
libinput.enable = true;
displayManager.gdm.enable = true;
desktopManager.gnome3.enable = true;
desktopManager.xterm.enable = false;
displayManager.sessionCommands = ''
${./settings.sh}
'';
};
}

25
modules/gnome/settings.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
set -x
gsettings set org.gnome.desktop.background picture-uri 'file:///run/current-system/sw/share/backgrounds/gnome/adwaita-night.jpg'
gsettings set org.gnome.desktop.interface enable-hot-corners false
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
gsettings set org.gnome.desktop.interface icon-theme 'Numix'
gsettings set org.gnome.desktop.interface show-battery-percentage true
gsettings set org.gnome.desktop.media-handling automount false
gsettings set org.gnome.desktop.media-handling autorun-never true
gsettings set org.gnome.desktop.notifications show-in-lock-screen false
gsettings set org.gnome.desktop.peripherals.mouse speed 0.375
gsettings set org.gnome.desktop.privacy recent-files-max-age 30
gsettings set org.gnome.desktop.privacy remove-old-temp-files true
gsettings set org.gnome.desktop.privacy remove-old-trash-files true
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['<Super>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['<Shift><Super>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-windows "['<Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "['<Shift><Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings toggle-fullscreen "['<Super>f']"
gsettings set org.gnome.desktop.wm.preferences resize-with-right-button true
gsettings set org.gnome.settings-daemon.plugins.media-keys logout '[]'
echo 'window.ssd headerbar.titlebar { padding-top: 2px; padding-bottom: 2px; }' > ~/.config/gtk-3.0/gtk.css

49
modules/graphical.nix Normal file
View file

@ -0,0 +1,49 @@
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
firefox
brave
gimp
mpv
libreoffice
tdesktop
steam
pavucontrol
gnome3.dconf-editor
glxinfo
steam-run
discord
(vscode-with-extensions.override {
vscode = vscodium;
vscodeExtensions = with pkgs.vscode-extensions; [
bbenoist.Nix
ms-python.python
ms-vscode.cpptools
ms-azuretools.vscode-docker
];
})
];
# environment.systemPackages = with pkgs; [ retroarch ];
# nixpkgs.config.retroarch = {
# enableParallelN64 = true;
# enableNestopia = true;
# enableHiganSFC = true;
# };
services.xserver.deviceSection = ''
Option "VariableRefresh" "true"
'';
hardware = {
pulseaudio.enable = true;
pulseaudio.support32Bit = true;
opengl.driSupport32Bit = true;
};
fonts.fonts = [ pkgs.powerline-fonts ];
boot.loader.timeout = null;
}

View file

@ -0,0 +1,176 @@
diff --git a/include/libinput-properties.h b/include/libinput-properties.h
index a701316890d3d45511199f40207145bb08de4b4f..3dd659fbd157ecbe6be8382b9bf5d9bd8a8f4beb 100644
--- a/include/libinput-properties.h
+++ b/include/libinput-properties.h
@@ -109,6 +109,12 @@
only one is enabled at a time at max, read-only */
#define LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT "libinput Scroll Method Enabled Default"
+/* Scroll distance scale: FLOAT, 2 values, 32 bit */
+#define LIBINPUT_PROP_SCROLL_DISTANCE_SCALE "libinput Scroll Distance Scale"
+
+/* Scroll distance scale: FLOAT, 2 values, 32 bit, read only */
+#define LIBINPUT_PROP_SCROLL_DISTANCE_SCALE_DEFAULT "libinput Scroll Distance Scale Default"
+
/* Scroll button for button scrolling: 32-bit int, 1 value */
#define LIBINPUT_PROP_SCROLL_BUTTON "libinput Button Scrolling Button"
diff --git a/man/libinput.man b/man/libinput.man
index dbf7dee7621d1c2f463813569202896a61259cfd..008a36acba47739ff24dbe8f23f1f6e650822ab4 100644
--- a/man/libinput.man
+++ b/man/libinput.man
@@ -264,6 +264,9 @@ Indicates which scroll methods are available on this device.
3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button".
Indicates which scroll method is currently enabled on this device.
.TP 7
+.BI "libinput Scroll Distance Scale"
+2 32-bit float values. Scroll distance is multiplied by this before being
+passed to the client. First is vertical scale, second is horizontal scale.
.BI "libinput Send Events Modes Available"
2 boolean values (8 bit, 0 or 1), in order "disabled" and
"disabled-on-external-mouse". Indicates which send-event modes are available
diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index ff76895cbbe55ac3c5ed999cb54cefb1e7493063..05ac092615a447be19b25d47e93f476833a6d222 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -131,6 +131,7 @@ struct xf86libinput {
struct scroll_axis {
int dist;
double fraction;
+ double scale;
} v, h;
} scroll;
@@ -1651,6 +1652,18 @@ calculate_axis_value(struct xf86libinput *driver_data,
value = libinput_event_pointer_get_axis_value(event, axis);
}
+ //LogMessageVerb(X_INFO, 0, "scroll of %f on axis %d", value, axis);
+ switch (axis) {
+ case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
+ //LogMessageVerb(X_INFO, 0, "scaled by %f to %f\n", driver_data->scroll.h.scale, value);
+ value *= driver_data->scroll.h.scale;
+ break;
+ case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
+ //LogMessageVerb(X_INFO, 0, "scaled by %f to %f\n", driver_data->scroll.v.scale, value);
+ value *= driver_data->scroll.v.scale;
+ break;
+ }
+
*value_out = value;
return true;
@@ -3430,6 +3443,9 @@ xf86libinput_pre_init(InputDriverPtr drv,
driver_data->scroll.v.dist = 15;
driver_data->scroll.h.dist = 15;
+ driver_data->scroll.v.scale = 1;
+ driver_data->scroll.h.scale = 1;
+
if (!is_subdevice) {
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
driver_data->capabilities |= CAP_POINTER;
@@ -3570,6 +3586,8 @@ static Atom prop_scroll_method_enabled;
static Atom prop_scroll_method_default;
static Atom prop_scroll_button;
static Atom prop_scroll_button_default;
+static Atom prop_scroll_distance_scale;
+static Atom prop_scroll_distance_scale_default;
static Atom prop_click_methods_available;
static Atom prop_click_method_enabled;
static Atom prop_click_method_default;
@@ -4147,6 +4165,35 @@ LibinputSetPropertyScrollButton(DeviceIntPtr dev,
return Success;
}
+static inline int
+LibinputSetPropertyScrollDistanceScale(DeviceIntPtr dev,
+ Atom atom,
+ XIPropertyValuePtr val,
+ BOOL checkonly)
+{
+ InputInfoPtr pInfo = dev->public.devicePrivate;
+ struct xf86libinput *driver_data = pInfo->private;
+ float *data;
+
+ if (val->format != 32 || val->size != 2 || val->type != prop_float) {
+ LogMessageVerb(X_INFO, 0, "bad match");
+ return BadMatch;
+ }
+
+ data = (float*)val->data;
+ LogMessageVerb(X_INFO, 0, "i want to set it to %f %f\n", data[0], data[1]);
+ if (checkonly) {
+ if (!xf86libinput_check_device(dev, atom))
+ return BadMatch;
+ } else {
+ LogMessageVerb(X_INFO, 0, "setting scroll.v.scale to %f and scroll.h.scale to %f\n", data[0], data[1]);
+ driver_data->scroll.v.scale = data[0];
+ driver_data->scroll.h.scale = data[1];
+ }
+
+ return Success;
+}
+
static inline int
LibinputSetPropertyClickMethod(DeviceIntPtr dev,
Atom atom,
@@ -4521,6 +4568,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
rc = LibinputSetPropertyScrollMethods(dev, atom, val, checkonly);
else if (atom == prop_scroll_button)
rc = LibinputSetPropertyScrollButton(dev, atom, val, checkonly);
+ else if (atom == prop_scroll_distance_scale)
+ rc = LibinputSetPropertyScrollDistanceScale(dev, atom, val, checkonly);
else if (atom == prop_click_method_enabled)
rc = LibinputSetPropertyClickMethod(dev, atom, val, checkonly);
else if (atom == prop_middle_emulation)
@@ -4561,6 +4610,7 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
atom == prop_scroll_method_default ||
atom == prop_scroll_methods_available ||
atom == prop_scroll_button_default ||
+ atom == prop_scroll_distance_scale_default ||
atom == prop_click_method_default ||
atom == prop_click_methods_available ||
atom == prop_middle_emulation_default ||
@@ -5072,6 +5122,33 @@ LibinputInitScrollMethodsProperty(DeviceIntPtr dev,
}
}
+static void
+LibinputInitScrollDistanceScaleProperty(DeviceIntPtr dev,
+ struct xf86libinput *driver_data,
+ struct libinput_device *device)
+{
+ float scroll_distance_scale[2] = {driver_data->scroll.v.scale, driver_data->scroll.h.scale};
+
+ if (!subdevice_has_capabilities(dev, CAP_POINTER))
+ return;
+
+ LogMessageVerb(X_INFO, 0, "making %s property with %f %f\n", LIBINPUT_PROP_SCROLL_DISTANCE_SCALE, scroll_distance_scale[0], scroll_distance_scale[1]);
+ prop_scroll_distance_scale = LibinputMakeProperty(dev,
+ LIBINPUT_PROP_SCROLL_DISTANCE_SCALE,
+ prop_float, 32,
+ 2, scroll_distance_scale);
+ if (!prop_scroll_distance_scale)
+ return;
+
+ scroll_distance_scale[0] = 1;
+ scroll_distance_scale[1] = 1;
+ LogMessageVerb(X_INFO, 0, "making %s property with %f %f\n", LIBINPUT_PROP_SCROLL_DISTANCE_SCALE_DEFAULT, scroll_distance_scale[0], scroll_distance_scale[1]);
+ prop_scroll_distance_scale_default = LibinputMakeProperty(dev,
+ LIBINPUT_PROP_SCROLL_DISTANCE_SCALE_DEFAULT,
+ prop_float, 32,
+ 2, scroll_distance_scale);
+}
+
static void
LibinputInitClickMethodsProperty(DeviceIntPtr dev,
struct xf86libinput *driver_data,
@@ -5476,6 +5553,7 @@ LibinputInitProperty(DeviceIntPtr dev)
LibinputInitNaturalScrollProperty(dev, driver_data, device);
LibinputInitDisableWhileTypingProperty(dev, driver_data, device);
LibinputInitScrollMethodsProperty(dev, driver_data, device);
+ LibinputInitScrollDistanceScaleProperty(dev, driver_data, device);
LibinputInitClickMethodsProperty(dev, driver_data, device);
LibinputInitMiddleEmulationProperty(dev, driver_data, device);
LibinputInitRotationAngleProperty(dev, driver_data, device);

View file

@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
services.xserver.displayManager.sessionCommands = ''
xinput list | cut -d= -f2 | cut -f1 | xargs -i xinput set-prop {} 'libinput Scroll Distance Scale' 2 1
'';
nixpkgs.overlays = [(self: super: {
xorg = super.xorg.overrideScope' (selfB: superB: {
inherit (super.xorg) xlibsWrapper;
xf86inputlibinput = superB.xf86inputlibinput.overrideAttrs (attr: {
patches = [ ./b7b5c5ef5f34802fc5f57e68493afaea5db7cdb4.diff ];
});
});
})];
}

14
modules/sean/default.nix Normal file
View file

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
users.users = {
sean = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" "audio" "video" "networkmanager" "dialout" "input" "wireshark" ];
};
test = {
isNormalUser = true;
isSystemUser = true;
};
};
}

View file

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
exiftool burpsuite nmap masscan binutils remmina openvpn socat ghidra-bin
wfuzz gobuster dirb pwndbg thc-hydra metasploit
(callPackage ../pkgs/binary-ninja-personal {})
];
programs = {
wireshark.enable = true;
wireshark.package = pkgs.wireshark;
};
}

29
modules/sway/default.nix Normal file
View file

@ -0,0 +1,29 @@
{ config, pkgs, ... }:
{
programs.sway.enable = true;
environment.variables.GTK_THEME = "Yaru-dark";
environment.variables.MOZ_ENABLE_WAYLAND = "1";
environment.etc."xdg/gtk-3.0/settings.ini".text = ''
[Settings]
gtk-theme-name=Yaru-dark
gtk-icon-theme-name=Numix
'';
# hardware.bluetooth.enable = true;
# services.blueman.enable = true;
services.gvfs.enable = true;
programs.dconf.enable = true;
networking.networkmanager.enable = true;
environment.systemPackages = with pkgs; [
numix-icon-theme yaru-theme
gnome3.networkmanagerapplet gnome3.file-roller gnome3.adwaita-icon-theme
mate.mate-terminal xfce.thunar i3status xfce.thunar-archive-plugin caffeine-ng
wf-recorder
];
programs.bash.interactiveShellInit = '' [ "$(tty)" = "/dev/tty1" ] && exec sway '';
}

View file

@ -0,0 +1,35 @@
{
stdenv, autoPatchelfHook, requireFile, libxkbcommon, makeWrapper, unzip, zlib, glib,
fontconfig, freetype, dbus, python37, libglvnd, libXext, libX11, libXrender, libXi,
libSM, libICE, xkeyboardconfig, nss, libXcomposite, libXcursor, libXdamage, libXtst,
alsaLib, libXrandr, krb5, xcbutilwm, xcbutilimage, xcbutilkeysyms, xcbutilrenderutil
}:
stdenv.mkDerivation rec {
name = "binary-ninja-personal";
src = requireFile {
name = "BinaryNinja-personal.zip";
url = "https://binary.ninja";
sha256 = "5dae72ad0d31f7439cf4232a5324a31857ce4e0e593c85c62520c94ff171b4a2";
};
nativeBuildInputs = [
autoPatchelfHook libxkbcommon stdenv.cc.cc.lib zlib glib fontconfig freetype nss
dbus python37 libglvnd libXext libX11 libXrender libXi libSM libICE unzip makeWrapper
libXcomposite libXcursor libXdamage libXtst alsaLib libXrandr krb5 xcbutilwm xcbutilimage
xcbutilkeysyms xcbutilrenderutil
];
dontStrip = true;
dontPatchELF = true;
installPhase = ''
mkdir -p $out/lib $out/bin $out/share
mv $NIX_BUILD_TOP/$sourceRoot $out/lib/binary-ninja
ln -s "${src}" "$out/share/BinaryNinja-personal.zip"
ln -s "${python37}/lib/libpython3.7m.so.1.0" "$out/lib/binary-ninja/libpython3.7m.so.1"
makeWrapper $out/lib/binary-ninja/binaryninja $out/bin/binaryninja \
--set QT_XKB_CONFIG_ROOT "${xkeyboardconfig}/share/X11/xkb" \
--set QTCOMPOSE "${libX11.out}/share/X11/locale"
'';
}

View file

@ -0,0 +1,10 @@
{ ... }:
{
imports = [
../modules/baseline.nix
../modules/cli.nix
../modules/gnome
../modules/graphical.nix
../modules/security-tools.nix
];
}

10
profiles/desktop-sway.nix Normal file
View file

@ -0,0 +1,10 @@
{ ... }:
{
imports = [
../modules/baseline.nix
../modules/cli.nix
../modules/sway
../modules/graphical.nix
../modules/security-tools.nix
];
}

9
profiles/server.nix Normal file
View file

@ -0,0 +1,9 @@
{ ... }:
{
imports = [
../modules/auto-update.nix
../modules/baseline.nix
../modules/cli.nix
];
services.openssh.enable = true;
}