From 1d8f2f80530d33363d027f5c9034734a29835788 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Mon, 1 Nov 2021 21:33:21 +0100 Subject: [PATCH] flakes: Migrate the config and miku to flakes --- .gitignore | 1 + flake.lock | 327 +++++ flake.nix | 53 + hosts/ayame.nix | 73 -- hosts/isla.nix | 74 -- hosts/miku.nix | 199 +-- lib/baseSystem.nix | 179 +++ lib/default.nix | 22 + lib/flake.nix | 7 + lib/helpers/kanshi.nix | 45 + lib/mkSystem.nix | 48 + {modules => lib}/network.nix | 4 +- modules/base.nix | 26 + modules/default.nix | 50 +- modules/hardware/amd.nix | 14 +- modules/hardware/amdgpu.nix | 22 +- modules/hardware/intel.nix | 26 +- modules/hardware/mobile.nix | 18 +- modules/hardware/surface-pro6.nix | 117 +- modules/hardware/wifi.nix | Bin 1244 -> 1357 bytes modules/host.nix | 220 ---- modules/offloading/builder.nix | 29 + modules/offloading/offload.nix | 31 + modules/programs/alacritty/default.nix | 1155 +++++++++-------- .../programs/distributed-build/builder.nix | 21 - .../programs/distributed-build/offload.nix | 24 - modules/programs/emacs/#dotemacs# | 293 +++++ modules/programs/emacs/default.nix | 22 +- modules/programs/firefox/default.nix | 16 +- modules/programs/gamemode/#gamemode.ini# | 36 - modules/programs/gamemode/default.nix | 21 - modules/programs/gamemode/gamemode.ini | 36 - modules/programs/git/default.nix | 13 +- modules/programs/gnome-terminal/default.nix | 14 +- modules/programs/gnome/default.nix | 12 +- modules/programs/i18n/default.nix | 30 +- modules/programs/kanshi/default.nix | 105 -- modules/programs/mako/default.nix | 21 +- modules/programs/mpv/default.nix | 14 +- modules/programs/sway/default.nix | 101 +- modules/programs/swaync/default.nix | 18 +- modules/programs/tmux/default.nix | 14 +- modules/programs/waybar/default.nix | 104 +- modules/programs/xournalpp/default.nix | 23 +- modules/programs/zsh/default.nix | 166 +-- modules/services/gamemode/default.nix | 29 + modules/services/kanshi/default.nix | 72 + modules/services/key-mapper/default.nix | 35 + modules/users/alexander.nix | 11 +- modules/users/default.nix | 2 +- modules/users/fuck-xi.nix | 4 +- modules/virtualisation/default.nix | 15 +- modules/virtualisation/gaming.nix | 72 +- overlays/custom.nix | 5 - overlays/default.nix | 11 +- overlays/stable.nix | 21 - overlays/unstable.nix | 21 - packages/default.nix | 68 +- packages/misc/video/anime4k/default.nix | 2 +- packages/tools/games/key-mapper/default.nix | 5 +- .../games/key-mapper/hack-data-dir.patch | 12 +- .../video/animedl/0000-add-kawaiifu.patch | 57 + packages/tools/video/animedl/default.nix | 49 + .../virtualisation/vfio-isolate/default.nix | 16 +- 64 files changed, 2612 insertions(+), 1739 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 hosts/ayame.nix delete mode 100644 hosts/isla.nix create mode 100644 lib/baseSystem.nix create mode 100644 lib/default.nix create mode 100644 lib/flake.nix create mode 100644 lib/helpers/kanshi.nix create mode 100644 lib/mkSystem.nix rename {modules => lib}/network.nix (63%) create mode 100644 modules/base.nix delete mode 100644 modules/host.nix create mode 100644 modules/offloading/builder.nix create mode 100644 modules/offloading/offload.nix delete mode 100644 modules/programs/distributed-build/builder.nix delete mode 100644 modules/programs/distributed-build/offload.nix create mode 100644 modules/programs/emacs/#dotemacs# delete mode 100644 modules/programs/gamemode/#gamemode.ini# delete mode 100644 modules/programs/gamemode/default.nix delete mode 100644 modules/programs/gamemode/gamemode.ini delete mode 100644 modules/programs/kanshi/default.nix create mode 100644 modules/services/gamemode/default.nix create mode 100644 modules/services/kanshi/default.nix create mode 100644 modules/services/key-mapper/default.nix delete mode 100644 overlays/custom.nix delete mode 100644 overlays/stable.nix delete mode 100644 overlays/unstable.nix create mode 100644 packages/tools/video/animedl/0000-add-kawaiifu.patch create mode 100644 packages/tools/video/animedl/default.nix diff --git a/.gitignore b/.gitignore index 2c042de..4d75657 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ packages/result +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7172564 --- /dev/null +++ b/flake.lock @@ -0,0 +1,327 @@ +{ + "nodes": { + "agenix": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1634404028, + "narHash": "sha256-JyP2Y6JCCYvUcVz7CXX5pXUfTGTU4GX51Yza82BgMfk=", + "owner": "ryantm", + "repo": "agenix", + "rev": "53aa91b4170da35a96fab1577c9a34bc0da44e27", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "emacs": { + "locked": { + "lastModified": 1635818927, + "narHash": "sha256-q5mJS+2t4X67eqEua/k4HOhLfKCIvblfYWpB+DmOgA4=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "64580e3ac034e2704895a272f341a0729d165b93", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1635839387, + "narHash": "sha256-2B6DqfTiwY5w2TljC4+AxEUuVYMTP5Fo2h5iGNIONvk=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "288faaa5a65e72e37e6027024829b15c8bb69286", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "ostylk", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1634544068, + "narHash": "sha256-RlRQBaAHfdWqfRyHdWuDPMkplBTYwuyDQqDcNbP/Sog=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "ff2bed9dac84fb202bbb3c49fdcfe30c29d0b12f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-21.05", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "locked": { + "lastModified": 1635517258, + "narHash": "sha256-8iV8f9eZ/5cE0DmG7VmNSiCqpe00yL5HbOO7nZJm1Oo=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "ce77ed9bd069e57a7a688d360196e576ca63a842", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "ostylk", + "rnix-lsp", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1629707199, + "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", + "owner": "nmattia", + "repo": "naersk", + "rev": "df71f5e4babda41cd919a8684b72218e2e809fa9", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1635762949, + "narHash": "sha256-goQTG3VaYkbNe5vcfA8neNUJoh23WW1eX8BSkkC1xlQ=", + "owner": "ostylk", + "repo": "nixos-hardware", + "rev": "83336d73604a38d492fa8e85b860b2d937547e09", + "type": "github" + }, + "original": { + "owner": "ostylk", + "ref": "surface-update", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1635844945, + "narHash": "sha256-tZcL307dj28jgEU1Wdn+zwG9neyW0H2+ZjdVhvJxh9g=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b67e752c29f18a0ca5534a07661366d6a2c2e649", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1635702959, + "narHash": "sha256-ZKxX9DjJJGJqq20pE4dIj1G4ssCLVXXRFerM6lNuF0k=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e544ee88fa4590df75e221e645a03fe157a99e5b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1635792138, + "narHash": "sha256-D79GqaYrwgyM4wvOPbQeKveAHROnVh97F36iSGZO9uA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b165ce0c4efbb74246714b5c66b6bcdce8cde175", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1618628710, + "narHash": "sha256-9xIoU+BrCpjs5nfWcd/GlU7XCVdnNKJPffoNTxgGfhs=", + "path": "/nix/store/z1rf17q0fxj935cmplzys4gg6nxj1as0-source", + "rev": "7919518f0235106d050c77837df5e338fb94de5d", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1635719588, + "narHash": "sha256-pWjdy0NheM97NsPE6+jUnr5LYyeA0sBGTdw4mfXMGZQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f0869b1a2c0b150aac26e10bb5c2364ffb2e804f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nur": { + "locked": { + "lastModified": 1635841629, + "narHash": "sha256-DDgUT9vVJXIcjQW4Idv2ejIx0Ksjg3z+VLYRhwa+GxQ=", + "owner": "nix-community", + "repo": "nur", + "rev": "1e5920035311eac2cc98304ef6633d3063b63e9f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nur", + "type": "github" + } + }, + "ostylk": { + "inputs": { + "agenix": "agenix", + "flake-utils": "flake-utils_2", + "home-manager": "home-manager_2", + "impermanence": "impermanence", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs_4", + "nixpkgs-unstable": "nixpkgs-unstable", + "rnix-lsp": "rnix-lsp" + }, + "locked": { + "lastModified": 1635797605, + "narHash": "sha256-syj9QJmOwQdQOYhnHJn+jNJLshX73jvdJAepiNC/6qo=", + "ref": "master", + "rev": "c1b6e767ba39d7c3d3a7308882ba44d0ed334471", + "revCount": 136, + "type": "git", + "url": "https://dev.ostylk.de/NixDistro/Config" + }, + "original": { + "type": "git", + "url": "https://dev.ostylk.de/NixDistro/Config" + } + }, + "rnix-lsp": { + "inputs": { + "naersk": "naersk", + "nixpkgs": [ + "ostylk", + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1634449716, + "narHash": "sha256-JuRCU4KCIA3/pp8BjHqqF9dj1d2xtpkxKKAtSuOzTIY=", + "owner": "nix-community", + "repo": "rnix-lsp", + "rev": "a2d06d2d2910cbe35b4f323a54ef484f51d71e20", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "rnix-lsp", + "type": "github" + } + }, + "root": { + "inputs": { + "emacs": "emacs", + "flake-utils": "flake-utils", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2", + "nur": "nur", + "ostylk": "ostylk" + } + }, + "utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..263ef2d --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "PapaTutuWawa's flake configuration"; + + inputs = { + home-manager.url = "github:nix-community/home-manager/master"; + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + #stable.url = "github:nixos/nixpkgs/nixos-21.05"; + emacs.url = "github:nix-community/emacs-overlay"; + nur.url = "github:nix-community/nur"; + ostylk.url = "git+https://dev.ostylk.de/NixDistro/Config"; + }; + + outputs = { + self + , nixpkgs + , home-manager + , flake-utils + , ... + }@inputs: let + inherit (import ./lib/flake.nix { + inherit flake-utils; + inherit (nixpkgs) lib; + }) eachDefaultLinuxSystem; + mkSystem = import ./lib/mkSystem.nix { + inherit inputs; + inherit (inputs) nur emacs; + inherit (nixpkgs) lib config; + }; + in { + # Defines outputs that is not dependent on a specific system, i.e. overlays + overlay = import ./packages; + + nixosConfigurations = { + miku = mkSystem { + hostConfigFile = ./hosts/miku.nix; + }; + }; + } // eachDefaultLinuxSystem (system: { + packages = let + pkgs = import nixpkgs { + inherit system; + + overlays = [ + self.overlay + ]; + }; + in { + # key-mapper only runs on linux + inherit (pkgs) key-mapper; + }; + }); +} diff --git a/hosts/ayame.nix b/hosts/ayame.nix deleted file mode 100644 index 4b4fd91..0000000 --- a/hosts/ayame.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - mkHost = (import ../modules { lib = lib; pkgs = pkgs; }).mkHost; -in mkHost config { - userName = "alexander"; - hostName = "ayame"; - wireless = true; - wifiInterface = "wlan0"; - overlays = [ "nur" "unstable" ]; - hardwareImports = [ "intel" "mobile" ]; - programImports = [ - "zsh" "mpv" "git" "tmux" "firefox" "gnome-terminal" "gnome" - ]; - extraImports = [ "distributed-build/offload.nix" ]; - extraPackages = pkgs: with pkgs; [ - unstable.firmwareLinuxNonFree unstable.sof-firmware - ]; - fileSystems = { - "/" = { - device = "/dev/disk/by-label/root"; - fsType = "btrfs"; - }; - "/boot" = { - device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; - }; - swapDevices = [ - { device = "/dev/disk/by-uuid/cf3b1e1c-c245-4452-ad49-68ac72369e77"; } - ]; - extraOptions = old: { - boot = { - loader = { - systemd-boot.enable = false; - efi.canTouchEfiVariables = false; - grub = { - enable = true; - efiInstallAsRemovable = true; - device = "nodev"; - efiSupport = true; - # The UEFI is pretty wonky - forcei686 = true; - }; - }; - extraModprobeConfig = ""; - initrd = { - availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "sd_mod" "sdhci_acpi" ]; - kernelModules = [ - "kvm-intel" "i915" - ]; - }; - # This spams the console and takes up so much CPU time - kernelParams = [ "modprobe.blacklist=arizona_spi" ]; - kernelModules = []; - extraModulePackages = []; - kernelPackages = pkgs.linuxPackages_zen; - }; - - /*systemd.services = { - rfkill-workaround = { - enable = true; - description = "Work around rfkill having the Wifi blocked at boot"; - before = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "oneshot"; - ExecStart = "rfkill unblock all"; - }; - }; - };*/ - }; -} diff --git a/hosts/isla.nix b/hosts/isla.nix deleted file mode 100644 index da7afca..0000000 --- a/hosts/isla.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ config, pkgs, modulesPath, lib, ... }: - -{ - imports = [ - ./generic.nix - ../modules/hardware/generic.nix ../modules/hardware/video.nix - ../modules/users/fuck-xi.nix - ../modules/programs/zsh ../modules/programs/tmux ../modules/programs/emacs ../modules/programs/firefox ../modules/programs/gnome-terminal ../modules/programs/gnome - ]; - - nixpkgs.overlays = [ - (import (builtins.fetchGit { - url = "https://github.com/nix-community/emacs-overlay.git"; - ref = "master"; - rev = "ce0e9482d53d69bedc8416d8a984d00e17607826"; - })) - - # Unstable, NUR, ... - (import ../overlays/unstable.nix pkgs) - (import ../overlays/nur.nix pkgs) - (import ../overlays/custom.nix pkgs) - ]; - - environment = { - systemPackages = with pkgs; [ - emacsPgtkGcc - ]; - - sessionVariables = { - # Prevent us from having to always type it out - #NIXOS_CONFIG = "\${HOME}/Development/Personal/nixos-config/hosts/isla.nix"; - }; - }; - - networking = { - interfaces.enp6s0.useDHCP = false; - hostName = "isla"; - # Nix otherwise has a conflict with this option - wireless.enable = lib.mkForce false; - - # Allow scream to connect to this host - firewall.allowedUDPPorts = [ 4010 ]; - }; - - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - extraModprobeConfig = ""; - initrd = { - availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" "amdgpu" "vendor-reset" ]; - kernelModules = []; - }; - kernelParams = []; - kernelModules = []; - extraModulePackages = []; - kernelPackages = pkgs.linuxPackages_zen; - }; - - services = { - emacs.package = pkgs.emacsPgtkGcc; - }; - - systemd.services.NetworkManager-wait-online.enable = false; - - fileSystems = { - "/" = { - device = "/dev/disk/by-label/root"; - fsType = "btrfs"; - }; - }; - swapDevices = [ ]; -} diff --git a/hosts/miku.nix b/hosts/miku.nix index 3e57411..33cceca 100644 --- a/hosts/miku.nix +++ b/hosts/miku.nix @@ -1,20 +1,6 @@ { config, lib, pkgs, ... }: -let - mkHost = (import ../modules { lib = lib; pkgs = pkgs; }).mkHost; -in mkHost config { - userName = "alexander"; - hostName = "miku"; - primaryInterface = "enp6s0"; - overlays = [ "nur" "unstable" "stable" "simple" "custom" "emacs" ]; - hardwareImports = [ "amdgpu" "amd" ]; - programImports = [ - "zsh" "git" "mpv" "tmux" "emacs" "firefox" "i18n" "gamemode" "gnome" #"gnome-terminal" - "alacritty" "sway" "waybar" "swaync" "kanshi" - "distributed-build/builder.nix" - "music" - ]; - extraImports = [ "virtualisation/gaming.nix" "virtualisation" ]; +{ fileSystems = { "/" = { device = "/dev/disk/by-label/root"; @@ -29,12 +15,11 @@ in mkHost config { fsType = "ext4"; }; }; - extraPackages = pkgs: with pkgs; [ + + environment.systemPackages = with pkgs; [ emacsPgtkGcc gajim-mainwindow - virt-manager unstable.qemu scream - #gamemode # Custom package - #key-mapper # Custom package + virt-manager qemu scream replaysorcery # Custom package #evdev-proxy # Custom package vfio-isolate # Custom Package @@ -44,77 +29,138 @@ in mkHost config { mumble piper anime-dl trackma # Custom package - unstable.thunderbird + thunderbird multimc-wrapped # Custom package nwg-launchers ]; - extraOptions = old: { - system.autoUpgrade.channel = "https://nixos.org/channels/nixos-unstable"; + ptw = { programs = { mpv.primaryScreen = "C27F398"; - adb.enable = true; sway.enable = true; + alacritty.enable = true; + emacs.enable = true; + firefox.enable = true; + git.enable = true; + #gnome-terminal.enable = true; + mpv.enable = true; + tmux.enable = true; + waybar.enable = true; + xournalpp.enable = true; + zsh.enable = true; }; + services = { + gamemode.enable = true; + #gnome.enable = true; + kanshi = let + horizontal = "Samsung Electric Company C27F398 H4ZR101145"; + vertical = "Goldstar Company Ltd IPS235 305NDPHKN600"; - boot = { - extraModprobeConfig = '' + helpers = import ../lib/helpers/kanshi.nix; + mkProfile = helpers.mkProfile; + wallpaperScript = helpers.mkWallpaperScript { + inherit pkgs config; + }; + in { + enable = true; + profiles = { + homeMultihead = mkProfile { + outputs = [ + { + criteria = vertical; + status = "enable"; + mode = "1920x1080"; + transform = "90"; + position = "-1080,0"; + } + { + criteria = horizontal; + status = "enable"; + mode = "1920x1080"; + position = "0,0"; + } + ]; + name = "homeMultihead"; + script = wallpaperScript; + }; + }; + }; + swaync.enable = true; + key-mapper.enable = true; + }; + system = { + i18n.enable = true; + singleUser = "alexander"; + primaryInterface = "enp6s0"; + hostName = "miku"; + }; + virtualisation = { + enable = true; + }; + }; + programs.adb.enable = true; + + boot = { + extraModprobeConfig = '' options kvm_amd nested=1 options vfio-pci ids=1002:67df,1002:aaf0 options amdgpu dpm=0 ''; - initrd = { - availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" "amdgpu" "vendor-reset" ]; - kernelModules = [ - "amdgpu" # GPU (duh) - "kvm-amd" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" # Virt - "uinput" # key-mapper - "vendor-reset" - ]; - }; - kernelParams = [ - "amd_iommu=on" - "iommu=pt" - "sysrq_always_enabled=1" - "kvm.ignore_msrs=1" - "kvm.report_ignored_msrs=N" - "fbcon=rotate:3" - "quiet" - "tsc=unstable" + initrd = { + availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" "amdgpu" ]; #"vendor-reset" ]; + kernelModules = [ + "amdgpu" # GPU (duh) + "kvm-amd" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" # Virt + "uinput" # key-mapper + #"vendor-reset" ]; - extraModulePackages = [ pkgs.linuxPackages_xanmod.vendor-reset ]; + }; + kernelParams = [ + "amd_iommu=on" + "iommu=pt" + "sysrq_always_enabled=1" + "kvm.ignore_msrs=1" + "kvm.report_ignored_msrs=N" + "fbcon=rotate:3" + "quiet" + "tsc=unstable" + ]; + + #extraModulePackages = [ pkgs.linuxPackages_xanmod.vendor-reset ]; - #extraModulePackages = [ pkgs.linuxPackages.vendor-reset ]; - # NOTE: A regression appears to have happend between 5.10 and 5.12 - # which leads to the RX590 to have the fence fallback timer on - # sdma0 time out (whatever this means). Maybe bisect? - kernelPackages = pkgs.linuxPackages_xanmod; - }; - xdg.portal = { - enable = true; - extraPortals = [ - pkgs.xdg-desktop-portal-wlr - ]; - }; - services = { - ratbagd.enable = true; - flatpak.enable = true; - etesync-dav.enable = true; - connman.extraConfig = '' + #extraModulePackages = [ pkgs.linuxPackages.vendor-reset ]; + # NOTE: A regression appears to have happend between 5.10 and 5.12 + # which leads to the RX590 to have the fence fallback timer on + # sdma0 time out (whatever this means). Maybe bisect? + kernelPackages = pkgs.linuxPackages_zen; + }; + xdg.portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-wlr + ]; + }; + services = { + ratbagd.enable = true; + flatpak.enable = true; + etesync-dav.enable = true; + connman.extraConfig = '' WriteResolvConf=false ''; - udev = { - #packages = with pkgs; [ key-mapper ]; - extraRules = '' - KERNEL=="uinput", GROUP="input", MODE="0660" - ''; + xserver = { + enable = true; + layout = "de"; + libinput.enable = true; + displayManager.gdm = { + enable = true; + wayland = true; }; - gnome.gnome-keyring.enable = true; }; - - environment.sessionVariables = { - # sway - #"_JAVA_AWT_NONREPARENTING" = 1; + }; + + environment.sessionVariables = { + # sway + #"_JAVA_AWT_NONREPARENTING" = 1; # Wayland "QT_QPA_PLATFORM" = "wayland-egl"; @@ -148,17 +194,6 @@ in mkHost config { Restart = "always"; }; }; - #key-mapper = { - # description = "A tool to change the mapping of your input device buttons"; - # wantedBy = [ "default.target" ]; - # serviceConfig = { - # Type = "simple"; - # ExecStart = "${pkgs.key-mapper}/bin/key-mapper-service"; - # Restart = "always"; - # # NOTE: The Tartarus may not be connected, so don't fail if we cannot set the preset - # ExecPostStart = "${pkgs.key-mapper}/bin/key-mapper --command start --preset NOOP --device \"Razer Razer Tartarus V2\"; exit 0"; - # }; - #}; replaysorcery = { description = "An open-source, instant-replay solution for Linux"; #wantedBy = [ "default.target" ]; diff --git a/lib/baseSystem.nix b/lib/baseSystem.nix new file mode 100644 index 0000000..61f78a7 --- /dev/null +++ b/lib/baseSystem.nix @@ -0,0 +1,179 @@ +{ config, pkgs, lib, ... }: + +let + network = import ./network.nix; + isVM = config.ptw.system.isVM; + wireless = config.ptw.system.wireless; +in { + time.timeZone = "Europe/Berlin"; + ostylk.nftables = { + enable = true; + + tables.firewall = { + family = "inet"; + chains = { + non-libvirt.extraConfig = let + deviceIPString = lib.concatStringsSep "," (with network; [ + miku nishimiya tamaki mashu # ayame + ]); + in '' + # Accept traffic from my devices + ip saddr != { ${deviceIPString} } drop + ''; + input.extraConfig = '' + type filter hook input priority 0 + + ct state { established, related } accept + iif lo accept + # TODO + #iif {primaryInterfaceWrapper} goto non-libvirt + ''; + }; + }; + }; + networking = { + useDHCP = false; # Done by the network manager + networkmanager.enable = false; + + #interfaces.*.useDHCP = false; + + hostName = config.ptw.system.hostName; + wireless.enable = (if wireless then true else lib.mkForce false); + hosts = lib.mkIf (!isVM) { + "${network.miku}" = [ "miku.local" ]; + "${network.nishimiya}" = [ "nishimiya.local" ]; + #"${network.ayame}" = [ "ayame.local" ]; + "${network.tamaki}" = [ "tamaki.local" ]; + "${network.mashu}" = [ "mashu.local" ]; + }; + }; + + i18n.defaultLocale = "en_GB.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "de"; + }; + + users = { + mutableUsers = false; + + extraUsers = { + root = { + # Disable root login + hashedPassword = "*"; + }; + }; + }; + + environment = { + systemPackages = with pkgs; [ + htop + vim + git # Otherwise we cannot install home-manager + git-crypt + gnupg + python3 + + # RT scheduling + rtkit + ] ++ lib.optionals (!isVM) (with pkgs; [ gopass ]); + + sessionVariables = { + # Prevent us from having to always type it out + NIXOS_CONFIG = "/home/${config.ptw.system.singleUser}/Development/Personal/nixos-config/hosts/${config.networking.hostName}.nix"; + }; + }; + + fonts.fonts = with pkgs; [ + # CJK fonts + source-han-sans source-han-serif + # Coding fonts + source-code-pro + # Icon fonts + nerdfonts + ]; + + # We don't tolerate non-free software, except for Steam and Linux firmware + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "firmwareLinuxNonfree" "microcodeAmd" "microcodeIntel" + "steam" "steam-original" "steam-runtime" + "discord" + ]; + + services = { + connman.enable = true; + + # TODO: Is this correct? Maybe run once + timesyncd.enable = false; + + # Everyone needs sound + pipewire = { + enable = true; + pulse.enable = true; + jack.enable = true; + alsa.enable = true; + alsa.support32Bit = true; + }; + + # On desktop: Monitor keyboards, mice, ... + # On portable devices: Monitor their battery + upower.enable = true; + + # What generated entropy? + haveged.enable = true; + + printing.enable = lib.mkDefault false; + avahi.enable = false; + + # For debugging. + # TODO: Lock to known IPs and keys + sshd.enable = true; + + # Prevent unexpected OOM situations with heavy swapping + earlyoom = { + enable = true; + enableNotifications = true; + }; + }; + + # Don't wait for a network connection + systemd.services.NetworkManager-wait-online.enable = false; + + security.sudo.extraConfig = '' + Defaults env_keep += "NIXOS_CONFIG" + ''; + + hardware = { + enableRedistributableFirmware = true; + # This is a Pipewire household! + pulseaudio.enable = false; + + opengl = { + enable = true; + driSupport32Bit = true; + driSupport = true; + extraPackages = with pkgs; [ vaapiVdpau libvdpau-va-gl ]; + }; + + # Only a subset of my devices have bluetooth + bluetooth = lib.mkIf wireless { + enable = true; + }; + } // (if wireless then { + wifiInterface = config.ptw.system.wifiInterface; + } else {}); + + nix.package = pkgs.nixUnstable; + nix.extraOptions = '' + experimental-features = nix-command flakes ca-references + ''; + + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + }; + + system.stateVersion = "21.05"; +} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..839be58 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,22 @@ +{ inputs, config, lib, ... }: + +{ + # Creates an overlay from a given input + mkOverlayFromInput = name: input: { + nixpkgs.overlays = [ + (final: prev: + prev.lib.attrsets.setAttrByPath [ name ] ( + import input { + system = prev.system; + + overlays = [ inputs.self.overlay ]; + #config = config.nixpkgs.config; + } + )) + ]; + }; + mkSystem = import ./mkSystem.nix { + inherit inputs config lib; + }; + network = import ./network.nix; +} diff --git a/lib/flake.nix b/lib/flake.nix new file mode 100644 index 0000000..2268ad9 --- /dev/null +++ b/lib/flake.nix @@ -0,0 +1,7 @@ +{ flake-utils, lib }: + +let + defaultLinuxSystems = lib.filter (system: lib.strings.hasSuffix "-linux" system) flake-utils.lib.defaultSystems; +in { + eachDefaultLinuxSystem = arg: flake-utils.lib.eachSystem defaultLinuxSystems arg; +} diff --git a/lib/helpers/kanshi.nix b/lib/helpers/kanshi.nix new file mode 100644 index 0000000..a908e43 --- /dev/null +++ b/lib/helpers/kanshi.nix @@ -0,0 +1,45 @@ +{ + mkWallpaperScript = { pkgs, config }: let + wallpapers = "/home/${config.ptw.system.singleUser}/Data/Wallpaper"; + wallpapersHorizontal = "${wallpapers}/horizontal"; + wallpapersVertical = "${wallpapers}/vertical"; + in pkgs.writeShellScript "wallpaper.sh" '' + set -x + [[ $# -lt 1 ]] && echo "No profile specified" && exit 1 + + random_file() { + find "$1" -maxdepth 1 -type f | shuf -n 1 + } + + setbg() { + # Sets the background of $1 to $2 + swaymsg "output \"$1\" background $2 fill" + } + + case $1 in + homeMultihead) + horiz=$(random_file ${wallpapersHorizontal}) + vert=$(random_file ${wallpapersVertical}) + + setbg "DP-2" $horiz + setbg "HDMI-A-3" $vert + ;; + genericMultihead) + horiz1=$(random_file ${wallpapersHorizontal}) + horiz2=$(random_file ${wallpapersHorizontal}) + + setbg "eDP-1" $horiz1 + setbg "HDMI-A-1" $horiz2 + ;; + laptop) + horiz=$(random_file ${wallpapersHorizontal}) + + setbg "eDP-1" $horiz + ;; + esac + ''; + mkProfile = { script, name, outputs }: { + outputs = outputs; + exec = "${script} ${name}"; + }; +} diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix new file mode 100644 index 0000000..0df99e5 --- /dev/null +++ b/lib/mkSystem.nix @@ -0,0 +1,48 @@ +{ inputs, config, lib, nur, emacs, ... }: + +{ + hostConfigFile +, architecture ? "x86_64-linux" +}: let + pkgs = inputs.nixpkgs; + config = pkgs.lib; + network = import ./network.nix; + + util = import ./default.nix { + inherit inputs config lib; + }; + + #primaryInterfaceWrapper = if wifiInterface != "" && primaryInterface == "" then wifiInterface else primaryInterface; +in inputs.nixpkgs.lib.nixosSystem { + system = architecture; + + modules = [ + inputs.home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + } + + (util.mkOverlayFromInput "stable" inputs.stable) + (util.mkOverlayFromInput "unstable" inputs.nixpkgs) + + { + nixpkgs.overlays = [ + nur.overlay + emacs.overlay + (import ../packages) + ]; + } + + (import ../modules) + + inputs.ostylk.nixosModules.nftables + + (import ./baseSystem.nix) + (import hostConfigFile) + #(extraOptions baseConfig) + ]; + + specialArgs = { + inherit inputs; + }; +} diff --git a/modules/network.nix b/lib/network.nix similarity index 63% rename from modules/network.nix rename to lib/network.nix index c08ed11..17e1499 100644 --- a/modules/network.nix +++ b/lib/network.nix @@ -4,7 +4,7 @@ rec { # A collection of IP addresses for various uses miku = "${network-base}.38"; nishimiya = "${network-base}.21"; - ayame = "${network-base}.35"; # TODO: That one's wrong + #ayame = "${network-base}.35"; # TODO: That one's wrong tamaki = "${network-base}.27"; - mashu = "${network-base}.52"; + mashu = "${network-base}.52"; # TODO: That's wrong } diff --git a/modules/base.nix b/modules/base.nix new file mode 100644 index 0000000..ddfa243 --- /dev/null +++ b/modules/base.nix @@ -0,0 +1,26 @@ +{ config, lib, ... }: + +{ + options.ptw.system = { + singleUser = lib.mkOption { + type = lib.types.str; + example = "PapaTutuWawa"; + readOnly = true; + description = "The username of this single-user system"; + }; + wireless = lib.mkEnableOption "Enable wireless functionality"; + wifiInterface = lib.mkOption { + type = lib.types.str; + description = "The wireless interface to use for various options"; + }; + primaryInterface = lib.mkOption { + type = lib.types.str; + description = "The primary network interface to use"; + }; + hostName = lib.mkOption { + type = lib.types.str; + description = "The hostname to use"; + }; + isVM = lib.mkEnableOption "Sets whether the treat the host as VM"; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 798df58..009ab70 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,8 +1,48 @@ { - lib, pkgs -}: + imports = [ + # Hardware modules + ./hardware/amdgpu.nix + ./hardware/amd.nix + ./hardware/intel.nix + ./hardware/mobile.nix + ./hardware/surface-pro6.nix + ./hardware/wifi.nix -{ - mkHost = import ./host.nix { lib = lib; pkgs = pkgs; }; - mkSandbox = pkgs.callPackage ./sandbox.nix {}; + # Programs + ./programs/alacritty + ./programs/emacs + ./programs/firefox + ./programs/gnome + ./programs/gnome-terminal + ./programs/i18n # TODO: Move to toplevel + ./programs/mpv + ./programs/git + ./programs/sway + ./programs/swaync + ./programs/tmux + ./programs/waybar + ./programs/zsh + ./programs/xournalpp + + # Services + ./services/kanshi + ./services/key-mapper + ./services/gamemode + + # User + #./users/default.nix + ./users/alexander.nix + ./users/fuck-xi.nix + + # Offloading + ./offloading/builder.nix + ./offloading/offload.nix + + # Virtualisation + ./virtualisation/default.nix + ./virtualisation/gaming.nix + + # Pure options + ./base.nix + ]; } diff --git a/modules/hardware/amd.nix b/modules/hardware/amd.nix index c069d2f..3c35b81 100644 --- a/modules/hardware/amd.nix +++ b/modules/hardware/amd.nix @@ -1,5 +1,13 @@ -{ ... }: +{ config, lib, ... }: -{ - hardware.cpu.amd.updateMicrocode = true; +let + cfg = config.ptw.hardware.amdcpu; +in { + options.ptw.hardware.amdcpu = { + enable = lib.mkEnableOption "Enable support for AMD CPUs"; + }; + + config = lib.mkIf cfg.enable { + hardware.cpu.amd.updateMicrocode = true; + }; } diff --git a/modules/hardware/amdgpu.nix b/modules/hardware/amdgpu.nix index 991934a..de80da8 100644 --- a/modules/hardware/amdgpu.nix +++ b/modules/hardware/amdgpu.nix @@ -1,11 +1,19 @@ { - pkgs, ... + config, lib, pkgs, ... }: -{ - environment.systemPackages = with pkgs; [ - unstable.mesa - unstable.firmwareLinuxNonfree - ]; - services.xserver.videoDrivers = [ "amdgpu" ]; +let + cfg = config.ptw.hardware.amdgpu; +in { + options.ptw.hardware.amdgpu = { + enable = lib.mkEnableOption "Enable support for AMDGPU GPUs"; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + unstable.mesa + unstable.firmwareLinuxNonfree + ]; + services.xserver.videoDrivers = [ "amdgpu" ]; + }; } diff --git a/modules/hardware/intel.nix b/modules/hardware/intel.nix index b336996..7195240 100644 --- a/modules/hardware/intel.nix +++ b/modules/hardware/intel.nix @@ -1,13 +1,19 @@ -{ - pkgs, ... -}: +{ config, lib, pkgs, ... }: -{ - hardware = { - cpu.intel.updateMicrocode = true; - # NOTE: Assuming each Intel CPU has integrated graphics - opengl.extraPackages = with pkgs; [ vaapiIntel intel-media-driver ]; +let + cfg = config.ptw.hardware.intel; +in { + options.ptw.hardware.intel = { + enable = lib.mkEnableOption "Enable support for Intel CPUs"; + }; + + config = lib.mkIf cfg.enable { + hardware = { + cpu.intel.updateMicrocode = true; + # NOTE: Assuming each Intel CPU has integrated graphics + opengl.extraPackages = with pkgs; [ vaapiIntel intel-media-driver ]; + }; + # TODO: Remove? + services.xserver.videoDrivers = [ "modesetting" "fbdev" ]; }; - # TODO: Remove? - services.xserver.videoDrivers = [ "modesetting" "fbdev" ]; } diff --git a/modules/hardware/mobile.nix b/modules/hardware/mobile.nix index 7aa68c3..8d21bdc 100644 --- a/modules/hardware/mobile.nix +++ b/modules/hardware/mobile.nix @@ -1,9 +1,17 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: # Special options for mobile devices -{ - # Battery savings - #services.tlp.enable = true; +let + cfg = config.ptw.hardware.mobile; +in { + options.ptw.hardware.mobile = { + enable = lib.mkEnableOption "Enable support for mobile devices"; + }; - hardware.sensor.iio.enable = true; + config = lib.mkIf cfg.enable { + # Battery savings + #services.tlp.enable = true; + + hardware.sensor.iio.enable = true; + }; } diff --git a/modules/hardware/surface-pro6.nix b/modules/hardware/surface-pro6.nix index 9135f9c..5dcc155 100644 --- a/modules/hardware/surface-pro6.nix +++ b/modules/hardware/surface-pro6.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: let fetchurl = pkgs.fetchurl; @@ -12,66 +12,72 @@ let sha256 = sha256; }; }; + cfg = config.ptw.hardware.surface; in { - environment.etc = { - "ipts.conf".text = '' + options.ptw.hardware.surface = { + enable = lib.mkEnableOption "Enable support for the Microsoft Surface Pro 6"; + }; + + config = lib.mkIf cfg.enable { + environment.etc = { + "ipts.conf".text = '' [Config] BlockOnPalm = true ''; - "thermald/thermal-cpu-cdev-order.xml".source = fetchurl { - url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/surface_pro_5/thermal-conf.xml.auto.mobile"; - sha256 = "1wsrgad6k4haw4m0jjcjxhmj4742kcb3q8rmfpclbw0czm8384al"; - }; - }; - - powerManagement = { - enable = true; - cpuFreqGovernor = "powersave"; - }; - hardware.video.hidpi.enable = true; - - systemd.services.iptsd = { - description = "Userspace daemon for Intel Precise Touch & Stylus"; - wantedBy = [ "multi-user.target" ]; - wants = [ "dev-ipts-15.device" ]; - after = [ "dev-ipts-15.device" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.iptsd}/bin/iptsd"; - }; - }; - environment.systemPackages = with pkgs; [ iptsd surface-control ]; - services = { - udev.packages = with pkgs; [ iptsd surface-control ]; - thermald = { - enable = true; - configFile = fetchurl { - url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/thermal-conf.xml"; - sha256 = "1xj70n9agy41906jgm4yjmsx58i7pzsizpvv3rkzq78k95qjfmc9"; + "thermald/thermal-cpu-cdev-order.xml".source = fetchurl { + url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/surface_pro_5/thermal-conf.xml.auto.mobile"; + sha256 = "1wsrgad6k4haw4m0jjcjxhmj4742kcb3q8rmfpclbw0czm8384al"; }; }; - }; - boot = { - kernelPackages = pkgs.linuxPackages_5_13; - kernelPatches = [ - (mkPatch "0001-surface3-oemb" "1h5f4qgrv74x8q02f29xfia9imcm6svh5gv5vb5izxx6w5i6c9fh") - #(mkPatch "0002-mwifiex" "1qn5lqhbg67j1226msiijq42zdjwmvxzyfd5q366hlczcsw7a7r2") - (mkPatch "0003-ath10k" "0zwyb1vksh6sjbwy5fp2c108m6fqzrv78cz3a296cff550ldn0fj") - (mkPatch "0004-ipts" "0ap5li17zyvba1zx4ryyyk42m00rg5ympj2n24g5ylrld0n2xc3x") - (mkPatch "0005-surface-sam-over-hid" "1vm4v84zbyiiqwby3cr7n8ffibx072rb7rhrl5hv37dsdr03gsa3") - (mkPatch "0006-surface-sam" "1fi0w9bnfnwllmypk3llc58dmfsvx34772g8c52dgi4h9wsgnbhj") - (mkPatch "0007-surface-hotplug" "0g3fkc12pc15aqq6nqk1zfp99lj1wj7cgc1n9691bp8fhqx5aj28") - (mkPatch "0008-surface-typecover" "0803nd0w5rv17kwk3y577pm22zwzpcb52ddlkanm7jrbsrhk130f") - #(mkPatch "0009-cameras" "1i5c16bx8drzagv5nkvmsyixvsz3w75lblabsmgxlh1znxsh7cj5") - (mkPatch "0010-amd-gpio" "0qibdak0ivsch0r5kxd5hhmvw7rd75xy9mmxjbcmysv8q2y9m6hn") # TODO: Maybe drop - (mkPatch "0011-amd-s0ix" "0awv32wqwkjsxs1bhg82rqq3c4ni2f9vsdm7iscilbad28ngdab8") # TODO: Maybe drop + powerManagement = { + enable = true; + cpuFreqGovernor = "powersave"; + }; + hardware.video.hidpi.enable = true; + + systemd.services.iptsd = { + description = "Userspace daemon for Intel Precise Touch & Stylus"; + wantedBy = [ "multi-user.target" ]; + wants = [ "dev-ipts-15.device" ]; + after = [ "dev-ipts-15.device" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.iptsd}/bin/iptsd"; + }; + }; + environment.systemPackages = with pkgs; [ iptsd surface-control ]; + services = { + udev.packages = with pkgs; [ iptsd surface-control ]; + thermald = { + enable = true; + configFile = fetchurl { + url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/thermal-conf.xml"; + sha256 = "1xj70n9agy41906jgm4yjmsx58i7pzsizpvv3rkzq78k95qjfmc9"; + }; + }; + }; - { - name = "surface-config"; - patch = null; - # Options from https://github.com/linux-surface/linux-surface/blob/master/configs/surface-5.13.config - extraConfig = '' + boot = { + kernelPackages = pkgs.linuxPackages_5_13; + kernelPatches = [ + (mkPatch "0001-surface3-oemb" "1h5f4qgrv74x8q02f29xfia9imcm6svh5gv5vb5izxx6w5i6c9fh") + #(mkPatch "0002-mwifiex" "1qn5lqhbg67j1226msiijq42zdjwmvxzyfd5q366hlczcsw7a7r2") + (mkPatch "0003-ath10k" "0zwyb1vksh6sjbwy5fp2c108m6fqzrv78cz3a296cff550ldn0fj") + (mkPatch "0004-ipts" "0ap5li17zyvba1zx4ryyyk42m00rg5ympj2n24g5ylrld0n2xc3x") + (mkPatch "0005-surface-sam-over-hid" "1vm4v84zbyiiqwby3cr7n8ffibx072rb7rhrl5hv37dsdr03gsa3") + (mkPatch "0006-surface-sam" "1fi0w9bnfnwllmypk3llc58dmfsvx34772g8c52dgi4h9wsgnbhj") + (mkPatch "0007-surface-hotplug" "0g3fkc12pc15aqq6nqk1zfp99lj1wj7cgc1n9691bp8fhqx5aj28") + (mkPatch "0008-surface-typecover" "0803nd0w5rv17kwk3y577pm22zwzpcb52ddlkanm7jrbsrhk130f") + #(mkPatch "0009-cameras" "1i5c16bx8drzagv5nkvmsyixvsz3w75lblabsmgxlh1znxsh7cj5") + (mkPatch "0010-amd-gpio" "0qibdak0ivsch0r5kxd5hhmvw7rd75xy9mmxjbcmysv8q2y9m6hn") # TODO: Maybe drop + (mkPatch "0011-amd-s0ix" "0awv32wqwkjsxs1bhg82rqq3c4ni2f9vsdm7iscilbad28ngdab8") # TODO: Maybe drop + + { + name = "surface-config"; + patch = null; + # Options from https://github.com/linux-surface/linux-surface/blob/master/configs/surface-5.13.config + extraConfig = '' # # Surface Aggregator Module # @@ -147,7 +153,8 @@ in { MFD_INTEL_LPSS_PCI y INTEL_IDMA64 y ''; - } - ]; + } + ]; + }; }; } diff --git a/modules/hardware/wifi.nix b/modules/hardware/wifi.nix index 6669d52e081f07972a004b021107c2e6dfff8830..0d068cf8a4db0f7927a49f58130a3f58e67794aa 100644 GIT binary patch literal 1357 zcmV-T1+w}8M@dveQdv+`09-A{*+U~5N*)doO4Eha08r(dPM)b&w#3T4%z!4A;YF=B z3`&GpKYo-I90(XNpinmy8LcDIbp5`RSIML5zG01m^>+KUH=)wm=1SdSOg=gO8I6fE z(_6mtD#BdBUOd)nL^SFfwaW}aWkI!MrwwcC)7c|wnO?#;^8v6MjOvDa#jHvj-al7- z21T?!f!?4)iOhpQpn86!!VPfFUGUkG(j13)pNXH`2r|m$N#hX~bAzyR2fRq@L&3(9 zoaZqOaflLywF3337Y7@1C=u!1bhKmKd~w*SFk=>Nn+y)UL!|SL9ekbI zS@(X@U*(D%5PgE^6zQ%cFB8{FtDtgi;?*++4Dkky&9yV+Ru}$O^!ku0Ny!sH&W4@1JD?b?s!|#WqeOEE@?obX^e*@^|#TdjS4F2w2RrSi9bdkl{nWA^y-G7dy=yfC5CAE$`4gA?G^=kx7CHh}E@QNpG!YV#{j02Vk>DEr2P@ zAuzYHT%87$s&9rjAGuZy>E;ac7CrlkoeeFg$ICZt?*vw|$=F@-tS6+p{L2-T$XP{z zksuSpGu75_+ow_Sn3xMA!PG4YK59ix2!|m9C@#srNj%)FLI-_`U{7)s3q4C|);?F0 zuS{4P8DVdnFGi*E+M2X=#VwaZ^2sghpuB0Ap8qGkqM4SxN6g=o&9EM1)L6@4>Y87n zG26~ir}$|^ih6cg<9-Azzn^kz7Up!v&2&Fi42}KOvJV0iw5Q26RW(Hq*TZuN^n^y0 zzAhIBA!Ln2vigQQCCA~Y8;%UpKAzr2?%s;43+3%galtp1wV{BVZOz8T?ob}m=`WI} zir8C#52F(m2sV)s&)Hr3r}F%YeAbc#l0Hmh1ZF(m{+XR>?Llg(v}juqR5OX)O1 zFu~BIP_kpH3xGntTtdu(h`aDvL6E@{sTY*;pB|~luJy{*P!`C^bCOR?NfBA&K_`=o zNepL2{VXW?(6(sCt6E=7%@M73Sfu1on=MC?Qa6f38Fv1I4%+%$w~jp{g{~b-pcAm7 Pr!yy;oOG0(P`MjB>9Lnh literal 1244 zcmV<21S9(ZM@dveQdv+`04t#iF)_&kpOa66ib3+(YMV~4M0g63|3sZoWV{5;ANKZH zpz4FA^hrhp_G`&wrU#Jx_$p|GxsvOpJ05InPqNYsVwlH_5Mp%Fc6Uw+TRNQoU3d2f z)Ubic(cM_~oL-ST{widY{4k)H@E1g1{enx8_GUH0g_A(Wpd0K_8Yu)ejbP#qeqC3p zrRu>!J_aw9kKLe%CbA5u4!`Swlt=t>ObBu+n2%f@CKr+l*HCGVt>YnrwShc_^GW7^ zNlj5=BNDxpA}F_h-@VrzMf-_IEb4ENJUyRW`yq(o7k3K|UbKgI1BB>|q@9sCIjGIR zbTFP*2HZ|#CVN^kW8N7dBd*;pj}du~`gk#vhNe?kQQ;DnkHLLL(b^f3c{`K9^Smh47HwzIx)o9(tW=^KG6 z2ML2ZQyIhSN#u?7r{zq90fAQB8xn}-u{B7XcnatoA#GYhsF8If9KSr5FIfxU4d% z?>jsf67(!pk9Iaymz3F+I`^x*${sa{bM*1QuOFX0ZZUBzhsQCcnljgWVVx~8V8m7!Q*ZEY0@h@l&2DSgp&IG&qdI>WC)8HK+NJOM%eko`*{<}S_#7M2Jo}3W!f4=D0lbE`ai3dV(9)Tb^VB{VJ*;N|=Td3x)fN&yBF`lQBh#3lzj z5Oq(8-{*N9M68~;Roko1jlq~TZ$hdYy)=e1sPj~O#WOAXwQ!;5FbKi6JIEmW5SlUN zP8XuQWn}^gJG-nKp_YaqcaWk zIycNGf7^opQYSCj75m<4_0zmJl~*%yiUj9+f6m*-UNtml&$pl1&e5)>M;4<>l|+j$ z-{*CDQyndw;0cPhZgCkaXbb~bZR?ax1R;kPDr!A)X;|5+AXQtxmDo1_+|73u1GTk# zzcl;FB3hgzGWFol&s;Z2iKGxCUYn3%($iZ|DAFG^Eoc^)=IYFtbc+wk4jj&n|uDmMF;#>99X0J4u?0=aUO*TO}r9 zj0i;E6-6A|B"; + save_to_clipboard = true; + }; + + cursor = { + style = "Block"; + unfocused_hollow = true; + }; + + live_config_reload = true; + enable_experimental_conpty_backend = false; + alt_send_esc = true; + + key_bindings = [ + { + key = "Paste"; + action = "Paste"; + } + { + key = "Copy"; + action = "Copy"; + } + { + key = "L"; + mods = "Control"; + action = "ClearLogNotice"; + } + { + key = "L"; + mods = "Control"; + chars = "\\x0c"; + } + { + key = "Home"; + chars = "\\x1bOH"; + mode = "AppCursor"; + } + { + key = "Home"; + chars = "\\x1b[H"; + mode = "~AppCursor"; + } + { + key = "End"; + chars = "\\x1bOF"; + mode = "AppCursor"; + } + { + key = "End"; + chars = "\\x1b[F"; + mode = "~AppCursor"; + } + { + key = "PageUp"; + mods = "Shift"; + action = "ScrollPageUp"; + mode = "~Alt"; + } + { + key = "PageUp"; + mods = "Shift"; + chars = "\\x1b[5;2~"; + mode = "Alt"; + } + { + key = "PageDown"; + mods = "Control"; + chars = "\\x1b[6;5~"; + } + { + key = "PageDown"; + chars = "\\x1b[6~"; + } + { + key = "Tab"; + mods = "Shift"; + chars = "\\x1b[Z"; + } + { + key = "Back"; + chars= "\\x7f"; + } + { + key = "Back"; + mods = "Alt"; + chars = "\\x1b\\x7f"; + } + { + key = "Insert"; + chars = "\\x1b[2~"; + } + { + key = "Delete"; + chars = "\\x1b[3~"; + } + { + key = "Left"; + mods = "Shift"; + chars = "\\x1b[1;2D"; + } + { + key = "Left"; + mods = "Control"; + chars = "\\x1b[1;5D"; + } + { + key = "Left"; + mods = "Alt"; + chars = "\\x1b[1;3D"; + } + { + key = "Left"; + chars = "\\x1b[D"; + mode = "~AppCursor"; + } + { + key = "Left"; + chars = "\\x1bOD"; + mode = "AppCursor"; + } + { + key = "Right"; + mods = "Shift"; + chars = "\\x1b[1;2C"; + } + { + key = "Right"; + mods = "Control"; + chars = "\\x1b[1;5C"; + } + { + key = "Right"; + mods = "Alt"; + chars = "\\x1b[1;3C"; + } + { + key = "Right"; + chars = "\\x1b[C"; + mode = "~AppCursor"; + } + { + key = "Right"; + chars = "\\x1bOC"; + mode = "AppCursor"; + } + { + key = "Up"; + mods = "Shift"; + chars = "\\x1b[1;2A"; + } + { + key = "Up"; + mods = "Control"; + chars = "\\x1b[1;5A"; + } + { + key = "Up"; + mods = "Alt"; + chars = "\\x1b[1;3A"; + } + { + key = "Up"; + chars = "\\x1b[A"; + mode = "~AppCursor"; + } + { + key = "Up"; + chars = "\\x1bOA"; + mode = "AppCursor"; + } + { + key = "Down"; + mods = "Shift"; + chars = "\\x1b[1;2B"; + } + { + key = "Down"; + mods = "Control"; + chars = "\\x1b[1;5B"; + } + { + key = "Down"; + mods = "Alt"; + chars = "\\x1b[1;3B"; + } + { + key = "Down"; + chars = "\\x1b[B"; + mode = "~AppCursor"; + } + { + key = "Down"; + chars = "\\x1bOB"; + mode = "AppCursor"; + } + { + key = "F1"; + chars = "\\x1bOP"; + } + { + key = "F2"; + chars = "\\x1bOQ"; + } + { + key = "F3"; + chars = "\\x1bOR"; + } + { + key = "F4"; + chars = "\\x1bOS"; + } + { + key = "F5"; + chars = "\\x1b[15~"; + } + { + key = "F6"; + chars = "\\x1b[17~"; + } + { + key = "F7"; + chars = "\\x1b[18~"; + } + { + key = "F8"; + chars = "\\x1b[19~"; + } + { + key = "F9"; + chars = "\\x1b[20~"; + } + { + key = "F10"; + chars = "\\x1b[21~"; + } + { + key = "F11"; + chars = "\\x1b[23~"; + } + { + key = "F12"; + chars = "\\x1b[24~"; + } + { + key = "F1"; + mods = "Shift"; + chars = "\\x1b[1;2P"; + } + { + key = "F2"; + mods = "Shift"; + chars = "\\x1b[1;2Q"; + } + { + key = "F3"; + mods = "Shift"; + chars = "\\x1b[1;2R"; + } + { + key = "F4"; + mods = "Shift"; + chars = "\\x1b[1;2S"; + } + { + key = "F5"; + mods = "Shift"; + chars = "\\x1b[15;2~"; + } + { + key = "F6"; + mods = "Shift"; + chars = "\\x1b[17;2~"; + } + { + key = "F7"; + mods = "Shift"; + chars = "\\x1b[18;2~"; + } + { + key = "F8"; + mods = "Shift"; + chars = "\\x1b[19;2~"; + } + { + key = "F9"; + mods = "Shift"; + chars = "\\x1b[20;2~"; + } + { + key = "F10"; + mods = "Shift"; + chars = "\\x1b[21;2~"; + } + { + key = "F11"; + mods = "Shift"; + chars = "\\x1b[23;2~"; + } + { + key = "F12"; + mods = "Shift"; + chars = "\\x1b[24;2~"; + } + { + key = "F1"; + mods = "Control"; + chars = "\\x1b[1;5P"; + } + { + key = "F2"; + mods = "Control"; + chars = "\\x1b[1;5Q"; + } + { + key = "F3"; + mods = "Control"; + chars = "\\x1b[1;5R"; + } + { + key = "F4"; + mods = "Control"; + chars = "\\x1b[1;5S"; + } + { + key = "F5"; + mods = "Control"; + chars = "\\x1b[15;5~"; + } + { + key = "F6"; + mods = "Control"; + chars = "\\x1b[17;5~"; + } + { + key = "F7"; + mods = "Control"; + chars = "\\x1b[18;5~"; + } + { + key = "F8"; + mods = "Control"; + chars = "\\x1b[19;5~"; + } + { + key = "F9"; + mods = "Control"; + chars = "\\x1b[20;5~"; + } + { + key = "F10"; + mods = "Control"; + chars = "\\x1b[21;5~"; + } + { + key = "F11"; + mods = "Control"; + chars = "\\x1b[23;5~"; + } + { + key = "F12"; + mods = "Control"; + chars = "\\x1b[24;5~"; + } + { + key = "F1"; + mods = "Alt"; + chars = "\\x1b[1;6P"; + } + { + key = "F2"; + mods = "Alt"; + chars = "\\x1b[1;6Q"; + } + { + key = "F3"; + mods = "Alt"; + chars = "\\x1b[1;6R"; + } + { + key = "F4"; + mods = "Alt"; + chars = "\\x1b[1;6S"; + } + { + key = "F5"; + mods = "Alt"; + chars = "\\x1b[15;6~"; + } + { + key = "F6"; + mods = "Alt"; + chars = "\\x1b[17;6~"; + } + { + key = "F7"; + mods = "Alt"; + chars = "\\x1b[18;6~"; + } + { + key = "F8"; + mods = "Alt"; + chars = "\\x1b[19;6~"; + } + { + key = "F9"; + mods = "Alt"; + chars = "\\x1b[20;6~"; + } + { + key = "F10"; + mods = "Alt"; + chars = "\\x1b[21;6~"; + } + { + key = "F11"; + mods = "Alt"; + chars = "\\x1b[23;6~"; + } + { + key = "F12"; + mods = "Alt"; + chars = "\\x1b[24;6~"; + } + { + key = "F1"; + mods = "Super"; + chars = "\\x1b[1;3P"; + } + { + key = "F2"; + mods = "Super"; + chars = "\\x1b[1;3Q"; + } + { + key = "F3"; + mods = "Super"; + chars = "\\x1b[1;3R"; + } + { + key = "F4"; + mods = "Super"; + chars = "\\x1b[1;3S"; + } + { + key = "F5"; + mods = "Super"; + chars = "\\x1b[15;3~"; + } + { + key = "F6"; + mods = "Super"; + chars = "\\x1b[17;3~"; + } + { + key = "F7"; + mods = "Super"; + chars = "\\x1b[18;3~"; + } + { + key = "F8"; + mods = "Super"; + chars = "\\x1b[19;3~"; + } + { + key = "F9"; + mods = "Super"; + chars = "\\x1b[20;3~"; + } + { + key = "F10"; + mods = "Super"; + chars = "\\x1b[21;3~"; + } + { + key = "F11"; + mods = "Super"; + chars = "\\x1b[23;3~"; + } + { + key = "F12"; + mods = "Super"; + chars = "\\x1b[24;3~"; + } + { + key = "NumpadEnter"; + chars = "\\n"; + } + ]; }; - - scrolling = { - history = 10000; - multiplier = 3; - }; - - font = { - size = config.services.alacritty.fontSize; - offset = { - x = 0; - y = 0; - }; - glyph_offset = { - x = 0; - y = 0; - }; - use_thin_strokes = true; - }; - debug = { - render_timer = false; - persistent_logging = false; - }; - - draw_bold_text_with_bright_colors = true; - - colors = { - primary = { - background = "0x1e282d"; - foreground = "0xc4c7d1"; - }; - normal = { - black = "0x666666"; - red = "0xeb606b"; - green = "0xc3e88d"; - yellow = "0xf7eb95"; - blue = "0x80cbc4"; - magenta = "0xff2f90"; - cyan = "0xaeddff"; - white = "0xffffff"; - }; - bright = { - black = "0xff262b"; - red = "0xeb606b"; - green = "0xc3e88d"; - yellow = "0xf7eb95"; - blue = "0x7dc6bf"; - magenta = "0x6c71c4"; - cyan = "0x35434d"; - white = "0xffffff"; - }; - }; - - background_opacity = 0.7; - mouse_bindings = [ { - mouse = "Middle"; - action = "PasteSelection"; - } ]; - mouse = { - double_click = { - threshold = 300; - }; - triple_click = { - threshold = 300; - }; - - hide_when_typing = false; - }; - - selection = { - semantic_scape_chars = ",│`|:\"' ()[]{}<>"; - save_to_clipboard = true; - }; - - cursor = { - style = "Block"; - unfocused_hollow = true; - }; - - live_config_reload = true; - enable_experimental_conpty_backend = false; - alt_send_esc = true; - - key_bindings = [ - { - key = "Paste"; - action = "Paste"; - } - { - key = "Copy"; - action = "Copy"; - } - { - key = "L"; - mods = "Control"; - action = "ClearLogNotice"; - } - { - key = "L"; - mods = "Control"; - chars = "\\x0c"; - } - { - key = "Home"; - chars = "\\x1bOH"; - mode = "AppCursor"; - } - { - key = "Home"; - chars = "\\x1b[H"; - mode = "~AppCursor"; - } - { - key = "End"; - chars = "\\x1bOF"; - mode = "AppCursor"; - } - { - key = "End"; - chars = "\\x1b[F"; - mode = "~AppCursor"; - } - { - key = "PageUp"; - mods = "Shift"; - action = "ScrollPageUp"; - mode = "~Alt"; - } - { - key = "PageUp"; - mods = "Shift"; - chars = "\\x1b[5;2~"; - mode = "Alt"; - } - { - key = "PageDown"; - mods = "Control"; - chars = "\\x1b[6;5~"; - } - { - key = "PageDown"; - chars = "\\x1b[6~"; - } - { - key = "Tab"; - mods = "Shift"; - chars = "\\x1b[Z"; - } - { - key = "Back"; - chars= "\\x7f"; - } - { - key = "Back"; - mods = "Alt"; - chars = "\\x1b\\x7f"; - } - { - key = "Insert"; - chars = "\\x1b[2~"; - } - { - key = "Delete"; - chars = "\\x1b[3~"; - } - { - key = "Left"; - mods = "Shift"; - chars = "\\x1b[1;2D"; - } - { - key = "Left"; - mods = "Control"; - chars = "\\x1b[1;5D"; - } - { - key = "Left"; - mods = "Alt"; - chars = "\\x1b[1;3D"; - } - { - key = "Left"; - chars = "\\x1b[D"; - mode = "~AppCursor"; - } - { - key = "Left"; - chars = "\\x1bOD"; - mode = "AppCursor"; - } - { - key = "Right"; - mods = "Shift"; - chars = "\\x1b[1;2C"; - } - { - key = "Right"; - mods = "Control"; - chars = "\\x1b[1;5C"; - } - { - key = "Right"; - mods = "Alt"; - chars = "\\x1b[1;3C"; - } - { - key = "Right"; - chars = "\\x1b[C"; - mode = "~AppCursor"; - } - { - key = "Right"; - chars = "\\x1bOC"; - mode = "AppCursor"; - } - { - key = "Up"; - mods = "Shift"; - chars = "\\x1b[1;2A"; - } - { - key = "Up"; - mods = "Control"; - chars = "\\x1b[1;5A"; - } - { - key = "Up"; - mods = "Alt"; - chars = "\\x1b[1;3A"; - } - { - key = "Up"; - chars = "\\x1b[A"; - mode = "~AppCursor"; - } - { - key = "Up"; - chars = "\\x1bOA"; - mode = "AppCursor"; - } - { - key = "Down"; - mods = "Shift"; - chars = "\\x1b[1;2B"; - } - { - key = "Down"; - mods = "Control"; - chars = "\\x1b[1;5B"; - } - { - key = "Down"; - mods = "Alt"; - chars = "\\x1b[1;3B"; - } - { - key = "Down"; - chars = "\\x1b[B"; - mode = "~AppCursor"; - } - { - key = "Down"; - chars = "\\x1bOB"; - mode = "AppCursor"; - } - { - key = "F1"; - chars = "\\x1bOP"; - } - { - key = "F2"; - chars = "\\x1bOQ"; - } - { - key = "F3"; - chars = "\\x1bOR"; - } - { - key = "F4"; - chars = "\\x1bOS"; - } - { - key = "F5"; - chars = "\\x1b[15~"; - } - { - key = "F6"; - chars = "\\x1b[17~"; - } - { - key = "F7"; - chars = "\\x1b[18~"; - } - { - key = "F8"; - chars = "\\x1b[19~"; - } - { - key = "F9"; - chars = "\\x1b[20~"; - } - { - key = "F10"; - chars = "\\x1b[21~"; - } - { - key = "F11"; - chars = "\\x1b[23~"; - } - { - key = "F12"; - chars = "\\x1b[24~"; - } - { - key = "F1"; - mods = "Shift"; - chars = "\\x1b[1;2P"; - } - { - key = "F2"; - mods = "Shift"; - chars = "\\x1b[1;2Q"; - } - { - key = "F3"; - mods = "Shift"; - chars = "\\x1b[1;2R"; - } - { - key = "F4"; - mods = "Shift"; - chars = "\\x1b[1;2S"; - } - { - key = "F5"; - mods = "Shift"; - chars = "\\x1b[15;2~"; - } - { - key = "F6"; - mods = "Shift"; - chars = "\\x1b[17;2~"; - } - { - key = "F7"; - mods = "Shift"; - chars = "\\x1b[18;2~"; - } - { - key = "F8"; - mods = "Shift"; - chars = "\\x1b[19;2~"; - } - { - key = "F9"; - mods = "Shift"; - chars = "\\x1b[20;2~"; - } - { - key = "F10"; - mods = "Shift"; - chars = "\\x1b[21;2~"; - } - { - key = "F11"; - mods = "Shift"; - chars = "\\x1b[23;2~"; - } - { - key = "F12"; - mods = "Shift"; - chars = "\\x1b[24;2~"; - } - { - key = "F1"; - mods = "Control"; - chars = "\\x1b[1;5P"; - } - { - key = "F2"; - mods = "Control"; - chars = "\\x1b[1;5Q"; - } - { - key = "F3"; - mods = "Control"; - chars = "\\x1b[1;5R"; - } - { - key = "F4"; - mods = "Control"; - chars = "\\x1b[1;5S"; - } - { - key = "F5"; - mods = "Control"; - chars = "\\x1b[15;5~"; - } - { - key = "F6"; - mods = "Control"; - chars = "\\x1b[17;5~"; - } - { - key = "F7"; - mods = "Control"; - chars = "\\x1b[18;5~"; - } - { - key = "F8"; - mods = "Control"; - chars = "\\x1b[19;5~"; - } - { - key = "F9"; - mods = "Control"; - chars = "\\x1b[20;5~"; - } - { - key = "F10"; - mods = "Control"; - chars = "\\x1b[21;5~"; - } - { - key = "F11"; - mods = "Control"; - chars = "\\x1b[23;5~"; - } - { - key = "F12"; - mods = "Control"; - chars = "\\x1b[24;5~"; - } - { - key = "F1"; - mods = "Alt"; - chars = "\\x1b[1;6P"; - } - { - key = "F2"; - mods = "Alt"; - chars = "\\x1b[1;6Q"; - } - { - key = "F3"; - mods = "Alt"; - chars = "\\x1b[1;6R"; - } - { - key = "F4"; - mods = "Alt"; - chars = "\\x1b[1;6S"; - } - { - key = "F5"; - mods = "Alt"; - chars = "\\x1b[15;6~"; - } - { - key = "F6"; - mods = "Alt"; - chars = "\\x1b[17;6~"; - } - { - key = "F7"; - mods = "Alt"; - chars = "\\x1b[18;6~"; - } - { - key = "F8"; - mods = "Alt"; - chars = "\\x1b[19;6~"; - } - { - key = "F9"; - mods = "Alt"; - chars = "\\x1b[20;6~"; - } - { - key = "F10"; - mods = "Alt"; - chars = "\\x1b[21;6~"; - } - { - key = "F11"; - mods = "Alt"; - chars = "\\x1b[23;6~"; - } - { - key = "F12"; - mods = "Alt"; - chars = "\\x1b[24;6~"; - } - { - key = "F1"; - mods = "Super"; - chars = "\\x1b[1;3P"; - } - { - key = "F2"; - mods = "Super"; - chars = "\\x1b[1;3Q"; - } - { - key = "F3"; - mods = "Super"; - chars = "\\x1b[1;3R"; - } - { - key = "F4"; - mods = "Super"; - chars = "\\x1b[1;3S"; - } - { - key = "F5"; - mods = "Super"; - chars = "\\x1b[15;3~"; - } - { - key = "F6"; - mods = "Super"; - chars = "\\x1b[17;3~"; - } - { - key = "F7"; - mods = "Super"; - chars = "\\x1b[18;3~"; - } - { - key = "F8"; - mods = "Super"; - chars = "\\x1b[19;3~"; - } - { - key = "F9"; - mods = "Super"; - chars = "\\x1b[20;3~"; - } - { - key = "F10"; - mods = "Super"; - chars = "\\x1b[21;3~"; - } - { - key = "F11"; - mods = "Super"; - chars = "\\x1b[23;3~"; - } - { - key = "F12"; - mods = "Super"; - chars = "\\x1b[24;3~"; - } - { - key = "NumpadEnter"; - chars = "\\n"; - } - ]; }; }; }; diff --git a/modules/programs/distributed-build/builder.nix b/modules/programs/distributed-build/builder.nix deleted file mode 100644 index 0bd4eef..0000000 --- a/modules/programs/distributed-build/builder.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ pkgs, ... }: - -{ - boot.binfmt.emulatedSystems = [ "i686-linux" "aarch64-linux" ]; # For remote building - environment.systemPackages = with pkgs; [ openssh ]; - nix.trustedUsers = [ "builder" ]; - - # TODO: Specify a firewall rule to only allow this from my other NixOS machines - users = { - groups.builder = {}; - extraUsers."builder" = { - group = "builder"; - isSystemUser = true; - useDefaultShell = true; - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCYfZ6FF3I7Bc8h1VmRxNDHOL08OffetE4DaOZKgw3ZFYSYub80eGN14jevx4Ie525MptFIYbvO5FUcpXx3d6Dh7AE7WUsGzbvPPCmaRy/wiwn2mpCKWqSC3EVxabPakTfVD2+OWDVUW/LWDb2bK40NegBykxf9Vo7112lBFXD8xcq1p8cyhCaq/vsnWUr/8T5z029ySp5UnzuesqrXpfVwnBVzj7xaZizs3Y0bUxdP6vWQSqrTl9KXUveRt3AL+TG3ny4KESvFzGo4YZQCQ2WgCGWgf8SLeHm8UDp8h7dPWkzmT/y7ZSWKGp2R0VDklsjJQqi91l+NXBmKs/uLTVMVqGTYeO04z2mzwzI7aBLrN7A2n3/SmFHz6gW64BYkWNh6iRaDAnu0CgDM4rWyBD/vrgjlojJv6tmSCA3hNGm2ndRfsjiv49+K9NEAxkiijnf0277KHgPHstzlhFq6hYT9qEbaPtqfbKUeWMhj3FpqTHfNVznOXR6+bsGW7h28uLc= alexander@ayame" - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCnhM7E78tisAJuHpLURXXuR3Ya6bFXgh0gLAPU41EAw4QXg77NvW5vuSwGoGLsGmJCYUQSkQbzoqDpjDkdIzuJFMlkQrSBgHSm1g5BdQSY+g/Coey452vd8Xw/tHejlB102ZQI6Pp7IuWTVvJR0jZDosd3igEUmlWN7EVhtS4BIYioZTYS03XPHhZLsLvpXBtX9PST/iHINg1BkvVMAwHd3sRotTCFkJD8dlLrstKDPWijWNjnAmXuTFYPe0PQFUJFaM9JqoXbbu8JuOITtJDNnbh/3z6FNBnn7waJBL5hY+CRaDTnL5icNXzn+L3pcSNUMIm9/AlciqADf9gKx89+bdsM87KFVoFHYWkqHVEo1vBHxssMFFEF9hyTd68bav6rCLlF4CCH+TWG/wUbFR+s2eM+OEAhOl4fcfXMCOKRIMa2N8mAUm5Ms/1Ix1pWQ3MVqfidq7TXhh3Nu91jEoAVjVHihcpfDoNcwPVGXcQY/HcscR6A8VKiQt3ektKTan8= alexander@miku" - ]; - }; - }; -} diff --git a/modules/programs/distributed-build/offload.nix b/modules/programs/distributed-build/offload.nix deleted file mode 100644 index 8347cd0..0000000 --- a/modules/programs/distributed-build/offload.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, ... }: - -let - network = import ../../network.nix; -in { - nix = { - distributedBuilds = true; - buildMachines = [{ - hostName = "miku"; - systems = [ "x86_64-linux" "i686-linux" ]; - maxJobs = 4; - speedFactor = 2; - supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; - }]; - }; - - programs.ssh.extraConfig = '' -Host miku - HostName ${network.miku} - User builder - IdentitiesOnly yes - IdentityFile /root/.ssh/id_builder - ''; -} diff --git a/modules/programs/emacs/#dotemacs# b/modules/programs/emacs/#dotemacs# new file mode 100644 index 0000000..13ae090 --- /dev/null +++ b/modules/programs/emacs/#dotemacs# @@ -0,0 +1,293 @@ +(defconst dd/using-native-comp-p (fboundp 'native-comp-available-p)) +(when dd/using-native-comp-p + (setq comp-async-query-on-exit t) + (setq comp-async-jobs-number 8) + (setq comp-async-report-warnings-errors nil) + (setq comp-deferred-compilation t)) +(setq redisplay-dont-pause t) +(setq jit-lock-defer-time 0) +(setq fast-but-imprecise-scrolling t) +(setq make-backup-files nil) +(setq create-lockfiles nil) + +;; A trick for faster startup is to just disable GC for the init phase +;;; See: https://github.com/nilcons/emacs-use-package-fast#a-trick-less-gc-during-startup +(setq gc-cons-threshold 64000000) +(add-hook 'after-init-hook #'(lambda () + ;; restore after startup + (setq gc-cons-threshold 800000))) + +(defun http-download-verify-and-exec (url sha256-hash name func) + (let ((actual-hash "")) + (with-temp-buffer + ;; Somewhat not documented function. Based on https://emacs.stackexchange.com/a/38482 + ;; The problem is that url-retrieve-synchronously prints the HTTP headers at + ;; the top, which are, since they include time, non-deterministic and thus cannot + ;; be used for hashing. + (url-insert-file-contents url) + (setq actual-hash (secure-hash 'sha256 (current-buffer))) + (unless (string= sha256-hash actual-hash) + (error "Unexpected hash for %s: Got %s, expected %s" name actual-hash sha256-hash)) + func))) + +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 5) + (install-hash "")) + (unless (file-exists-p bootstrap-file) + (http-download-verify-and-exec + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + "5bbeee903a90a0fda88a6b8516697c121400facb36a2c349e9447a53baef154e" + "straight's install.el" + (lambda () + (goto-char (point-max)) + (eval-print-last-sexp)))) + (load bootstrap-file nil 'nomessage)) + +(setq straight-use-package-by-default t) +(straight-use-package 'use-package) + +; Visual things +(defvar emacs-font "SourceCodePro:style=Light-7") +(add-to-list 'default-frame-alist `(font . ,emacs-font)) +(set-face-attribute 'default t :height 150 :font emacs-font) +(tool-bar-mode -1) +(menu-bar-mode -1) +(toggle-scroll-bar -1) +(setq inhibit-startup-screen t) + +;; We cannot exactly use use-package, so we just download it "manually". +(let* ((theme-dir (expand-file-name "themes" user-emacs-directory)) + (theme-file (expand-file-name "weyland-yutani-theme.el" theme-dir))) + (unless (file-exists-p theme-file) + (unless (file-exists-p theme-dir) + (make-directory theme-dir)) + (http-download-verify-and-exec + "https://raw.githubusercontent.com/jstaursky/weyland-yutani-theme/246410e1c03f7d8d8e76102f7c5e3cda83acb36b/weyland-yutani-theme.el" + "6593a0a7e46710e25f9b9caf9888106c93230bd20f9af87c5fc883a98b187253" + "weyland-yutani-theme.el" + (lambda () + (write-file theme-file)))) + (add-to-list 'custom-theme-load-path theme-dir) + (load-theme 'weyland-yutani t)) + +(use-package rainbow-delimiters + :straight t + :config + (add-hook 'prog-mode-hook + #'rainbow-delimiters-mode)) +(use-package hl-todo + :straight t + :config + (add-hook 'prog-mode-hook + #'hl-todo-mode)) +(global-hl-line-mode 1) +(use-package nlinum + :straight t + :config + (add-hook 'prog-mode-hook + (lambda () + (nlinum-mode 1)))) +(add-hook 'prog-mode-hook + (lambda () + (show-paren-mode 1) + (setq show-parens-delay 0))) + +(use-package ivy + :straight t + :config + (defvar ivy-use-virtual-buffers t) + (ivy-mode 1)) + +(setq enable-recursive-minibuffers t) + +; This function allows us to exit EVIL states with C-c +; (https://www.emacswiki.org/emacs/Evil#toc16) +(defun escape (prompt) + (cond ((or (evil-insert-state-p) (evil-normal-state-p) (evil-replace-state-p) (evil-visual-state-p)) [escape]) + (t (kbd "C-g")))) +(use-package evil + :init + (setq evil-want-keybinding nil) + :config + (define-key key-translation-map (kbd "C-c") 'escape) + (evil-mode 1)) +(use-package evil-collection + :after evil + :ensure t + :config + (evil-collection-init)) +; Vim-like buffer navigation +(global-set-key (kbd "C-h") 'windmove-left) +(global-set-key (kbd "C-l") 'windmove-right) +(global-set-key (kbd "C-k") 'windmove-up) +(global-set-key (kbd "C-j") 'windmove-down) + +(use-package rainbow-delimiters + :config + (add-hook 'prog-mode-hook + #'rainbow-delimiters-mode)) +(use-package highlight-parentheses + :straight t + :config + (highlight-parentheses-mode)) +(use-package smartparens + :straight t + :config + (smartparens-global-mode t)) +(use-package undo-tree + :straight t + :config + (global-undo-tree-mode)) + +(use-package hl-todo + :config + (add-hook 'prog-mode-hook + #'hl-todo-mode)) +(global-hl-line-mode 1) + +(setq-default indent-tab-mode t) +(setq tab-width 4) + +(use-package perspective + :bind + ("C-x C-b" . (lambda (arg) + (interactive "P") + (if (fboundp 'persp-bs-show) + (persp-bs-show arg) + (bs-show "all")))) + :config + (message "Persp-mode") + (persp-mode)) + +;; mu4e config +(unless (string= (system-name) "miku") + ; I don't need mu4e on my desktop + (load-file (expand-file-name "mu4e.el" user-emacs-directory)) + (use-package mu4e + :straight t + :config + (ptw/init-mu4e))) + +(use-package calfw + :straight (calfw + :host github + :repo "kiwanami/emacs-calfw" + :files ("calfw.el" "calfw-cal.el"))) + +;; Org mode stuff +;(use-package org-evil +; :straight t) +(use-package graphviz-dot-mode + :straight t) +(use-package org + :straight t + :bind + ("C-x P" . (lambda () + (interactive) + (org-babel-execute-src-block) + (org-redisplay-inline-images))) + :config + (org-babel-do-load-languages + 'org-babel-load-languages + '((dot . t))) + (add-hook 'org-mode-hook + (lambda () + (local-set-key + (kbd "C-x q") + (lambda () + (interactive) + (org-present-quit))) + (local-set-key + (kbd "C-x p") + (lambda () + (interactive) + (org-present)))))) +(use-package org-present + :straight (org-present + :host github + :repo "rlister/org-present" + :files ("org-present.el")) + :config + (add-hook 'org-present-mode-hook + (lambda () + (org-present-big) + (org-display-inline-images) + (org-present-hide-cursor) + (org-present-read-only) + (org-hide-block-all) + + ; Disable evil, but bind left (prev) and right (next) + (turn-off-evil-mode) + (local-set-key + (kbd "l") + (lambda () + (interactive) + (org-present-next) + ;; NOTE: Workaround for images not being shown wen + ;; the slide has been changed + (org-redisplay-inline-images))) + (local-set-key + (kbd "h") + (lambda () + (interactive) + (org-present-prev) + ;; NOTE: Workaround for images not being shown wen + ;; the slide has been changed + (org-redisplay-inline-images))) + + ;; Disable the modeline. But save it before so that we + ;; can restore it + (set (make-local-variable 'saved-mode-line-format) mode-line-format) + (setq mode-line-format nil))) + (add-hook 'org-present-mode-quit-hook + (lambda () + (org-present-small) + (org-remove-inline-images) + (org-present-show-cursor) + (org-present-read-write) + (org-show-all) + (turn-on-evil-mode) + + (local-unset-key (kbd "h")) + (local-unset-key (kbd "l")) + + ;; Restore the modeline. + ;; NOTE: We need to call redraw-display or else the modeline + ;; won't be complete + (setq mode-line-format saved-mode-line-format) + (redraw-display)))) + +;; Development +(use-package tide + :straight t + :config + (defun setup-tide-mode () + (interactive) + (tide-setup) + (tide-hl-identifier-mode +1)) + (add-hook 'typescript-mode-hook #'setup-tide-mode) + (add-hook 'web-mode-hook + (lambda () + (when (string-equal "tsx" (file-name-extension buffer-file-name)) + (setup-tide-mode)))) + (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))) +(use-package nix-mode + :straight t) +(use-package go-mode + :straight t) +(use-package json-mode + :straight t) +(use-package rust-mode + :straight t) + +;; Debugging +(use-package explain-pause-mode + :straight + (explain-pause-mode + :type git + :host github + :repo "lastquestion/explain-pause-mode") + :config + (explain-pause-mode)) diff --git a/modules/programs/emacs/default.nix b/modules/programs/emacs/default.nix index 2c8ed90..be1ac1c 100644 --- a/modules/programs/emacs/default.nix +++ b/modules/programs/emacs/default.nix @@ -1,11 +1,19 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - services.emacs.package = pkgs.emacsPgtkGcc; +let + cfg = config.ptw.programs.emacs; +in { + options.ptw.programs.emacs = { + enable = lib.mkEnableOption "Configure emacs"; + }; - home-manager.users."${config.system.singleUser}".home.file = { - ".emacs".source = ./dotemacs; - ".emacs.d/early-init.el".source = ./early-init.el; - ".emacs.d/mu4e.el".source = ./mu4e.el; + config = lib.mkIf cfg.enable { + services.emacs.package = pkgs.emacsPgtkGcc; + + home-manager.users."${config.ptw.system.singleUser}".home.file = { + ".emacs".source = ./dotemacs; + ".emacs.d/early-init.el".source = ./early-init.el; + ".emacs.d/mu4e.el".source = ./mu4e.el; + }; }; } diff --git a/modules/programs/firefox/default.nix b/modules/programs/firefox/default.nix index 098a972..b163c6b 100644 --- a/modules/programs/firefox/default.nix +++ b/modules/programs/firefox/default.nix @@ -1,9 +1,15 @@ -{ config, pkgs, ... }: +{ inputs, config, lib, pkgs, ... }: -{ - config = { +let + cfg = config.ptw.programs.firefox; +in { + options.ptw.programs.firefox = { + enable = lib.mkEnableOption "Configure Firefox using HomeManager"; + }; + + config = lib.mkIf cfg.enable { environment = { - systemPackages = with pkgs; [ unstable.firefox-wayland tor-browser-bundle-bin ]; + systemPackages = with pkgs; [ firefox-wayland tor-browser-bundle-bin ]; # Deploy a Firefox policy to set the search engine and do some other things etc."firefox/policies/policies.json".source = ./policies.json; @@ -16,7 +22,7 @@ }; }; - home-manager.users."${config.system.singleUser}".programs.firefox = { + home-manager.users."${config.ptw.system.singleUser}".programs.firefox = { enable = true; extensions = with pkgs.nur.repos.rycee.firefox-addons; [ https-everywhere diff --git a/modules/programs/gamemode/#gamemode.ini# b/modules/programs/gamemode/#gamemode.ini# deleted file mode 100644 index c1123bc..0000000 --- a/modules/programs/gamemode/#gamemode.ini# +++ /dev/null @@ -1,36 +0,0 @@ -[general] -reaper_freq=5 -desiredgov=performance -; TODO: Maybe set this -;defaultgov=powersave - -; The iGPU desired governor is used when the integrated GPU is under heavy load -igpu_desiredgov=powersave -igpu_power_threshold=0.3 - -softrealtime=on; -renice=0 -ioprio=0 -inhibit_screensaver=1 - -[filter] -; If "whitelist" entry has a value(s) -; gamemode will reject anything not in the whitelist -;whitelist=RiseOfTheTombRaide - -; Gamemode will always reject anything in the blacklist -;blacklist=HalfLife3 -; glxgears - -[gpu] - -[supervisor] - -[custom] -start=systemctl --user start replaysorcery-kms - systemctl --user start replaysorcery - -end=systemctl --user stop replaysorcery-kms - systemctl --user stop replaysorcery - -script_timeout=10 \ No newline at end of file diff --git a/modules/programs/gamemode/default.nix b/modules/programs/gamemode/default.nix deleted file mode 100644 index e17e4b0..0000000 --- a/modules/programs/gamemode/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ ... }: - -{ - config.programs.gamemode = { - enable = true; - enableRenice = true; - settings = { - general = { - reaper_freq = 5; - desiredgov = "performance"; - igpu_desiredgov = "powersave"; - igpu_power_threshold = 0.3; - - softrealtime = "on"; - renice = 0; - ioprio = 0; - inhibit_screensaver = 1; - }; - }; - }; -} diff --git a/modules/programs/gamemode/gamemode.ini b/modules/programs/gamemode/gamemode.ini deleted file mode 100644 index ea1a439..0000000 --- a/modules/programs/gamemode/gamemode.ini +++ /dev/null @@ -1,36 +0,0 @@ -[general] -reaper_freq=5 -desiredgov=performance -; TODO: Maybe set this -;defaultgov=powersave - -; The iGPU desired governor is used when the integrated GPU is under heavy load -igpu_desiredgov=powersave -igpu_power_threshold=0.3 - -softrealtime=on; -renice=0 -ioprio=0 -inhibit_screensaver=1 - -[filter] -; If "whitelist" entry has a value(s) -; gamemode will reject anything not in the whitelist -;whitelist=RiseOfTheTombRaider - -; Gamemode will always reject anything in the blacklist -;blacklist=HalfLife3 -; glxgears - -[gpu] - -[supervisor] - -[custom] -start=systemctl --user start replaysorcery-kms - systemctl --user start replaysorcery - -end=systemctl --user stop replaysorcery-kms - systemctl --user stop replaysorcery - -script_timeout=10 \ No newline at end of file diff --git a/modules/programs/git/default.nix b/modules/programs/git/default.nix index f4aedc3..f943cb2 100644 --- a/modules/programs/git/default.nix +++ b/modules/programs/git/default.nix @@ -1,9 +1,14 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - config = { +let + cfg = config.ptw.programs.git; +in { + options.ptw.programs.git = { + enable = lib.mkEnableOption "Configure git using HomeManager"; + }; + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.diff-so-fancy ]; - home-manager.users."${config.system.singleUser}".programs.git = { + home-manager.users."${config.ptw.system.singleUser}".programs.git = { enable = true; userEmail = "papatutuwawa@polynom.me"; userName = "Alexander \"PapaTutuWawa\""; diff --git a/modules/programs/gnome-terminal/default.nix b/modules/programs/gnome-terminal/default.nix index 6e1d27b..55f8e8e 100644 --- a/modules/programs/gnome-terminal/default.nix +++ b/modules/programs/gnome-terminal/default.nix @@ -1,9 +1,15 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - config = { +let + cfg = config.ptw.programs.gnome-terminal; +in { + options.ptw.programs.gnome-terminal = { + enable = lib.mkEnableOption "Configure GNOME Terminal using HomeManager"; + }; + + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.gnome.gnome-terminal ]; - home-manager.users."${config.system.singleUser}".programs.gnome-terminal = { + home-manager.users."${config.ptw.system.singleUser}".programs.gnome-terminal = { enable = true; profile.default = { visibleName = "default"; diff --git a/modules/programs/gnome/default.nix b/modules/programs/gnome/default.nix index 37ba7f4..2b4fe6e 100644 --- a/modules/programs/gnome/default.nix +++ b/modules/programs/gnome/default.nix @@ -1,7 +1,13 @@ { pkgs, config, lib, ... }: -{ - config = { +let + cfg = config.ptw.services.gnome; +in { + options.ptw.services.gnome = { + enable = lib.mkEnableOption "Configure GNOME using HomeManager"; + }; + + config = lib.mkIf cfg.enable { environment = { systemPackages = with pkgs; [ arc-theme @@ -68,7 +74,7 @@ gtkUsePortal = true; }; - home-manager.users."${config.system.singleUser}" = { + home-manager.users."${config.ptw.system.singleUser}" = { xdg.configFile = { # Make QT apps use a dark theme "Kvantum/kvantum.kvconfig".text = '' diff --git a/modules/programs/i18n/default.nix b/modules/programs/i18n/default.nix index eec0bbc..483d29b 100644 --- a/modules/programs/i18n/default.nix +++ b/modules/programs/i18n/default.nix @@ -1,15 +1,23 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - i18n.inputMethod = { - enabled = "ibus"; - ibus.engines = with pkgs.ibus-engines; [ mozc ]; +let + cfg = config.ptw.system.i18n; +in { + options.ptw.system.i18n = { + enable = lib.mkEnableOption "Configure i18n services on the system"; }; - #environment.variables = { - # # TODO: Use pam_environment - # "GTK_IM_MODULE" = "xim"; - # "XMODIFIERS" = "@im=ibus"; - # "QT_IM_MODULE" = "xim"; - #}; + config = lib.mkIf cfg.enable { + i18n.inputMethod = { + enabled = "ibus"; + ibus.engines = with pkgs.ibus-engines; [ mozc ]; + }; + + #environment.variables = { + # # TODO: Use pam_environment + # "GTK_IM_MODULE" = "xim"; + # "XMODIFIERS" = "@im=ibus"; + # "QT_IM_MODULE" = "xim"; + #}; + }; } diff --git a/modules/programs/kanshi/default.nix b/modules/programs/kanshi/default.nix deleted file mode 100644 index 881a260..0000000 --- a/modules/programs/kanshi/default.nix +++ /dev/null @@ -1,105 +0,0 @@ -{ - config -, lib -, pkgs -, ... -}: - -let - kanshi = pkgs.kanshi; - writeShellScript = pkgs.writeShellScript; - wallpapersPath = "/home/${config.system.singleUser}/Data/Wallpaper"; - wallpapersHorizontal = "${wallpapersPath}/horizontal"; - wallpapersVertical = "${wallpapersPath}/vertical"; - wallpaperScript = writeShellScript "wallpaper.sh" '' - set -x - [[ $# -lt 1 ]] && echo "No profile specified" && exit 1 - - random_file() { - find "$1" -maxdepth 1 -type f | shuf -n 1 - } - - setbg() { - # Sets the background of $1 to $2 - swaymsg "output \"$1\" background $2 fill" - } - - case $1 in - homeMultihead) - horiz=$(random_file ${wallpapersHorizontal}) - vert=$(random_file ${wallpapersVertical}) - - setbg "DP-2" $horiz - setbg "HDMI-A-3" $vert - ;; - genericMultihead) - horiz1=$(random_file ${wallpapersHorizontal}) - horiz2=$(random_file ${wallpapersHorizontal}) - - setbg "eDP-1" $horiz1 - setbg "HDMI-A-1" $horiz2 - ;; - laptop) - horiz=$(random_file ${wallpapersHorizontal}) - - setbg "eDP-1" $horiz - ;; - esac - ''; - mkProfile = name: outputs: { - outputs = outputs; - - exec = "${wallpaperScript} ${name}"; - }; -in { - environment.systemPackages = [ kanshi ]; - - home-manager.users."${config.system.singleUser}".services.kanshi = { - enable = true; - profiles = let - horizontal = "Samsung Electric Company C27F398 H4ZR101145"; - vertical = "Goldstar Company Ltd IPS235 305NDPHKN600"; - in { - homeMultihead = mkProfile "homeMultihead" [ - { - criteria = vertical; - status = "enable"; - mode = "1920x1080"; - transform = "90"; - position = "-1080,0"; - } - { - criteria = horizontal; - status = "enable"; - mode = "1920x1080"; - position = "0,0"; - } - #{ - # criteria = "eDP-1"; - # status = "enable"; - # mode = "1920x1080"; - # position = "0,0"; - #} - ]; - #genericMultihead = mkProfile "genericMultihead" [ - # { - # criteria = "eDP-1"; - # mode = "1920x1080"; - # status = "enable"; - # } - # { - # criteria = "HDMI-A-1"; - # status = "enable"; - # } - #]; - #laptop = mkProfile "laptop" [ - # { - # criteria = "eDP-1"; - # status = "enable"; - # mode = "1920x1080"; - # position = "0,0"; - # } - #]; - }; - }; -} diff --git a/modules/programs/mako/default.nix b/modules/programs/mako/default.nix index 4bfecf9..b183612 100644 --- a/modules/programs/mako/default.nix +++ b/modules/programs/mako/default.nix @@ -1,12 +1,21 @@ { config -, mako +, lib +, pkgs }: -{ - environment.systemPackages = [ mako ]; - - home-manager.users."${config.system.singleUser}".programs.mako = { - enable = true; +let + cfg = config.ptw.services.mako; +in { + options.ptw.services.mako = { + enable = lib.mkEnableOption "Enable and configure mako using HomeManager"; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ mako ]; + + home-manager.users."${config.ptw.system.singleUser}".programs.mako = { + enable = true; + }; }; } diff --git a/modules/programs/mpv/default.nix b/modules/programs/mpv/default.nix index 81c2f74..3da40fd 100644 --- a/modules/programs/mpv/default.nix +++ b/modules/programs/mpv/default.nix @@ -12,13 +12,15 @@ let video-sync = "display-resample"; interpolation = ""; tscale = "oversample"; - } // additional // (if config.programs.mpv != "" then { + } // additional // (if config.ptw.programs.mpv != "" then { # Make mpv pop up on the primary screen - screen-name = config.programs.mpv.primaryScreen; - fs-screen-name = config.programs.mpv.primaryScreen; + screen-name = config.ptw.programs.mpv.primaryScreen; + fs-screen-name = config.ptw.programs.mpv.primaryScreen; } else {}); + cfg = config.ptw.programs.mpv; in { - options.programs.mpv = { + options.ptw.programs.mpv = { + enable = lib.mkEnableOption "Enable and configure mpv using HomeManager"; primaryScreen = lib.mkOption { type = lib.types.str; default = ""; @@ -26,10 +28,10 @@ in { }; }; - config = { + config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ mpv ]; - home-manager.users."${config.system.singleUser}" = { + home-manager.users."${config.ptw.system.singleUser}" = { programs.mpv = { enable = true; config = { diff --git a/modules/programs/sway/default.nix b/modules/programs/sway/default.nix index 3a80906..70ed65a 100644 --- a/modules/programs/sway/default.nix +++ b/modules/programs/sway/default.nix @@ -30,54 +30,63 @@ let nwggridWrapper = mkWrapperScript "${pkgs.nwg-launchers}/bin/nwggrid-server" ""; # TODO: Fuse this with kanshi swayIdleWrapper = mkWrapperScript "${pkgs.swayidle}/bin/swayidle" "-w before-sleep '${pkgs.swaylock}/bin/swaylock -f --image $(find ~/Data/Wallpaper/horizontal/ -maxdepth 1 -type f | shuf -n 1)'"; + + cfg = config.ptw.programs.sway; in { - home-manager.users."${config.system.singleUser}" = { - wayland.windowManager.sway = { - enable = true; - config = { - bars = [ ]; - startup = [ - { command = "${nwggridWrapper}"; always = true; } - { command = "${swayncWrapper}"; always = true; } - { command = "${waybarWrapper}"; always = true; } - { command = "${kanshiWrapper}"; always = true; } - { command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; always = true; } - { command = "${swayIdleWrapper}"; always = true; } - ]; - modifier = "${modifier}"; - gaps = { - inner = 5; - outer = 7; - }; - input = { - "*" = { xkb_layout = "de"; }; - "2:7:SynPS/2_Synaptics_TouchPad" = { - tap = "enabled"; - natural_scroll = "disabled"; - dwt = "enabled"; + options.ptw.programs.sway = { + enable = lib.mkEnableOption "Configure sway using HomeManager"; + }; + + config = lib.mkIf cfg.enable { + programs.sway.enable = true; + home-manager.users."${config.ptw.system.singleUser}" = { + wayland.windowManager.sway = { + enable = true; + config = { + bars = [ ]; + startup = [ + { command = "${nwggridWrapper}"; always = true; } + { command = "${swayncWrapper}"; always = true; } + { command = "${waybarWrapper}"; always = true; } + { command = "${kanshiWrapper}"; always = true; } + { command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; always = true; } + { command = "${swayIdleWrapper}"; always = true; } + ]; + modifier = "${modifier}"; + gaps = { + inner = 5; + outer = 7; + }; + input = { + "*" = { xkb_layout = "de"; }; + "2:7:SynPS/2_Synaptics_TouchPad" = { + tap = "enabled"; + natural_scroll = "disabled"; + dwt = "enabled"; + }; + "2:10:TPPS/2_Elan_TrackPoint" = { dwt = "enabled"; }; + }; + output = { + "*" = { adaptive_sync = "on"; }; + }; + keybindings = let + speakers = "alsa_output.pci-0000_00_1f.3.analog-stereo"; + in lib.mkOptionDefault { + "${modifier}+Return" = "exec alacritty"; + "${modifier}+e" = "exec emacs"; + "${modifier}+Shift+q" = "kill"; + "${modifier}+f" = "exec firefox"; + "${modifier}+d" = "exec ${pkgs.nwg-launchers}/bin/nwggrid -client"; + "${modifier}+p" = "exec ${passwordDmenu}"; + "Mod4+s" = "exec systemctl suspend"; + # TODO: Screenlock + #"Mod4+l" = "exec ..." + "F1" = "exec pactl set-sink-volume ${speakers} toggle"; + "F2" = "exec pactl set-sink-volume ${speakers} -10%"; + "F3" = "exec pactl set-sink-volume ${speakers} +10%"; + "F5" = "exec brightnessctl --device=intel_backlight set 10%-"; + "F6" = "exec brightnessctl --device=intel_backlight set +10%"; }; - "2:10:TPPS/2_Elan_TrackPoint" = { dwt = "enabled"; }; - }; - output = { - "*" = { adaptive_sync = "on"; }; - }; - keybindings = let - speakers = "alsa_output.pci-0000_00_1f.3.analog-stereo"; - in lib.mkOptionDefault { - "${modifier}+Return" = "exec alacritty"; - "${modifier}+e" = "exec emacs"; - "${modifier}+Shift+q" = "kill"; - "${modifier}+f" = "exec firefox"; - "${modifier}+d" = "exec ${pkgs.nwg-launchers}/bin/nwggrid -client"; - "${modifier}+p" = "exec ${passwordDmenu}"; - "Mod4+s" = "exec systemctl suspend"; - # TODO: Screenlock - #"Mod4+l" = "exec ..." - "F1" = "exec pactl set-sink-volume ${speakers} toggle"; - "F2" = "exec pactl set-sink-volume ${speakers} -10%"; - "F3" = "exec pactl set-sink-volume ${speakers} +10%"; - "F5" = "exec brightnessctl --device=intel_backlight set 10%-"; - "F6" = "exec brightnessctl --device=intel_backlight set +10%"; }; }; }; diff --git a/modules/programs/swaync/default.nix b/modules/programs/swaync/default.nix index 31a555d..671dbee 100644 --- a/modules/programs/swaync/default.nix +++ b/modules/programs/swaync/default.nix @@ -1,8 +1,16 @@ -{ config, ... }: +{ lib, config, ... }: -{ - home-manager.users."${config.system.singleUser}".xdg.configFile = { - "swaync/config.json".source = ./config.json; - "swaync/style.css".source = ./style.css; +let + cfg = config.ptw.services.swaync; +in { + options.ptw.services.swaync = { + enable = lib.mkEnableOption "Configure swaync using HomeManager"; + }; + + config = lib.mkIf cfg.enable { + home-manager.users."${config.ptw.system.singleUser}".xdg.configFile = { + "swaync/config.json".source = ./config.json; + "swaync/style.css".source = ./style.css; + }; }; } diff --git a/modules/programs/tmux/default.nix b/modules/programs/tmux/default.nix index d0643c8..3d214e7 100644 --- a/modules/programs/tmux/default.nix +++ b/modules/programs/tmux/default.nix @@ -1,9 +1,15 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - config = { +let + cfg = config.ptw.programs.tmux; +in { + options.ptw.programs.tmux = { + enable = lib.mkEnableOption "Enable and configure tmux using HomeManager"; + }; + + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.tmux ]; - home-manager.users."${config.system.singleUser}".programs.tmux = { + home-manager.users."${config.ptw.system.singleUser}".programs.tmux = { enable = true; extraConfig = '' set -g mouse on diff --git a/modules/programs/waybar/default.nix b/modules/programs/waybar/default.nix index 25da8c3..da520ac 100644 --- a/modules/programs/waybar/default.nix +++ b/modules/programs/waybar/default.nix @@ -1,55 +1,63 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - home-manager.users."${config.system.singleUser}" = { - xdg.configFile."waybar/style.css".source = ./style.css; - programs.waybar = { - enable = true; - style = builtins.readFile ./style.css; - settings = [ - { - output = [ "DP-2" ]; - layer = "bottom"; - position = "left"; - gtk-layer-shell = true; +let + cfg = config.ptw.programs.waybar; +in { + options.ptw.programs.waybar = { + enable = lib.mkEnableOption "Enable and configure waybar using HomeManager"; + }; - modules-left = [ "custom/applauncher" "sway/workspaces" "sway/mode" ]; - modules-center = [ "clock" ]; - modules-right = [ "tray" "idle_inhibitor" "pulseaudio" "custom/notifications" "custom/menu" ]; + config = lib.mkIf cfg.enable { + home-manager.users."${config.ptw.system.singleUser}" = { + xdg.configFile."waybar/style.css".source = ./style.css; + programs.waybar = { + enable = true; + style = builtins.readFile ./style.css; + settings = [ + { + output = [ "DP-2" ]; + layer = "bottom"; + position = "left"; + gtk-layer-shell = true; - modules = { - "idle_inhibitor" = { - format = "{icon}"; - format-icons = { - activated = ""; - deactivated = ""; - }; + modules-left = [ "custom/applauncher" "sway/workspaces" "sway/mode" ]; + modules-center = [ "clock" ]; + modules-right = [ "tray" "idle_inhibitor" "pulseaudio" "custom/notifications" "custom/menu" ]; + + modules = { + "idle_inhibitor" = { + format = "{icon}"; + format-icons = { + activated = ""; + deactivated = ""; + }; + }; + "sway/workspaces" = { + disable-scroll = true; + all-outputs = true; + }; + "custom/applauncher" = { + format = "  "; + on-click = "${pkgs.nwg-launchers}/bin/nwggrid -client"; + tooltip = "false"; + }; + "custom/notifications" = { + format = "  "; + on-click = "${pkgs.swaync}/bin/swaync-client --toggle-panel"; + tooltip = "false"; + }; + "custom/menu" = { + format = "  "; + on-click = "${pkgs.wlogout}/bin/wlogout"; + tooltip = "false"; + }; + "pulseaudio" = { + #on-click = "${pkgs.stable.myxer}/bin/myxer"; + }; }; - "sway/workspaces" = { - disable-scroll = true; - all-outputs = true; - }; - "custom/applauncher" = { - format = "  "; - on-click = "${pkgs.nwg-launchers}/bin/nwggrid -client"; - tooltip = "false"; - }; - "custom/notifications" = { - format = "  "; - on-click = "${pkgs.swaync}/bin/swaync-client --toggle-panel"; - tooltip = "false"; - }; - "custom/menu" = { - format = "  "; - on-click = "${pkgs.wlogout}/bin/wlogout"; - tooltip = "false"; - }; - "pulseaudio" = { - on-click = "${pkgs.stable.myxer}/bin/myxer"; - }; - }; - } - ]; + } + ]; + }; }; }; } diff --git a/modules/programs/xournalpp/default.nix b/modules/programs/xournalpp/default.nix index 61f5913..4268c0d 100644 --- a/modules/programs/xournalpp/default.nix +++ b/modules/programs/xournalpp/default.nix @@ -1,10 +1,19 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - environment.systemPackages = with pkgs; [ xournalpp-git ]; +let + cfg = config.ptw.programs.xournalpp; +in { + options.ptw.programs.xournalpp = { + enable = lib.mkEnableOption "Install xournalpp"; + configure = lib.mkEnableOption "Configure xournalpp using HomeManager"; + }; - #home-manager.users."${config.system.singleUser}".home.file = { - # ".xournalpp/settings.xml".source = ./settings.xml; - # ".xournalpp/toolbar.ini".source = ./toolbar.ini; - #}; + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ xournalpp-git ]; + + home-manager.users."${config.ptw.system.singleUser}".home.file = lib.mkIf cfg.configure { + ".xournalpp/settings.xml".source = ./settings.xml; + ".xournalpp/toolbar.ini".source = ./toolbar.ini; + }; + }; } diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 4a75c42..b633d28 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -1,42 +1,49 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - environment = { - systemPackages = [ pkgs.zsh ]; - - shells = [ pkgs.zsh ]; - pathsToLink = [ "/share/zsh" ]; +let + cfg = config.ptw.programs.zsh; +in { + options.ptw.programs.zsh = { + enable = lib.mkEnableOption "Enable and configure zsh using HomeManager"; }; - - # Otherwise the user won't appear on the GDM login screen - programs.zsh.enable = true; - home-manager.users."${config.system.singleUser}".programs.zsh = { - enable = true; - history.ignoreSpace = true; - shellAliases = { - ls = "ls --color=always"; - ".." = "cd .."; - "..." = "cd ../../"; - dev = "cd $HOME/Development"; - home = "cd $HOME"; - reload = "$SHELL -l"; - gs = "git status"; - gd = "git diff"; - gds = "git diff --staged"; - c = "clear"; - suspend = "systemctl suspend"; + config = lib.mkIf cfg.enable { + environment = { + systemPackages = [ pkgs.zsh ]; - waifu2x = "flatpak run com.github.nihui.waifu2x-ncnn-vulkan"; + shells = [ pkgs.zsh ]; + pathsToLink = [ "/share/zsh" ]; }; - initExtra = '' + + # Otherwise the user won't appear on the GDM login screen + programs.zsh.enable = true; + + home-manager.users."${config.ptw.system.singleUser}".programs.zsh = { + enable = true; + history.ignoreSpace = true; + shellAliases = { + ls = "ls --color=always"; + ".." = "cd .."; + "..." = "cd ../../"; + dev = "cd $HOME/Development"; + home = "cd $HOME"; + reload = "$SHELL -l"; + gs = "git status"; + gd = "git diff"; + gds = "git diff --staged"; + c = "clear"; + suspend = "systemctl suspend"; + + waifu2x = "flatpak run com.github.nihui.waifu2x-ncnn-vulkan"; + }; + initExtra = '' bindkey "^[[1;5C" forward-word bindkey "^[[1;5D" backward-word bindkey "\e[3~" delete-char ''; - history.share = true; - # TODO: Maybe move this somewhere else - initExtraFirst = '' + history.share = true; + # TODO: Maybe move this somewhere else + initExtraFirst = '' wcurl() { [[ -z "$1" ]] && echo "Error: No URL specified" && exit 1 @@ -44,54 +51,55 @@ curl -fLo "$filename" "$1" } ''; - plugins = [ - { - name = "pure.zsh"; - file = "pure.zsh"; - src = pkgs.fetchFromGitHub { - owner = "sindresorhus"; - repo = "pure"; - rev = "v1.17.0"; - sha256 = "0qfs7rvpyd8jb7x4ziqrkh0b6g9ldds8sn6qbqgrir80vdk90gpa"; - }; - } - { - name = "zsh-history-substring-search"; - src = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-history-substring-search"; - rev = "0f80b8eb3368b46e5e573c1d91ae69eb095db3fb"; - sha256 = "0y8va5kc2ram38hbk2cibkk64ffrabfv1sh4xm7pjspsba9n5p1y"; - }; - } - { - name = "completion"; - file = "init.zsh"; - src = pkgs.fetchFromGitHub { - owner = "zimfw"; - repo = "completion"; - rev = "db079f405397a9dc9af93883e47d8adff817e3b1"; - sha256 = "1vakjj8l10discmzrzjq6nd0bg0jf4chxhwpiq7ldkirzy7lmm9c"; - }; - } - { - name = "zsh-completions"; - src = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-completions"; - rev = "d4511c23659381b56dec8be8c8553b7ff3dc5fd8"; - sha256 = "1y8wkmhgkkyfz91y1f8crh6cg912n87gmcchc8xhnwji11n1mqrq"; - }; - } - { - name = "zsh-syntax-highlighting"; - src = pkgs.fetchFromGitHub { - owner = "zsh-users"; - repo = "zsh-syntax-highlighting"; - rev = "6e0e950154a4c6983d9e077ed052298ad9126144"; - sha256 = "09bkg1a7qs6kvnq17jnw5cbcjhz9sk259mv0d5mklqaifd0hms4v"; - }; - } - ]; + plugins = [ + { + name = "pure.zsh"; + file = "pure.zsh"; + src = pkgs.fetchFromGitHub { + owner = "sindresorhus"; + repo = "pure"; + rev = "v1.17.0"; + sha256 = "0qfs7rvpyd8jb7x4ziqrkh0b6g9ldds8sn6qbqgrir80vdk90gpa"; + }; + } + { + name = "zsh-history-substring-search"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-history-substring-search"; + rev = "0f80b8eb3368b46e5e573c1d91ae69eb095db3fb"; + sha256 = "0y8va5kc2ram38hbk2cibkk64ffrabfv1sh4xm7pjspsba9n5p1y"; + }; + } + { + name = "completion"; + file = "init.zsh"; + src = pkgs.fetchFromGitHub { + owner = "zimfw"; + repo = "completion"; + rev = "db079f405397a9dc9af93883e47d8adff817e3b1"; + sha256 = "1vakjj8l10discmzrzjq6nd0bg0jf4chxhwpiq7ldkirzy7lmm9c"; + }; + } + { + name = "zsh-completions"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-completions"; + rev = "d4511c23659381b56dec8be8c8553b7ff3dc5fd8"; + sha256 = "1y8wkmhgkkyfz91y1f8crh6cg912n87gmcchc8xhnwji11n1mqrq"; + }; + } + { + name = "zsh-syntax-highlighting"; + src = pkgs.fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-syntax-highlighting"; + rev = "6e0e950154a4c6983d9e077ed052298ad9126144"; + sha256 = "09bkg1a7qs6kvnq17jnw5cbcjhz9sk259mv0d5mklqaifd0hms4v"; + }; + } + ]; + }; }; } diff --git a/modules/services/gamemode/default.nix b/modules/services/gamemode/default.nix new file mode 100644 index 0000000..68bf31f --- /dev/null +++ b/modules/services/gamemode/default.nix @@ -0,0 +1,29 @@ +{ config, lib, ... }: + +let + cfg = config.ptw.services.gamemode; +in { + options.ptw.services.gamemode = { + enable = lib.mkEnableOption "Enable and configure gamemode"; + }; + + config = lib.mkIf cfg.enable { + programs.gamemode = { + enable = true; + enableRenice = true; + settings = { + general = { + reaper_freq = 5; + desiredgov = "performance"; + igpu_desiredgov = "powersave"; + igpu_power_threshold = 0.3; + + softrealtime = "on"; + renice = 0; + ioprio = 0; + inhibit_screensaver = 1; + }; + }; + }; + }; +} diff --git a/modules/services/kanshi/default.nix b/modules/services/kanshi/default.nix new file mode 100644 index 0000000..bff4c75 --- /dev/null +++ b/modules/services/kanshi/default.nix @@ -0,0 +1,72 @@ +{ + config +, lib +, pkgs +, ... +}: + +let + kanshi = pkgs.kanshi; + writeShellScript = pkgs.writeShellScript; + wallpapersPath = "/home/${config.ptw.system.singleUser}/Data/Wallpaper"; + wallpapersHorizontal = "${wallpapersPath}/horizontal"; + wallpapersVertical = "${wallpapersPath}/vertical"; + wallpaperScript = writeShellScript "wallpaper.sh" '' + set -x + [[ $# -lt 1 ]] && echo "No profile specified" && exit 1 + + random_file() { + find "$1" -maxdepth 1 -type f | shuf -n 1 + } + + setbg() { + # Sets the background of $1 to $2 + swaymsg "output \"$1\" background $2 fill" + } + + case $1 in + homeMultihead) + horiz=$(random_file ${wallpapersHorizontal}) + vert=$(random_file ${wallpapersVertical}) + + setbg "DP-2" $horiz + setbg "HDMI-A-3" $vert + ;; + genericMultihead) + horiz1=$(random_file ${wallpapersHorizontal}) + horiz2=$(random_file ${wallpapersHorizontal}) + + setbg "eDP-1" $horiz1 + setbg "HDMI-A-1" $horiz2 + ;; + laptop) + horiz=$(random_file ${wallpapersHorizontal}) + + setbg "eDP-1" $horiz + ;; + esac + ''; + mkProfile = name: outputs: { + outputs = outputs; + + exec = "${wallpaperScript} ${name}"; + }; + cfg = config.ptw.services.kanshi; +in { + options.ptw.services.kanshi = { + enable = lib.mkEnableOption "Enable kanshi and configure using HomeManager"; + profiles = lib.mkOption { + description = "The actual kanshi configuration"; + type = lib.types.anything; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ kanshi ]; + + home-manager.users."${config.ptw.system.singleUser}".services.kanshi = { + enable = true; + inherit (cfg) profiles; + }; + }; +} diff --git a/modules/services/key-mapper/default.nix b/modules/services/key-mapper/default.nix new file mode 100644 index 0000000..60dd97d --- /dev/null +++ b/modules/services/key-mapper/default.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.ptw.services.key-mapper; +in { + options.ptw.services.key-mapper = { + enable = lib.mkEnableOption "Enable the key-mapper service and install it"; + }; + + config = lib.mkIf cfg.enable { + # TODO: Assert that uinput is in kernelModules + services.udev = { + packages = with pkgs; [ key-mapper ]; + extraRules = '' + KERNEL=="uinput", GROUP="input", MODE="0660" + ''; + }; + + environment.systemPackages = [ + pkgs.key-mapper # Custom package + ]; + + systemd.user.services.key-mapper = { + description = "A tool to change the mapping of your input device buttons"; + wantedBy = [ "default.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.key-mapper}/bin/key-mapper-service"; + Restart = "always"; + # NOTE: The Tartarus may not be connected, so don't fail if we cannot set the preset + ExecPostStart = "${pkgs.key-mapper}/bin/key-mapper --command start --preset NOOP --device \"Razer Razer Tartarus V2\"; exit 0"; + }; + }; + }; +} diff --git a/modules/users/alexander.nix b/modules/users/alexander.nix index ddc6d94..0f388e3 100644 --- a/modules/users/alexander.nix +++ b/modules/users/alexander.nix @@ -1,7 +1,7 @@ -{ pkgs, config, ... }: +{ pkgs, lib, config, ... }: { - config = { + config = lib.mkIf (config.ptw.system.singleUser == "alexander") { users.users.alexander = { isNormalUser = true; extraGroups = [ "wheel" "audio" "video" "kvm" "input" "libvirtd" ]; @@ -11,8 +11,6 @@ uid = 1000; isSystemUser = false; }; - - system.singleUser = "alexander"; # Activate gpg programs.gnupg.agent.enable = true; @@ -38,10 +36,11 @@ IdentityFile ~/.ssh/github_polynomdivision ''; }; - + + # TODO: Maybe move this somewhere else services.gpg-agent = { enable = true; - pinentryFlavor = "gnome3"; + pinentryFlavor = "qt"; }; }; }; diff --git a/modules/users/default.nix b/modules/users/default.nix index acfcf4c..10b72c9 100644 --- a/modules/users/default.nix +++ b/modules/users/default.nix @@ -1,7 +1,7 @@ { lib, ... }: { - options.system = { + options.ptw.system = { singleUser = lib.options.mkOption { example = "PapaTutuWawa"; readOnly = true; diff --git a/modules/users/fuck-xi.nix b/modules/users/fuck-xi.nix index 60b18ed..b44c09b 100644 --- a/modules/users/fuck-xi.nix +++ b/modules/users/fuck-xi.nix @@ -1,7 +1,7 @@ { pkgs, lib, config, ... }: { - config = { + config = lib.mkIf (config.ptw.system.singleUser == "fuck-xi") { users.users.fuck-xi = { isNormalUser = true; extraGroups = [ "wheel" "audio" "video" "kvm" "input" ]; @@ -12,7 +12,5 @@ uid = 1000; isSystemUser = false; }; - - system.singleUser = "fuck-xi"; }; } diff --git a/modules/virtualisation/default.nix b/modules/virtualisation/default.nix index 8141550..4de55ca 100644 --- a/modules/virtualisation/default.nix +++ b/modules/virtualisation/default.nix @@ -1,7 +1,14 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - environment.systemPackages = with pkgs; [ virglrenderer ]; +let + cfg = config.ptw.virtualisation; +in { + options.ptw.virtualisation = { + enable = lib.mkEnableOption "Enable and configure virtualisation"; + }; - services.spice-vdagentd.enable = true; + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ virglrenderer ]; + services.spice-vdagentd.enable = true; + }; } diff --git a/modules/virtualisation/gaming.nix b/modules/virtualisation/gaming.nix index 02e3bc9..2fe227c 100644 --- a/modules/virtualisation/gaming.nix +++ b/modules/virtualisation/gaming.nix @@ -1,8 +1,15 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: -{ - environment.etc = { - "evdev-proxy/config.toml".source = pkgs.writeText "config.toml" '' +let + cfg = config.ptw.virtualisation.gaming; +in { + options.ptw.virtualisation.gaming = { + enable = lib.mkEnableOption "Configure virtualisation for gaming purposes"; + }; + + config = lib.mkIf cfg.enable { + environment.etc = { + "evdev-proxy/config.toml".source = pkgs.writeText "config.toml" '' log_level = "INFO" [[device]] @@ -27,9 +34,9 @@ [[device.Simple.selector]] EVDEVClass = {phys="\"key-mapper\""} ''; - "libvirt/hooks/qemu".source = let - vfio-isolate-state = "/tmp/vfio-isolate-state"; - in pkgs.writeScript "qemu" '' + "libvirt/hooks/qemu".source = let + vfio-isolate-state = "/tmp/vfio-isolate-state"; + in pkgs.writeScript "qemu" '' #!${pkgs.stdenv.shell} guest=$1 action=$2 @@ -65,14 +72,14 @@ esac fi ''; - }; + }; - virtualisation.libvirtd = { - enable = true; - #qemuRunAsRoot = false; - qemuOvmf = true; - qemuPackage = pkgs.unstable.qemu; - qemuVerbatimConfig = '' + virtualisation.libvirtd = { + enable = true; + #qemuRunAsRoot = false; + qemuOvmf = true; + qemuPackage = pkgs.unstable.qemu; + qemuVerbatimConfig = '' seccomp_sandbox = 0 cgroup_device_acl = [ "/dev/null", "/dev/full", "/dev/zero", @@ -84,28 +91,29 @@ "/dev/input/by-id/virtual-event-EvdevProxyMouse", "/dev/input/by-id/virtual-event-EvdevProxyTartarus", "/dev/input/by-id/usb-Razer_Razer_BlackWidow_Ultimate-event-kbd" - ] + ] ''; - }; + }; - # NOTE: Workaround for libvirt's SYSCONFDIR being set to /var/lib - # (See https://github.com/NixOS/nixpkgs/issues/51152#issuecomment-899374407) - system.activationScripts.libvirt-hooks.text = '' + # NOTE: Workaround for libvirt's SYSCONFDIR being set to /var/lib + # (See https://github.com/NixOS/nixpkgs/issues/51152#issuecomment-899374407) + system.activationScripts.libvirt-hooks.text = '' ln -Tfs /etc/libvirt/hooks /var/lib/libvirt/hooks ''; - #services.udev.packages = with pkgs; [ evdev-proxy ]; - - systemd = { - services.libvirtd.path = with pkgs; [ vfio-isolate systemd bash ]; - #user.services.evdev-proxy = { - # description = "Creates virtual device to proxy evdev devices events"; - # #wantedBy = [ "default.target" ]; - # serviceConfig = { - # Type = "simple"; - # ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy"; - # Restart = "always"; - # }; - #}; + #services.udev.packages = with pkgs; [ evdev-proxy ]; + + systemd = { + services.libvirtd.path = with pkgs; [ vfio-isolate systemd bash ]; + #user.services.evdev-proxy = { + # description = "Creates virtual device to proxy evdev devices events"; + # #wantedBy = [ "default.target" ]; + # serviceConfig = { + # Type = "simple"; + # ExecStart = "${pkgs.evdev-proxy}/bin/evdev-proxy"; + # Restart = "always"; + # }; + #}; + }; }; } diff --git a/overlays/custom.nix b/overlays/custom.nix deleted file mode 100644 index 5e65175..0000000 --- a/overlays/custom.nix +++ /dev/null @@ -1,5 +0,0 @@ -pkgs: final: prev: - -import ../packages { - pkgs = prev; -} diff --git a/overlays/default.nix b/overlays/default.nix index a436d18..788e282 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -3,21 +3,14 @@ , lib }: -let - importWrapper = file: import file { - pkgs = pkgs; - lib = lib; - }; -in { +{ emacs = import (builtins.fetchGit { url = "https://github.com/nix-community/emacs-overlay.git"; ref = "master"; rev = "ce0e9482d53d69bedc8416d8a984d00e17607826"; }); nur = import ./nur.nix pkgs; - unstable = importWrapper ./unstable.nix; - stable = importWrapper ./stable.nix; - custom = import ./custom.nix pkgs; + custom = import ../packages; simple = import ./simple.nix; surface = import ./surface.nix pkgs; } diff --git a/overlays/stable.nix b/overlays/stable.nix deleted file mode 100644 index ada1ea4..0000000 --- a/overlays/stable.nix +++ /dev/null @@ -1,21 +0,0 @@ -# NOTE: pkgs is unused but there for consistency with nur.nix -{ - lib, ... -}: final: prev: - -let - stableTarball = - fetchTarball - https://github.com/NixOS/nixpkgs/archive/nixos-21.05.tar.gz; -in { - stable = import stableTarball { - # TODO - config = { - allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ - "firmwareLinuxNonfree" "microcodeAmd" "microcodeIntel" - "steam" "steam-original" "steam-runtime" - "discord" - ]; - }; - }; -} diff --git a/overlays/unstable.nix b/overlays/unstable.nix deleted file mode 100644 index b6a33c2..0000000 --- a/overlays/unstable.nix +++ /dev/null @@ -1,21 +0,0 @@ -# NOTE: pkgs is unused but there for consistency with nur.nix -{ - lib, ... -}: final: prev: - -let - unstableTarball = - fetchTarball - https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz; -in { - unstable = import unstableTarball { - # TODO - config = { - allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ - "firmwareLinuxNonfree" "microcodeAmd" "microcodeIntel" - "steam" "steam-original" "steam-runtime" - "discord" - ]; - }; - }; -} diff --git a/packages/default.nix b/packages/default.nix index 656663c..d85be21 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -1,43 +1,43 @@ -{ pkgs ? import {} }: +final: prev: let - pySmartDL = pkgs.callPackage ./development/python/pySmartDL {}; - cfscrape = pkgs.callPackage ./development/python/cfscrape {}; - system_hotkey = pkgs.callPackage ./development/python/system_hotkey {}; - discord-system-electron = pkgs.callPackage ./applications/networking/instant-messengers/discord { + pySmartDL = prev.callPackage ./development/python/pySmartDL {}; + cfscrape = prev.callPackage ./development/python/cfscrape {}; + system_hotkey = prev.callPackage ./development/python/system_hotkey {}; + discord-system-electron = prev.callPackage ./applications/networking/instant-messengers/discord { # Wayland # NOTE: electron under Wayland has no window titlebars extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland"; #extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WebRTCPipeWireCapturer"; }; - wrapInSandbox = pkgs.callPackage ./sandbox.nix {}; + wrapInSandbox = prev.callPackage ./sandbox.nix {}; in { - #key-mapper = pkgs.callPackage ./tools/games/key-mapper {}; - vfio-isolate = pkgs.callPackage ./tools/virtualisation/vfio-isolate {}; - mopidy-funkwhale = pkgs.callPackage ./applications/audio/mopidy/funkwhale.nix {}; + key-mapper = prev.callPackage ./tools/games/key-mapper {}; + vfio-isolate = prev.callPackage ./tools/virtualisation/vfio-isolate {}; + mopidy-funkwhale = prev.callPackage ./applications/audio/mopidy/funkwhale.nix {}; # Not as clean as I hoped, but it works - gnomeExtensions = pkgs.gnomeExtensions // { - notification-timeout = pkgs.callPackage ./desktop/gnome/extensions/notification-timeout {}; - windowisready-remover = pkgs.callPackage ./desktop/gnome/extensions/windowisready-remover {}; + gnomeExtensions = prev.gnomeExtensions // { + notification-timeout = prev.callPackage ./desktop/gnome/extensions/notification-timeout {}; + windowisready-remover = prev.callPackage ./desktop/gnome/extensions/windowisready-remover {}; }; - python3Packages = pkgs.python3Packages // { + python3Packages = prev.python3Packages // { pySmartDL = pySmartDL; cfscrape = cfscrape; system_hotkey = system_hotkey; }; - replaysorcery = pkgs.callPackage ./tools/games/replaysorcery {}; - evdev-proxy = pkgs.callPackage ./tools/virtualisation/evdev-proxy {}; - anime4k = pkgs.callPackage ./misc/video/anime4k {}; - anime-dl = pkgs.callPackage ./tools/video/animedl { + replaysorcery = prev.callPackage ./tools/games/replaysorcery {}; + evdev-proxy = prev.callPackage ./tools/virtualisation/evdev-proxy {}; + anime4k = prev.callPackage ./misc/video/anime4k {}; + anime-dl = prev.callPackage ./tools/video/animedl { pySmartDL = pySmartDL; cfscrape = cfscrape; }; - superpaper = pkgs.callPackage ./applications/desktop/superpaper { + superpaper = prev.callPackage ./applications/desktop/superpaper { system_hotkey = system_hotkey; }; discord-wrapped = wrapInSandbox { name = "discord"; - package = pkgs.unstable.discord; + package = prev.discord; #package = discord-system-electron; binaryName = "discord"; mountInHome = [ ".config/discord" ".config/BetterDiscord" ]; @@ -56,16 +56,16 @@ in { }; }; - sddm-sugar-dark = pkgs.callPackage ./sddm-sugar-dark {}; + sddm-sugar-dark = prev.callPackage ./sddm-sugar-dark {}; - iptsd = pkgs.callPackage ./tools/daemons/iptsd {}; - surface-control = pkgs.callPackage ./tools/system/surface-control {}; + iptsd = prev.callPackage ./tools/daemons/iptsd {}; + surface-control = prev.callPackage ./tools/system/surface-control {}; - trackma = pkgs.callPackage ./tools/video/trackma {}; + trackma = prev.callPackage ./tools/video/trackma {}; multimc-wrapped = wrapInSandbox { name = "multimc"; - package = pkgs.multimc; + package = prev.multimc; binaryName = "multimc"; mountInHome = [ ".local/share/multimc" ]; additionalBlacklist = [ "/mnt" ]; @@ -77,7 +77,7 @@ in { steam-wrapped = wrapInSandbox { name = "steam"; - package = pkgs.steam; + package = prev.steam; binaryName = "steam"; mountInHome = [ ".steam" ".local/share/Steam" ]; additionalBlacklist = [ "/mnt" ]; @@ -92,7 +92,7 @@ in { styluslabs-wrapped = wrapInSandbox { name = "Write"; - package = pkgs.write_stylus; + package = prev.write_stylus; binaryName = "Write"; additionalBlacklist = [ "/mnt" ]; mountInHome = [ "tmp" ]; @@ -102,16 +102,16 @@ in { android-studio-wrapped = wrapInSandbox { name = "android-studio"; - package = pkgs.android-studio; + package = prev.android-studio; binaryName = "android-studio"; additionalBlacklist = [ "/mnt" ]; mountInHome = [ "Development/Personal/Android" ".android" ]; chdirTo = "/home/$USER"; }; - xournalpp-git = pkgs.unstable.xournalpp.overrideAttrs (old: { + xournalpp-git = prev.xournalpp.overrideAttrs (old: { version = "1.1.1"; - src = pkgs.fetchFromGitHub { + src = prev.fetchFromGitHub { owner = "xournalpp"; repo = "xournalpp"; rev = "master"; @@ -119,9 +119,9 @@ in { }; }); - gajim-mainwindow = pkgs.callPackage ./applications/networking/instant-messengers/gajim { - nbxmpp = pkgs.python3Packages.nbxmpp.overrideAttrs (old: { - src = pkgs.fetchFromGitLab { + gajim-mainwindow = prev.callPackage ./applications/networking/instant-messengers/gajim { + nbxmpp = prev.python3Packages.nbxmpp.overrideAttrs (old: { + src = prev.fetchFromGitLab { domain = "dev.gajim.org"; owner = "gajim"; repo = "python-nbxmpp"; @@ -131,9 +131,9 @@ in { }); }; - swaync = pkgs.callPackage ./tools/desktop/swaync {}; + swaync = prev.callPackage ./tools/desktop/swaync {}; - myxer = pkgs.myxer.overrideAttrs (old: { + myxer = prev.myxer.overrideAttrs (old: { cargoPatches = [ ./0000-1.2.1-set-gio-version.patch ]; }); } diff --git a/packages/misc/video/anime4k/default.nix b/packages/misc/video/anime4k/default.nix index 5d99ac2..4c64508 100644 --- a/packages/misc/video/anime4k/default.nix +++ b/packages/misc/video/anime4k/default.nix @@ -6,7 +6,7 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "bloc97"; - repo = "Anime4k"; + repo = "anime4k"; rev = "v${version}"; sha256 = "1gc1ka9i7xzxq58175q5svhvp8vr27hy477r4z4nkhp9q1cqj19r"; }; diff --git a/packages/tools/games/key-mapper/default.nix b/packages/tools/games/key-mapper/default.nix index 6b243ef..0563ce8 100644 --- a/packages/tools/games/key-mapper/default.nix +++ b/packages/tools/games/key-mapper/default.nix @@ -9,8 +9,7 @@ python3Packages.buildPythonApplication rec { pname = "key-mapper"; - # TODO: Update to 1.2.1 - version = "1.0.0"; + version = "1.2.1"; buildInputs = [ gobject-introspection gtk3 gnome.adwaita-icon-theme ]; @@ -35,7 +34,7 @@ python3Packages.buildPythonApplication rec { # Fix keymapper not finding its data files preBuild = '' - sed -e "s|NIXOS_OUT_PATH|$out/usr/share/key-mapper|" --in-place keymapper/data.py + sed -e "s|@@NIXOS_OUT_PATH@@|$out/usr/share/key-mapper|" --in-place keymapper/data.py ''; # Required as we otherwise don't get the dbus policy installed diff --git a/packages/tools/games/key-mapper/hack-data-dir.patch b/packages/tools/games/key-mapper/hack-data-dir.patch index 65d3b2f..5e211cc 100644 --- a/packages/tools/games/key-mapper/hack-data-dir.patch +++ b/packages/tools/games/key-mapper/hack-data-dir.patch @@ -1,12 +1,12 @@ diff --git a/keymapper/data.py b/keymapper/data.py -index d909399..7e4aad0 100644 +index 6f3e428..8eded95 100644 --- a/keymapper/data.py +++ b/keymapper/data.py -@@ -68,6 +68,7 @@ def get_data_path(filename=''): - '/usr/share/key-mapper', - '/usr/local/share/key-mapper', - os.path.join(site.USER_BASE, 'share/key-mapper'), -+ 'NIXOS_OUT_PATH', +@@ -68,6 +68,7 @@ def get_data_path(filename=""): + "/usr/share/key-mapper", + "/usr/local/share/key-mapper", + os.path.join(site.USER_BASE, "share/key-mapper"), ++ "@@NIXOS_OUT_PATH@@", ] if data is None: diff --git a/packages/tools/video/animedl/0000-add-kawaiifu.patch b/packages/tools/video/animedl/0000-add-kawaiifu.patch new file mode 100644 index 0000000..4f39cbd --- /dev/null +++ b/packages/tools/video/animedl/0000-add-kawaiifu.patch @@ -0,0 +1,57 @@ +diff --git a/anime_downloader/sites/init.py b/anime_downloader/sites/init.py +index a0d0d3b..e555a56 100644 +--- a/anime_downloader/sites/init.py ++++ b/anime_downloader/sites/init.py +@@ -3,6 +3,7 @@ from importlib import import_module + ALL_ANIME_SITES = [ + # ('filename', 'sitename', 'classname') + # ('_4anime', '4anime', 'Anime4'), ++ ('kawaiifu', 'kawaiifu', 'Kawaiifu'), + ('anitube', 'anitube', 'AniTube'), + ('animtime', 'animtime', 'AnimTime'), + ('anime8', 'anime8', 'Anime8'), +diff --git a/anime_downloader/sites/kawaiifu.py b/anime_downloader/sites/kawaiifu.py +new file mode 100644 +index 0000000..dfffc6d +--- /dev/null ++++ b/anime_downloader/sites/kawaiifu.py +@@ -0,0 +1,39 @@ ++from anime_downloader.sites.anime import Anime, AnimeEpisode, SearchResult ++from anime_downloader.sites import helpers ++ ++import logging ++ ++logger = logging.getLogger(__name__) ++ ++class Kawaiifu(Anime, sitename='kawaiifu'): ++ sitename = 'kawaiifu' ++ ++ @classmethod ++ def search(cls, query): ++ soup = helpers.soupify(helpers.get("https://kawaiifu.com/search-movie?keyword={}&cat-get=".format(query))) ++ ++ items = soup.find_all("div", "item") ++ return [ ++ SearchResult( ++ title = item.select("h4 > a")[1].text.strip(), ++ url = item.select("h4 > a")[1]['href'] ++ ) for item in items ++ ] ++ ++ def _scrape_episodes(self): ++ soup = helpers.soupify(helpers.get(self.url)) ++ redirect = soup.select(".list-ep > li > a")[0]["href"] ++ soup = helpers.soupify(helpers.get(redirect)) ++ ++ return [item["href"] for item in soup.select(".list-ep > li > a")] ++ ++ def _scrape_metadata(self): ++ soup = helpers.soupify(helpers.get(self.url)) ++ self.title = soup.find_all("h2", "title")[0].text ++ ++class KawaiifuEpisode(AnimeEpisode, sitename="kawaiifu"): ++ def _get_sources(self): ++ soup = helpers.soupify(helpers.get(self.url)) ++ video = soup.find_all("video")[0] ++ ++ return [('no_extractor', video["atr_id"])] diff --git a/packages/tools/video/animedl/default.nix b/packages/tools/video/animedl/default.nix new file mode 100644 index 0000000..c2696cb --- /dev/null +++ b/packages/tools/video/animedl/default.nix @@ -0,0 +1,49 @@ +{ + pkgs +, lib +, fetchFromGitHub +, python3Packages +, python3 +, pySmartDL +, cfscrape +, extraPkgs ? pkgs: [] +}: + +python3Packages.buildPythonApplication rec { + pname = "anime-dl"; + version = "5.0.14"; + + src = fetchFromGitHub { + owner = "anime-dl"; + repo = "anime-downloader"; + rev = version; + sha256 = "1ai71g8cp2i37p53lm32nl3h8cq7rcxifhnj1z1cfvxbqjvackaj"; + }; + + propagatedBuildInputs = with python3.pkgs; [ + pySmartDL + cfscrape + beautifulsoup4 + requests + requests-cache + click + fuzzywuzzy + coloredlogs + tabulate + pycryptodome + ] ++ extraPkgs pkgs; + + patches = [ + ./0000-add-kawaiifu.patch + ]; + + doCheck = false; + + meta = with lib; { + homepage = "https://github.com/anime-dl/anime-downloader"; + description = "A simple but powerful anime downloader and streamer."; + license = licenses.unlicense; + maintainers = []; + platforms = platforms.linux; + }; +} diff --git a/packages/tools/virtualisation/vfio-isolate/default.nix b/packages/tools/virtualisation/vfio-isolate/default.nix index f745642..964d7a1 100644 --- a/packages/tools/virtualisation/vfio-isolate/default.nix +++ b/packages/tools/virtualisation/vfio-isolate/default.nix @@ -1,4 +1,10 @@ -{ pkgs, lib, python3Packages, python3, gtk3, gobject-introspection, git, wrapGAppsHook, gnome }: +{ + pkgs, lib +, python3Packages, python3 +, gtk3, gobject-introspection, gnome +, wrapGAppsHook +, fetchFromGitHub +}: python3Packages.buildPythonApplication rec { pname = "vfio-isolate"; @@ -9,9 +15,11 @@ python3Packages.buildPythonApplication rec { patches = [ ./remove-versions.patch ]; - src = builtins.fetchGit { - url = "https://github.com/spheenik/vfio-isolate.git"; - ref = "master"; + src = fetchFromGitHub { + owner = "spheenik"; + repo = "vfio-isolate"; + rev = "master"; + sha256 = "0n85bmaj79i97j19wrn3z4hmg93p2rrsb3jk1qfd0107agx8mr3k"; }; doCheck = false;