refactored
This commit is contained in:
parent
d484ea5a62
commit
09aa7681bd
8 changed files with 106 additions and 1858 deletions
|
@ -1,27 +0,0 @@
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
krisp-patcher = pkgs.writers.writePython3Bin "krisp-patcher" {
|
|
||||||
libraries = with pkgs.python3Packages; [ capstone pyelftools ];
|
|
||||||
flakeIgnore = [
|
|
||||||
"E501" # line too long (82 > 79 characters)
|
|
||||||
"F403" # ‘from module import *’ used; unable to detect undefined names
|
|
||||||
"F405" # name may be undefined, or defined from star imports: module
|
|
||||||
];
|
|
||||||
} (builtins.readFile ./krisp-patcher.py);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
sys.discord.enable = lib.mkOption {
|
|
||||||
description = "Whether to install Discord, a voice and text chat platform.";
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config = lib.mkIf config.sys.discord.enable {
|
|
||||||
home.packages = [
|
|
||||||
(pkgs.discord.override { withVencord = true; withTTS = true; })
|
|
||||||
krisp-patcher
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from elftools.elf.elffile import ELFFile
|
|
||||||
from capstone import *
|
|
||||||
from capstone.x86 import *
|
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print(f"Usage: {sys.argv[0]} [path to discord_krisp.node]")
|
|
||||||
# "Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors."
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
executable = sys.argv[1]
|
|
||||||
|
|
||||||
elf = ELFFile(open(executable, "rb"))
|
|
||||||
symtab = elf.get_section_by_name('.symtab')
|
|
||||||
|
|
||||||
krisp_initialize_address = symtab.get_symbol_by_name("_ZN7discord15KrispInitializeEv")[0].entry.st_value
|
|
||||||
isSignedByDiscord_address = symtab.get_symbol_by_name("_ZN7discord4util17IsSignedByDiscordERKNSt4__Cr12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE")[0].entry.st_value
|
|
||||||
|
|
||||||
text = elf.get_section_by_name('.text')
|
|
||||||
text_start = text['sh_addr']
|
|
||||||
text_start_file = text['sh_offset']
|
|
||||||
# This seems to always be zero (.text starts at the right offset in the file). Do it just in case?
|
|
||||||
address_to_file = text_start_file - text_start
|
|
||||||
|
|
||||||
# Done with the ELF now.
|
|
||||||
# elf.close()
|
|
||||||
|
|
||||||
krisp_initialize_offset = krisp_initialize_address - address_to_file
|
|
||||||
isSignedByDiscord_offset = krisp_initialize_address - address_to_file
|
|
||||||
|
|
||||||
f = open(executable, "rb")
|
|
||||||
f.seek(krisp_initialize_offset)
|
|
||||||
krisp_initialize = f.read(64)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
# States
|
|
||||||
found_issigned_by_discord_call = False
|
|
||||||
found_issigned_by_discord_test = False
|
|
||||||
found_issigned_by_discord_je = False
|
|
||||||
found_already_patched = False
|
|
||||||
je_location = None
|
|
||||||
|
|
||||||
# We are looking for a call to IsSignedByDiscord, followed by a test, followed by a je.
|
|
||||||
# Then we patch the je into a two byte nop.
|
|
||||||
|
|
||||||
md = Cs(CS_ARCH_X86, CS_MODE_64)
|
|
||||||
md.detail = True
|
|
||||||
for i in md.disasm(krisp_initialize, krisp_initialize_address):
|
|
||||||
if i.id == X86_INS_CALL:
|
|
||||||
if i.operands[0].type == X86_OP_IMM:
|
|
||||||
if i.operands[0].imm == isSignedByDiscord_address:
|
|
||||||
found_issigned_by_discord_call = True
|
|
||||||
|
|
||||||
if i.id == X86_INS_TEST:
|
|
||||||
if found_issigned_by_discord_call:
|
|
||||||
found_issigned_by_discord_test = True
|
|
||||||
|
|
||||||
if i.id == X86_INS_JE:
|
|
||||||
if found_issigned_by_discord_test:
|
|
||||||
found_issigned_by_discord_je = True
|
|
||||||
je_location = i.address
|
|
||||||
break
|
|
||||||
|
|
||||||
if i.id == X86_INS_NOP:
|
|
||||||
if found_issigned_by_discord_test:
|
|
||||||
found_already_patched = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if je_location:
|
|
||||||
print(f"Found patch location: 0x{je_location:x}")
|
|
||||||
|
|
||||||
shutil.copyfile(executable, executable + ".orig")
|
|
||||||
f = open(executable, 'rb+')
|
|
||||||
f.seek(je_location - address_to_file)
|
|
||||||
f.write(b'\x66\x90') # Two byte NOP
|
|
||||||
f.close()
|
|
||||||
else:
|
|
||||||
if found_already_patched:
|
|
||||||
print("Couldn't find patch location - already patched.")
|
|
||||||
else:
|
|
||||||
print("Couldn't find patch location - review manually. Sorry.")
|
|
85
flake.nix
85
flake.nix
|
@ -8,6 +8,11 @@
|
||||||
home-manager.url = "github:nix-community/home-manager/master";
|
home-manager.url = "github:nix-community/home-manager/master";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
darwin = {
|
||||||
|
url = "github:lnl7/nix-darwin/master";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
stylix.url = "github:danth/stylix";
|
stylix.url = "github:danth/stylix";
|
||||||
blocklist-hosts = {
|
blocklist-hosts = {
|
||||||
url = "github:StevenBlack/hosts";
|
url = "github:StevenBlack/hosts";
|
||||||
|
@ -52,44 +57,6 @@
|
||||||
overlays = [
|
overlays = [
|
||||||
inputs.zig.overlays.default
|
inputs.zig.overlays.default
|
||||||
];
|
];
|
||||||
systemSettings = {
|
|
||||||
system = "x86_64-linux"; # system arch
|
|
||||||
hostname = "nixos"; # hostname
|
|
||||||
#profile = "personal"; # select a profile defined from my profiles directory
|
|
||||||
timezone = "America/Los_Angeles"; # select timezone
|
|
||||||
locale = "en_US.UTF-8"; # select locale
|
|
||||||
};
|
|
||||||
userSettings = rec {
|
|
||||||
username = "nmarks"; # username
|
|
||||||
name = "Nmarks"; # name/identifier
|
|
||||||
email = "nmarks413@gmail.com"; # email (used for certain configurations)
|
|
||||||
dotfilesDir = "~/.dotfiles"; # absolute path of the local repo
|
|
||||||
#theme = "uwunicorn-yt"; # selcted theme from my themes directory (./themes/)
|
|
||||||
wm = "hyprland"; # Selected window manager or desktop environment; must select one in both ./user/wm/ and ./system/wm/
|
|
||||||
# window manager type (hyprland or x11) translator
|
|
||||||
wmType =
|
|
||||||
if (wm == "hyprland")
|
|
||||||
then "wayland"
|
|
||||||
else "x11";
|
|
||||||
browser = "firefox"; # Default browser; must select one from ./user/app/browser/
|
|
||||||
term = "kitty"; # Default terminal command;
|
|
||||||
font = ""; # Selected font
|
|
||||||
fontPkg = pkgs.intel-one-mono; # Font package
|
|
||||||
editor = "nvim"; # Default editor;
|
|
||||||
# editor spawning translator
|
|
||||||
# generates a command that can be used to spawn editor inside a gui
|
|
||||||
# EDITOR and TERM session variables must be set in home.nix or other module
|
|
||||||
# I set the session variable SPAWNEDITOR to this in my home.nix for convenience
|
|
||||||
spawnEditor =
|
|
||||||
if (editor == "emacsclient")
|
|
||||||
then "emacsclient -c -a 'emacs'"
|
|
||||||
else
|
|
||||||
(
|
|
||||||
if ((editor == "vim") || (editor == "nvim") || (editor == "nano"))
|
|
||||||
then "exec " + term + " -e " + editor
|
|
||||||
else editor
|
|
||||||
);
|
|
||||||
};
|
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
system = systemSettings.system;
|
system = systemSettings.system;
|
||||||
config = {
|
config = {
|
||||||
|
@ -108,15 +75,21 @@
|
||||||
overlays = [];
|
overlays = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
in {
|
in {
|
||||||
homeConfigurations = {
|
nixosConfigurations = {
|
||||||
nmarks = home-manager.lib.homeManagerConfiguration {
|
nixos = lib.nixosSystem {
|
||||||
inherit pkgs;
|
system = systemSettings.system;
|
||||||
modules = [
|
modules = [
|
||||||
./home.nix
|
nixos-cosmic.nixosModules.default
|
||||||
];
|
./configuration.nix
|
||||||
extraSpecialArgs = {
|
home-manager.nixosModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
home-manager.users.nmarks = import ./hosts/desktop/home.nix;
|
||||||
|
home-manager.extraSpecialArgs = {
|
||||||
inherit pkgs-stable;
|
inherit pkgs-stable;
|
||||||
inherit systemSettings;
|
inherit systemSettings;
|
||||||
inherit userSettings;
|
inherit userSettings;
|
||||||
|
@ -125,14 +98,7 @@
|
||||||
inherit zls;
|
inherit zls;
|
||||||
inherit ghostty;
|
inherit ghostty;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
|
||||||
nixosConfigurations = {
|
|
||||||
nixos = lib.nixosSystem {
|
|
||||||
system = systemSettings.system;
|
|
||||||
modules = [
|
|
||||||
nixos-cosmic.nixosModules.default
|
|
||||||
./configuration.nix
|
|
||||||
];
|
];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
|
@ -144,7 +110,20 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
darwinSystem = darwin.lib.darwinSystem {
|
||||||
|
system = "aarch64-darwin";
|
||||||
|
modules = [
|
||||||
|
./hosts/laptop/configuration.nix
|
||||||
|
home-manager.darwinModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
home-manager.users.nmarks = import ./hosts/laptop/home.nix;
|
||||||
|
users.users.nmarks.home = "/Users/nmarks";
|
||||||
|
};
|
||||||
|
];
|
||||||
|
specialArgs = { inherit nixpkgs; };
|
||||||
|
};
|
||||||
# nixos = inputs.self.nixosConfigurations.nmarks;
|
# nixos = inputs.self.nixosConfigurations.nmarks;
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
74
hosts/laptop/configuration.nix
Normal file
74
hosts/laptop/configuration.nix
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{ config, pkgs, … }:
|
||||||
|
|
||||||
|
{
|
||||||
|
environment.systemPackages =
|
||||||
|
[
|
||||||
|
pkgs.home-manager
|
||||||
|
];
|
||||||
|
|
||||||
|
# Use a custom configuration.nix location.
|
||||||
|
environment.darwinConfig = "$HOME/src/github.com/evantravers/dotfiles/nix-darwin-configuration";
|
||||||
|
|
||||||
|
# Auto upgrade nix package and the daemon service.
|
||||||
|
services.nix-daemon.enable = true;
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nix;
|
||||||
|
settings = {
|
||||||
|
"extra-experimental-features" = [ "nix-command" "flakes" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Create /etc/zshrc that loads the nix-darwin environment.
|
||||||
|
programs = {
|
||||||
|
gnupg.agent.enable = true;
|
||||||
|
zsh.enable = true; # default shell on catalina
|
||||||
|
};
|
||||||
|
|
||||||
|
# Used for backwards compatibility, please read the changelog before changing.
|
||||||
|
# $ darwin-rebuild changelog
|
||||||
|
system.stateVersion = 4;
|
||||||
|
|
||||||
|
# Install fonts
|
||||||
|
fonts.fontDir.enable = true;
|
||||||
|
fonts.fonts = [
|
||||||
|
pkgs.iosevka
|
||||||
|
];
|
||||||
|
|
||||||
|
# Use homebrew to install casks and Mac App Store apps
|
||||||
|
homebrew = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
casks = [
|
||||||
|
"1password"
|
||||||
|
"firefox"
|
||||||
|
"obsidian"
|
||||||
|
"raycast"
|
||||||
|
];
|
||||||
|
|
||||||
|
masApps = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# set some OSX preferences that I always end up hunting down and changing.
|
||||||
|
system.defaults = {
|
||||||
|
# minimal dock
|
||||||
|
dock = {
|
||||||
|
autohide = true;
|
||||||
|
orientation = "left";
|
||||||
|
show-process-indicators = false;
|
||||||
|
show-recents = false;
|
||||||
|
static-only = true;
|
||||||
|
};
|
||||||
|
# a finder that tells me what I want to know and lets me work
|
||||||
|
finder = {
|
||||||
|
AppleShowAllExtensions = true;
|
||||||
|
ShowPathbar = true;
|
||||||
|
FXEnableExtensionChangeWarning = false;
|
||||||
|
};
|
||||||
|
# Tab between form controls and F-row that behaves as F1-F12
|
||||||
|
NSGlobalDomain = {
|
||||||
|
AppleKeyboardUIMode = 3;
|
||||||
|
"com.apple.keyboard.fnState" = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,88 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
systemSettings,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
imports = [./hardware-configuration.nix];
|
|
||||||
nix.settings.experimental-features = [
|
|
||||||
"nix-command"
|
|
||||||
"flakes"
|
|
||||||
];
|
|
||||||
|
|
||||||
virtualisation.libvirtd.enable = true;
|
|
||||||
|
|
||||||
time.timeZone = systemSettings.timeZone;
|
|
||||||
|
|
||||||
systemd.targets = {
|
|
||||||
sleep.enable = false;
|
|
||||||
suspend.enable = false;
|
|
||||||
hibernate.enable = false;
|
|
||||||
hybrid-sleep.enable = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
fonts.packages = with pkgs; [
|
|
||||||
(nerdfonts.override {fonts = ["FiraCode" "Iosevka"];})
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
|
||||||
flatpak.enable = true;
|
|
||||||
tailscale.enable = true;
|
|
||||||
services.keyd = {
|
|
||||||
enable = true;
|
|
||||||
keyboards.default.settings.main.capslock = "escape";
|
|
||||||
};
|
|
||||||
xserver = {
|
|
||||||
enable = true;
|
|
||||||
videoDrivers = ["nvidia"];
|
|
||||||
displayManager.sddm.enable = true;
|
|
||||||
desktopManager.plasma6 = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
programs = {
|
|
||||||
fish.enable = true;
|
|
||||||
virt-manager.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
hardware = {
|
|
||||||
opengl = {
|
|
||||||
enable = true;
|
|
||||||
driSupport = true;
|
|
||||||
driSupport32Bit = true;
|
|
||||||
};
|
|
||||||
nvidia = {
|
|
||||||
modesetting.enable = false;
|
|
||||||
powerManagement.finegrained = false;
|
|
||||||
open = false;
|
|
||||||
nvidiaSettings = true;
|
|
||||||
|
|
||||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
|
||||||
};
|
|
||||||
pulseaudio.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.loader = {
|
|
||||||
systemd-boot.enable = true;
|
|
||||||
efi = {
|
|
||||||
canTouchEfiVariables = true;
|
|
||||||
efiSysMountPoint = "/boot";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
i18n = {
|
|
||||||
defaultLocale = "en_US.utf-8";
|
|
||||||
extraLocaleSettings = {
|
|
||||||
LC_ADDRESS = "en_US.UTF-8";
|
|
||||||
LC_IDENTIFICATION = "en_US.UTF-8";
|
|
||||||
LC_MEASUREMENT = "en_US.UTF-8";
|
|
||||||
LC_MONETARY = "en_US.UTF-8";
|
|
||||||
LC_NAME = "en_US.UTF-8";
|
|
||||||
LC_NUMERIC = "en_US.UTF-8";
|
|
||||||
LC_PAPER = "en_US.UTF-8";
|
|
||||||
LC_TELEPHONE = "en_US.UTF-8";
|
|
||||||
LC_TIME = "en_US.UTF-8";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue