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

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