flakes: Migrate the config and miku to flakes

This commit is contained in:
2021-11-01 21:33:21 +01:00
parent 09d385806a
commit 1d8f2f8053
64 changed files with 2612 additions and 1739 deletions

26
modules/base.nix Normal file
View File

@@ -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";
};
}

View File

@@ -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
];
}

View File

@@ -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;
};
}

View File

@@ -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" ];
};
}

View File

@@ -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" ];
}

View File

@@ -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;
};
}

View File

@@ -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
'';
}
];
}
];
};
};
}

Binary file not shown.

View File

@@ -1,220 +0,0 @@
{
lib, pkgs
}:
config: {
userName
, hostName
, wireless ? false
, wifiInterface ? ""
, primaryInterface ? ""
, overlays ? []
, hardwareImports ? [ "generic" ]
, programImports ? []
, extraImports ? []
, isVM ? false
, fileSystems
, swapDevices ? []
, extraPackages ? pkgs: []
, extraOptions ? old: {}
}:
let
overlaysSet = import ../overlays { pkgs = pkgs; lib = lib; };
network = import ./network.nix;
home-manager = builtins.fetchGit {
url = "https://github.com/nix-community/home-manager.git";
rev = "35a24648d155843a4d162de98c17b1afd5db51e4";
ref = "release-21.05";
};
primaryInterfaceWrapper = if wifiInterface != "" && primaryInterface == "" then wifiInterface else primaryInterface;
baseConfig = {
# Install home-manager
imports = [
"${home-manager}/nixos"
./users # For system.singleUser
(./users + "/${userName}.nix")
((import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = builtins.fetchGit {
url = "https://dev.ostylk.de/NixDistro/Config.git";
rev = "703d3d727a86c5c45d59608b35e0dea62a3f8486";
};
}).defaultNix.nixosModules.nftables)
] ++ (map (item: ./programs + "/${item}") programImports)
++ (map (item: ./hardware + "/${item}.nix") hardwareImports)
++ lib.optional wireless ./hardware/wifi.nix
++ (map (item: ./. + "/${item}") extraImports);
home-manager.useGlobalPkgs = true;
nixpkgs.overlays = (map (item: lib.getAttr item overlaysSet) overlays);
time.timeZone = "Europe/Berlin";
ostylk.nftables = {
enable = true;
tables.firewall = {
family = "inet";
chains = {
non-libvirt.extraConfig = let
deviceIPString = lib.concatStringsSep "," (with network; [
miku nishimiya ayame tamaki mashu
]);
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
iif ${primaryInterfaceWrapper} goto non-libvirt
'';
};
};
};
networking = {
useDHCP = false; # Done by the network manager
networkmanager.enable = false;
#interfaces.*.useDHCP = false;
hostName = hostName;
wireless.enable = (if wireless then true else lib.mkForce false);
connman.enable = true;
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
] ++ extraPackages pkgs
++ lib.optionals (!isVM) (with pkgs; [ gopass ]);
sessionVariables = {
# Prevent us from having to always type it out
NIXOS_CONFIG = "/home/${config.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 = {
# 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 = wifiInterface;
} else {});
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
};
fileSystems = fileSystems;
swapDevices = swapDevices;
system.stateVersion = "21.05";
};
in lib.attrsets.recursiveUpdate baseConfig (extraOptions baseConfig)

View File

@@ -1,10 +0,0 @@
rec {
network-base = "192.168.178";
# 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
tamaki = "${network-base}.27";
mashu = "${network-base}.52";
}

View File

@@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
let
cfg = config.ptw.system.offloading.builder;
in {
options.ptw.system.offloading.builder = {
enable = lib.mkEnableOption "Allow building derivations for other systems";
};
config = lib.mkIf cfg.enable {
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"
];
};
};
};
}

View File

@@ -0,0 +1,31 @@
{ config, lib, pkgs, ... }:
let
network = import ../../network.nix;
cfg = config.ptw.system.offloading.offload;
in {
options.ptw.system.offloading.offload = {
enable = lib.mkEnableOption "Allow offloading building of derivations";
};
config = lib.mkIf cfg.enable {
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
'';
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -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"
];
};
};
}

View File

@@ -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
'';
}

View File

@@ -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))

View File

@@ -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;
};
};
}

View File

@@ -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

View File

@@ -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

View File

@@ -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;
};
};
};
}

View File

@@ -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

View File

@@ -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\"";

View File

@@ -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";

View File

@@ -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 = ''

View File

@@ -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";
#};
};
}

View File

@@ -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";
# }
#];
};
};
}

View File

@@ -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;
};
};
}

View File

@@ -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 = {

View File

@@ -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%";
};
};
};

View File

@@ -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;
};
};
}

View File

@@ -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

View File

@@ -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";
};
};
}
];
}
];
};
};
};
}

View File

@@ -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;
};
};
}

View File

@@ -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";
};
}
];
};
};
}

View File

@@ -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;
};
};
};
};
}

View File

@@ -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;
};
};
}

View File

@@ -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";
};
};
};
}

View File

@@ -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";
};
};
};

View File

@@ -1,7 +1,7 @@
{ lib, ... }:
{
options.system = {
options.ptw.system = {
singleUser = lib.options.mkOption {
example = "PapaTutuWawa";
readOnly = true;

View File

@@ -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";
};
}

View File

@@ -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;
};
}

View File

@@ -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";
# };
#};
};
};
}