This commit is contained in:
Grimmauld 2024-05-07 23:31:41 +02:00
parent 280cc4f686
commit 2e8ca0ee0d
Signed by: Grimmauld
GPG Key ID: C2946668769F91FB
42 changed files with 1811 additions and 1405 deletions

View File

View File

@ -1,95 +1,119 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sync_mod = with lib; types.submodule ({ config, ... }: { sync_mod =
options = { with lib;
remote = mkOption { types.submodule (
type = types.nonEmptyStr; { config, ... }:
description = "path on the cloud server"; {
}; options = {
remote = mkOption {
type = types.nonEmptyStr;
description = "path on the cloud server";
};
local = mkOption { local = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
default = "$HOME/" + (concatStrings (builtins.match "/*(.+)" config.remote)); default = "$HOME/" + (concatStrings (builtins.match "/*(.+)" config.remote));
description = "local path to sync"; description = "local path to sync";
}; };
}; };
}); }
);
in in
{ {
config = with cfg; lib.mkIf (enable && cloudSync.enable) ( config =
let with cfg;
cloud_cmd = ''${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${config.grimmShared.cloudSync.username} -p "$(cat ${config.grimmShared.cloudSync.passwordFile})" -h -n --path''; lib.mkIf (enable && cloudSync.enable) (
sync_server = "https://${config.grimmShared.cloudSync.server}"; let
in cloud_cmd = ''${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${config.grimmShared.cloudSync.username} -p "$(cat ${config.grimmShared.cloudSync.passwordFile})" -h -n --path'';
{ sync_server = "https://${config.grimmShared.cloudSync.server}";
environment.systemPackages = with pkgs; [ in
(writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server)) {
nextcloud-client environment.systemPackages = with pkgs; [
]; (writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server))
nextcloud-client
];
systemd.services = lib.mkMerge (lib.mapAttrsToList systemd.services = lib.mkMerge (
(local_user: user_conf: lib.mapAttrsToList (
let local_user: user_conf:
paths = user_conf.syncPaths; let
sync_script = lib.strings.concatLines (map paths = user_conf.syncPaths;
({ local, remote }: sync_script = lib.strings.concatLines (
let map (
remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote); { local, remote }:
in let
"${cloud_cmd} /${remote_clean} ${local} ${sync_server}") remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote);
paths); in
in "${cloud_cmd} /${remote_clean} ${local} ${sync_server}"
{ ) paths
# user-specific sync jobs );
"nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) { in
description = "Auto sync Nextcloud"; {
after = [ "network-online.target" ]; # user-specific sync jobs
wants = [ "network-online.target" ]; "nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) {
serviceConfig.Type = "simple"; description = "Auto sync Nextcloud";
serviceConfig.User = local_user; after = [ "network-online.target" ];
serviceConfig.Group = "users"; wants = [ "network-online.target" ];
script = sync_script; serviceConfig.Type = "simple";
# TimeoutStopSec = "180"; serviceConfig.User = local_user;
# KillMode = "process"; serviceConfig.Group = "users";
# KillSignal = "SIGINT"; script = sync_script;
wantedBy = [ "multi-user.target" ]; # TimeoutStopSec = "180";
enable = true; # KillMode = "process";
# KillSignal = "SIGINT";
wantedBy = [ "multi-user.target" ];
enable = true;
};
}
) config.users.users
);
systemd.timers = lib.mkMerge (
lib.mapAttrsToList (
local_user: user_conf:
let
paths = user_conf.syncPaths;
in
{
# user-specific sync jobs
"nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) {
description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
timerConfig.OnBootSec = "5min";
timerConfig.OnUnitActiveSec = "60min";
wantedBy = [
"multi-user.target"
"timers.target"
];
enable = true;
};
}
) config.users.users
);
}
);
options.users.users =
with lib;
mkOption {
type = types.attrsOf (
types.submodule {
options = {
syncPaths = mkOption {
type = types.listOf sync_mod;
default = [ ];
description = "paths to sync via nextcloud";
}; };
}) };
config.users.users); }
);
systemd.timers = lib.mkMerge (lib.mapAttrsToList };
(local_user: user_conf:
let
paths = user_conf.syncPaths;
in
{
# user-specific sync jobs
"nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) {
description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
timerConfig.OnBootSec = "5min";
timerConfig.OnUnitActiveSec = "60min";
wantedBy = [ "multi-user.target" "timers.target" ];
enable = true;
};
})
config.users.users);
}
);
options.users.users = with lib; mkOption {
type = types.attrsOf (types.submodule {
options = {
syncPaths = mkOption {
type = types.listOf sync_mod;
default = [ ];
description = "paths to sync via nextcloud";
};
};
});
};
options.grimmShared.cloudSync = with lib; { options.grimmShared.cloudSync = with lib; {
enable = mkEnableOption "cloud_sync"; enable = mkEnableOption "cloud_sync";

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
with lib; with lib;
{ {
options.grimmShared = { options.grimmShared = {

View File

@ -1,64 +1,72 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && firefox.enable) { config =
environment.systemPackages = [ ] with cfg;
++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ]; lib.mkIf (enable && firefox.enable) {
environment.systemPackages =
[ ]
++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ];
programs.firefox = { programs.firefox = {
package = pkgs.firefox-beta; package = pkgs.firefox-beta;
enable = true; enable = true;
nativeMessagingHosts.packages = [ ] nativeMessagingHosts.packages =
++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ]; [ ]
languagePacks = lib.optionals cfg.locale [ "de" "en-US" ]; ++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ];
policies = { languagePacks = lib.optionals cfg.locale [
ExtensionSettings = lib.mkMerge [ "de"
(lib.mkIf cfg.firefox.disableUserPlugins { "en-US"
"*".installation_mode = "blocked"; ];
}) policies = {
(lib.mapAttrs ExtensionSettings = lib.mkMerge [
(guid: shortId: { (lib.mkIf cfg.firefox.disableUserPlugins { "*".installation_mode = "blocked"; })
(lib.mapAttrs (guid: shortId: {
# explicit plugins by config # explicit plugins by config
install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi";
installation_mode = "force_installed"; installation_mode = "force_installed";
}) cfg.firefox.plugins)
(lib.mkIf (cfg.tooling.enable && cfg.tooling.pass) {
# password-store support
"passff@invicem.pro" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/passff/latest.xpi";
installation_mode = "force_installed";
};
}) })
cfg.firefox.plugins) ];
(lib.mkIf (cfg.tooling.enable && cfg.tooling.pass) { DisableTelemetry = true;
# password-store support DisableFirefoxStudies = true;
"passff@invicem.pro" = { EnableTrackingProtection = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/passff/latest.xpi"; Value = true;
installation_mode = "force_installed"; Locked = true;
}; Cryptomining = true;
}) Fingerprinting = true;
]; };
DisableTelemetry = true; DisablePocket = true;
DisableFirefoxStudies = true; DisableFirefoxAccounts = true;
EnableTrackingProtection = { DisableAccounts = true;
Value = true; DisableFirefoxScreenshots = true;
Locked = true; OverrideFirstRunPage = "";
Cryptomining = true; OverridePostUpdatePage = "";
Fingerprinting = true; DontCheckDefaultBrowser = true;
}; Preferences = {
DisablePocket = true; "pdfjs.enableScripting" = false;
DisableFirefoxAccounts = true;
DisableAccounts = true;
DisableFirefoxScreenshots = true;
OverrideFirstRunPage = "";
OverridePostUpdatePage = "";
DontCheckDefaultBrowser = true;
Preferences = {
"pdfjs.enableScripting" = false;
"media.hardware-video-decoding.enabled" = true; "media.hardware-video-decoding.enabled" = true;
"media.ffmpeg.vaapi.enabled" = true; "media.ffmpeg.vaapi.enabled" = true;
"media.rdd-ffmpeg.enabled" = true; "media.rdd-ffmpeg.enabled" = true;
"media.navigator.mediadatadecoder_vpx_enabled" = true; "media.navigator.mediadatadecoder_vpx_enabled" = true;
} // lib.optionalAttrs cfg.sway.enable { "browser.tabs.inTitlebar" = 0; }; } // lib.optionalAttrs cfg.sway.enable { "browser.tabs.inTitlebar" = 0; };
};
}; };
}; };
};
options.grimmShared.firefox = with lib; { options.grimmShared.firefox = with lib; {
enable = mkEnableOption "grimm-firefox"; enable = mkEnableOption "grimm-firefox";

View File

@ -1,56 +1,62 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && gaming) { config =
programs.steam = { with cfg;
enable = true; lib.mkIf (enable && gaming) {
gamescopeSession.enable = true; programs.steam = {
gamescopeSession.env = { enable = true;
DRI_PRIME = "1"; gamescopeSession.enable = true;
gamescopeSession.env = {
DRI_PRIME = "1";
};
extraCompatPackages = with pkgs; [ proton-ge-bin ];
# extest.enable = true;
}; };
extraCompatPackages = with pkgs; [
proton-ge-bin programs.gamemode = {
enable = true;
settings = {
general = {
inhibit_screensaver = 0;
renice = 10;
};
custom = {
start = "${lib.getExe pkgs.libnotify} 'GameMode started'";
end = "${lib.getExe pkgs.libnotify} 'GameMode ended'";
};
};
};
services.udev.packages = [ pkgs.wooting-udev-rules ];
environment.sessionVariables = {
GAMEMODERUNEXEC = "env DRI_PRIME=1";
};
environment.systemPackages = with pkgs; [
heroic
prismlauncher
mangohud
the-powder-toy
(pkgs.symlinkJoin {
name = "osu";
paths = [
(pkgs.writeShellScriptBin "osu!" ''
exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin}
'')
pkgs.osu-lazer-bin
];
})
]; ];
# extest.enable = true;
}; };
programs.gamemode = {
enable = true;
settings = {
general = {
inhibit_screensaver = 0;
renice = 10;
};
custom = {
start = "${lib.getExe pkgs.libnotify} 'GameMode started'";
end = "${lib.getExe pkgs.libnotify} 'GameMode ended'";
};
};
};
services.udev.packages = [ pkgs.wooting-udev-rules ];
environment.sessionVariables = {
GAMEMODERUNEXEC = "env DRI_PRIME=1";
};
environment.systemPackages = with pkgs; [
heroic
prismlauncher
mangohud
the-powder-toy
(pkgs.symlinkJoin {
name = "osu";
paths = [
(pkgs.writeShellScriptBin "osu!" ''exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin}
'')
pkgs.osu-lazer-bin
];
})
];
};
options.grimmShared.gaming = lib.mkEnableOption "enables steam, heroic, prism and gamemoded"; options.grimmShared.gaming = lib.mkEnableOption "enables steam, heroic, prism and gamemoded";
} }

View File

@ -1,20 +1,27 @@
{ lib, pkgs, config, ... }:
{ {
config = with config.grimmShared; lib.mkIf (enable && graphical) { lib,
fonts = { pkgs,
packages = with pkgs; [ config,
noto-fonts ...
noto-fonts-cjk }:
font-awesome {
noto-fonts-emoji config =
roboto with config.grimmShared;
liberation_ttf lib.mkIf (enable && graphical) {
]; fonts = {
packages = with pkgs; [
noto-fonts
noto-fonts-cjk
font-awesome
noto-fonts-emoji
roboto
liberation_ttf
];
fontDir.enable = true; fontDir.enable = true;
};
environment.sessionVariables = {
FREETYPE_PROPERTIES = "cff:no-stem-darkening=0 autofitter:no-stem-darkening=0";
};
}; };
environment.sessionVariables = {
FREETYPE_PROPERTIES = "cff:no-stem-darkening=0 autofitter:no-stem-darkening=0";
};
};
} }

View File

@ -1,66 +1,74 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
screen = with lib; types.submodule { screen =
options = { with lib;
fps = mkOption { types.submodule {
type = types.either types.int (types.nonEmptyListOf types.int); options = {
default = 60; fps = mkOption {
description = "max framerate of screen"; type = types.either types.int (types.nonEmptyListOf types.int);
}; default = 60;
description = "max framerate of screen";
};
mode = mkOption { mode = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
default = "1920x1080"; default = "1920x1080";
description = "pixel format of the screen"; description = "pixel format of the screen";
}; };
id = mkOption { id = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
description = "ID of the screen"; description = "ID of the screen";
}; };
pos = mkOption { pos = mkOption {
type = types.nullOr types.nonEmptyStr; type = types.nullOr types.nonEmptyStr;
default = null; default = null;
example = "0,0"; example = "0,0";
description = "position where to place the screen"; description = "position where to place the screen";
};
}; };
}; };
};
in in
{ {
config = with cfg; lib.mkIf (enable && graphical) { config =
# Enable OpenGL with cfg;
hardware.opengl = { lib.mkIf (enable && graphical) {
enable = true; # Enable OpenGL
driSupport = true; hardware.opengl = {
driSupport32Bit = true; enable = true;
extraPackages = with pkgs; [ ]; driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [ ];
};
chaotic.mesa-git.enable = true;
boot.kernelParams = [ "nouveau.config=NvGspRm=1" ];
environment.sessionVariables = {
__GL_LOG_MAX_ANISO = "0";
__GL_SHADER_DISK_CACHE = "1";
__GL_SYNC_TO_VBLANK = "0";
__GL_THREADED_OPTIMIZATIONS = "1";
__GL_VRR_ALLOWED = "1";
# MESA_LOADER_DRIVER_OVERRIDE="zink";
# FLATPAK_GL_DRIVERS="mesa-git";
};
environment.systemPackages = with pkgs; [
glfw
glxinfo
vulkan-tools
mangohud
];
}; };
chaotic.mesa-git.enable = true;
boot.kernelParams = [ "nouveau.config=NvGspRm=1" ];
environment.sessionVariables = {
__GL_LOG_MAX_ANISO = "0";
__GL_SHADER_DISK_CACHE = "1";
__GL_SYNC_TO_VBLANK = "0";
__GL_THREADED_OPTIMIZATIONS = "1";
__GL_VRR_ALLOWED = "1";
# MESA_LOADER_DRIVER_OVERRIDE="zink";
# FLATPAK_GL_DRIVERS="mesa-git";
};
environment.systemPackages = with pkgs; [
glfw
glxinfo
vulkan-tools
mangohud
];
};
options.grimmShared = with lib; { options.grimmShared = with lib; {
graphical = mkOption { graphical = mkOption {
type = types.bool; type = types.bool;

View File

@ -1,49 +1,55 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && graphical) { config =
qt = { with cfg;
enable = true; lib.mkIf (enable && graphical) {
style = "kvantum"; qt = {
platformTheme = "qt5ct";
};
environment.systemPackages = with pkgs; with kdePackages; [
qtstyleplugin-kvantum
catppuccin-sddm-corners
libsForQt5.qtgraphicaleffects
catppuccin-kvantum
kdePackages.audiocd-kio
kdePackages.kio-extras
kdePackages.kio
xcb-util-cursor
qt6ct
kdePackages.dolphin
qtwayland
];
environment.pathsToLink = [
"/share/Kvantum"
];
services.displayManager = {
sddm = {
enable = true; enable = true;
theme = "catppuccin-sddm-corners"; style = "kvantum";
wayland.enable = true; platformTheme = "qt5ct";
wayland.compositor = "weston";
}; };
defaultSession = lib.optionalString cfg.sway.enable "sway";
};
boot.plymouth = { environment.systemPackages =
themePackages = with pkgs; [ with pkgs;
catppuccin-plymouth with kdePackages;
]; [
theme = "catppuccin-macchiato"; qtstyleplugin-kvantum
enable = true; catppuccin-sddm-corners
libsForQt5.qtgraphicaleffects
catppuccin-kvantum
kdePackages.audiocd-kio
kdePackages.kio-extras
kdePackages.kio
xcb-util-cursor
qt6ct
kdePackages.dolphin
qtwayland
];
environment.pathsToLink = [ "/share/Kvantum" ];
services.displayManager = {
sddm = {
enable = true;
theme = "catppuccin-sddm-corners";
wayland.enable = true;
wayland.compositor = "weston";
};
defaultSession = lib.optionalString cfg.sway.enable "sway";
};
boot.plymouth = {
themePackages = with pkgs; [ catppuccin-plymouth ];
theme = "catppuccin-macchiato";
enable = true;
};
}; };
};
} }

View File

@ -1,79 +1,97 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sway_conf = with lib; types.submodule ({ config, ... }: rec { sway_conf =
options = { with lib;
keybinds = mkOption { types.submodule (
type = types.attrsOf types.str; { config, ... }:
default = { }; rec {
description = "set of keybinds assigning key combo to action"; options = {
}; keybinds = mkOption {
type = types.attrsOf types.str;
default = { };
description = "set of keybinds assigning key combo to action";
};
autolaunch = mkOption { autolaunch = mkOption {
type = types.listOf (types.either types.nonEmptyStr types.package); type = types.listOf (types.either types.nonEmptyStr types.package);
default = [ ]; default = [ ];
description = "set of commands to be run at sway startup"; description = "set of commands to be run at sway startup";
}; };
execAlways = mkOption { execAlways = mkOption {
type = types.listOf (types.either types.nonEmptyStr types.package); type = types.listOf (types.either types.nonEmptyStr types.package);
default = [ ]; default = [ ];
description = "set of commands to be run at sway reload"; description = "set of commands to be run at sway reload";
}; };
extraConfig = mkOption { extraConfig = mkOption {
type = types.str; type = types.str;
default = ""; default = "";
description = "additional sway config to be included"; description = "additional sway config to be included";
}; };
definitions = mkOption { definitions = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = { }; default = { };
description = "set of definitions assigning variable to value"; description = "set of definitions assigning variable to value";
}; };
modes = mkOption { modes = mkOption {
type = types.attrsOf sway_conf; type = types.attrsOf sway_conf;
default = { }; default = { };
description = "possible modes to switch to, e.g. resize"; description = "possible modes to switch to, e.g. resize";
}; };
}; };
}); }
);
build_screen_def = fps_func: with lib; let build_screen_def =
output_def = mapAttrsToList fps_func:
(name: value: with lib;
let
output_def = mapAttrsToList (
name: value:
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz" "output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
+ (optionalString (value.pos != null) " position ${value.pos}") + (optionalString (value.pos != null) " position ${value.pos}")
) ) cfg.screens;
cfg.screens; in
in ''
'' for pid in $(${pkgs.procps}/bin/pgrep sway -x)
for pid in $(${pkgs.procps}/bin/pgrep sway -x) do
do uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid)) export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock" if [[ -e "$SWAYSOCK" ]] ; then
if [[ -e "$SWAYSOCK" ]] ; then echo "sock is $SWAYSOCK"
echo "sock is $SWAYSOCK" ${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}' fi
fi done
done '';
'';
inherit (lib) getExe; inherit (lib) getExe;
fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps); fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps);
fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps); fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps);
init_screens_min_fps = with lib; pkgs.writeShellScriptBin "init-screens-min" init_screens_min_fps =
(build_screen_def fps_min); with lib;
init_screens_max_fps = with lib; pkgs.writeShellScriptBin "init-screens-max" pkgs.writeShellScriptBin "init-screens-min" (build_screen_def fps_min);
(build_screen_def fps_max); init_screens_max_fps =
with lib;
pkgs.writeShellScriptBin "init-screens-max" (build_screen_def fps_max);
init_screens_auto = pkgs.writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}"; init_screens_auto = pkgs.writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}";
in in
{ {
config = config =
let let
bar_conf_file = if (lib.isPath cfg.sway.bar.config) then cfg.sway.bar.config else pkgs.writers.writeJSON "config.json" cfg.sway.bar.config; bar_conf_file =
if (lib.isPath cfg.sway.bar.config) then
cfg.sway.bar.config
else
pkgs.writers.writeJSON "config.json" cfg.sway.bar.config;
waybar_full = pkgs.writeShellScriptBin "waybar-full" ( waybar_full = pkgs.writeShellScriptBin "waybar-full" (
(lib.getExe config.programs.waybar.package) (lib.getExe config.programs.waybar.package)
+ (lib.optionalString (!isNull cfg.sway.bar.config) " -c ${bar_conf_file}") + (lib.optionalString (!isNull cfg.sway.bar.config) " -c ${bar_conf_file}")
@ -92,16 +110,21 @@ in
systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr
''; '';
build_conf = with lib; sway_conf: build_conf =
with lib;
sway_conf:
let let
build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}"); build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}");
build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}"); build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}");
build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item))); build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item)));
build_mode_lines = mapAttrsToList (name: value: '' build_mode_lines = mapAttrsToList (
mode "${name}" { name: value: ''
${concatLines (map (item: " " + item ) (build_conf value))}}''); mode "${name}" {
${concatLines (map (item: " " + item) (build_conf value))}}''
);
in in
([ ] (
[ ]
++ (build_definition_lines sway_conf.definitions) ++ (build_definition_lines sway_conf.definitions)
++ (build_keybind_lines sway_conf.keybinds) ++ (build_keybind_lines sway_conf.keybinds)
++ (build_exec_lines "exec" sway_conf.autolaunch) ++ (build_exec_lines "exec" sway_conf.autolaunch)
@ -113,17 +136,17 @@ in
sway_conf = lib.concatLines ( sway_conf = lib.concatLines (
(build_conf cfg.sway.config) (build_conf cfg.sway.config)
++ lib.optional cfg.sway.bar.enable bar_config ++ lib.optional cfg.sway.bar.enable bar_config
++ (lib.mapAttrsToList ++ (lib.mapAttrsToList (
(name: value: name: value:
"output ${value.id} mode ${value.mode}" "output ${value.id} mode ${value.mode}"
+ (lib.optionalString (value.pos != null) " position ${value.pos}") + (lib.optionalString (value.pos != null) " position ${value.pos}")
) ) cfg.screens)
cfg.screens)
); );
conf_path = "sway.conf"; conf_path = "sway.conf";
in in
with cfg; lib.mkIf (enable && sway.enable) { with cfg;
lib.mkIf (enable && sway.enable) {
environment.etc."${conf_path}".text = sway_conf; environment.etc."${conf_path}".text = sway_conf;
grimmShared.sway.config.execAlways = [ grimmShared.sway.config.execAlways = [
@ -131,17 +154,19 @@ in
init_screens_auto init_screens_auto
]; ];
environment.systemPackages = [ environment.systemPackages =
waybar_full [
dbus-sway-environment waybar_full
init_screens_min_fps dbus-sway-environment
init_screens_max_fps init_screens_min_fps
init_screens_auto init_screens_max_fps
] ++ (with pkgs; [ init_screens_auto
procps ]
slurp ++ (with pkgs; [
libnotify procps
]); slurp
libnotify
]);
systemd.services.reload-sway = { systemd.services.reload-sway = {
description = "Reload all running sway instances"; description = "Reload all running sway instances";

View File

@ -1,73 +1,82 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
lm_sensors lib.mkIf (enable && laptop_hardware.enable) {
lshw environment.systemPackages =
pciutils with pkgs;
usbutils [
opentabletdriver lm_sensors
ddcutil lshw
python312Packages.py-cpuinfo pciutils
(writeShellScriptBin "lsiommu" ./lsiommu) usbutils
] ++ lib.optionals graphical [ opentabletdriver
ddcui ddcutil
wootility python312Packages.py-cpuinfo
]; (writeShellScriptBin "lsiommu" ./lsiommu)
]
++ lib.optionals graphical [
ddcui
wootility
];
hardware.i2c.enable = true; hardware.i2c.enable = true;
services.libinput.enable = true; services.libinput.enable = true;
hardware.opentabletdriver.enable = true; hardware.opentabletdriver.enable = true;
services.udisks2.enable = true; services.udisks2.enable = true;
services.udev.extraRules = '' services.udev.extraRules = ''
SUBSYSTEM=="i2c-dev", ACTION=="add",\ SUBSYSTEM=="i2c-dev", ACTION=="add",\
ATTR{name}=="NVIDIA i2c adapter*",\ ATTR{name}=="NVIDIA i2c adapter*",\
TAG+="ddcci",\ TAG+="ddcci",\
TAG+="systemd",\ TAG+="systemd",\
ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service" ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
'';
systemd.services."ddcci@" = {
scriptArgs = "%i";
script = ''
sleep 20
echo Trying to attach ddcci to $1
i=0
id=$(echo $1 | cut -d "-" -f 2)
if ${pkgs.ddcutil}/bin/ddcutil getvcp 10 -b $id; then
echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device
fi
''; '';
serviceConfig.Type = "oneshot";
};
boot = { systemd.services."ddcci@" = {
kernelParams = [ scriptArgs = "%i";
# "splash" script = ''
"quiet" sleep 20
# "intel_iommu=on" echo Trying to attach ddcci to $1
# "iommu=force" i=0
# "pcie_acs_override=downstream" id=$(echo $1 | cut -d "-" -f 2)
# "mmio_stale_data=full,nosmt" if ${pkgs.ddcutil}/bin/ddcutil getvcp 10 -b $id; then
# "pcie_aspm=off" echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ]; fi
loader.efi.canTouchEfiVariables = true; '';
initrd.availableKernelModules = [ serviceConfig.Type = "oneshot";
"xhci_pci" };
"ahci"
"nvme" boot = {
"usbhid" kernelParams = [
"usb_storage" # "splash"
"sd_mod" "quiet"
]; # "intel_iommu=on"
loader.systemd-boot.enable = true; # "iommu=force"
extraModulePackages = [ # "pcie_acs_override=downstream"
(config.boot.kernelPackages.ddcci-driver.overrideAttrs # "mmio_stale_data=full,nosmt"
(old: { # "pcie_aspm=off"
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
loader.systemd-boot.enable = true;
extraModulePackages = [
(config.boot.kernelPackages.ddcci-driver.overrideAttrs (old: {
patches = [ patches = [
(pkgs.fetchpatch { (pkgs.fetchpatch {
url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch"; url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch";
@ -75,22 +84,21 @@ in
}) })
]; ];
})) }))
]; ];
kernelModules = [ kernelModules = [
# "kvm-intel" # "kvm-intel"
# "vfio_pci" # "vfio_pci"
# "vfio_iommu_type1" # "vfio_iommu_type1"
# "vfio" # "vfio"
"ddcci_backlight" "ddcci_backlight"
"i2c-dev" "i2c-dev"
"ec_sys" "ec_sys"
]; ];
# blacklistedKernelModules = [ "i2c_nvidia_gpu" ]; # blacklistedKernelModules = [ "i2c_nvidia_gpu" ];
};
}; };
};
options.grimmShared.laptop_hardware = { options.grimmShared.laptop_hardware = {
enable = lib.mkEnableOption "grimm-laptop"; enable = lib.mkEnableOption "grimm-laptop";
}; };
} }

View File

@ -1,77 +1,110 @@
{ pkgs, config, lib, system, ... }: {
pkgs,
config,
lib,
system,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
inherit (lib) optionals optional optionalString concatLines getExe; inherit (lib)
optionals
optional
optionalString
concatLines
getExe
;
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower; inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms); enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms);
powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([ powersave =
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed with pkgs;
"${getExe pkgs.brightnessctl} s 20%" # display brightness writeShellScriptBin "powersave-mode" (
] ++ optionals enable_perf_policy [ concatLines (
"${getExe x86_energy_perf_policy} 15" # power save preference [
"${getExe x86_energy_perf_policy} --turbo-enable 0" # disable turbo "${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
] ++ optional cfg.sway.enable "init-screens-min")); "${getExe pkgs.brightnessctl} s 20%" # display brightness
]
++ optionals enable_perf_policy [
"${getExe x86_energy_perf_policy} 15" # power save preference
"${getExe x86_energy_perf_policy} --turbo-enable 0" # disable turbo
]
++ optional cfg.sway.enable "init-screens-min"
)
);
performance = pkgs.writeShellScriptBin "performance-mode" (concatLines ([ performance = pkgs.writeShellScriptBin "performance-mode" (
"${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed concatLines (
"${getExe pkgs.brightnessctl} s 100%" # display brightness [
] ++ optionals enable_perf_policy [ "${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed
"${getExe x86_energy_perf_policy} 0" # performance preference "${getExe pkgs.brightnessctl} s 100%" # display brightness
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo ]
] ++ optional cfg.sway.enable "init-screens-max")); ++ optionals enable_perf_policy [
auto = let inherit (pkgs) tlp; in pkgs.writeShellScriptBin "auto-mode" '' "${getExe x86_energy_perf_policy} 0" # performance preference
${tlp}/bin/run-on-ac ${getExe performance} "${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
${tlp}/bin/run-on-bat ${getExe powersave} ]
''; ++ optional cfg.sway.enable "init-screens-max"
)
);
auto =
let
inherit (pkgs) tlp;
in
pkgs.writeShellScriptBin "auto-mode" ''
${tlp}/bin/run-on-ac ${getExe performance}
${tlp}/bin/run-on-bat ${getExe powersave}
'';
in in
{ {
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
acpi lib.mkIf (enable && laptop_hardware.enable) {
powertop environment.systemPackages =
brightnessctl with pkgs;
cpupower [
powersave acpi
performance powertop
auto brightnessctl
] ++ optionals graphical [ cpupower
tlpui powersave
] ++ optional enable_perf_policy x86_energy_perf_policy; performance
auto
]
++ optionals graphical [ tlpui ]
++ optional enable_perf_policy x86_energy_perf_policy;
services.acpid = { services.acpid = {
enable = true; enable = true;
acEventCommands = getExe auto; acEventCommands = getExe auto;
}; };
powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power";
powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; powerManagement.cpuFreqGovernor = lib.mkDefault "normal";
services.power-profiles-daemon.enable = false; services.power-profiles-daemon.enable = false;
services.upower.enable = true; services.upower.enable = true;
#boot.extraModulePackages = [ #boot.extraModulePackages = [
# cpupower # cpupower
#] ++ optional enable_perf_policy x86_energy_perf_policy; #] ++ optional enable_perf_policy x86_energy_perf_policy;
services.tlp = { services.tlp = {
enable = true; enable = true;
settings = { settings = {
USB_AUTOSUSPEND = 1; USB_AUTOSUSPEND = 1;
USB_EXCLUDE_BTUSB = 1; USB_EXCLUDE_BTUSB = 1;
USB_EXCLUDE_PHONE = 1; USB_EXCLUDE_PHONE = 1;
SOUND_POWER_SAVE_ON_AC = 0; SOUND_POWER_SAVE_ON_AC = 0;
SOUND_POWER_SAVE_ON_BAT = 1; SOUND_POWER_SAVE_ON_BAT = 1;
SATA_LINKPWR_ON_AC = "max_performance"; SATA_LINKPWR_ON_AC = "max_performance";
SATA_LINKPWR_ON_BAT = "min_power"; SATA_LINKPWR_ON_BAT = "min_power";
MAX_LOST_WORK_SECS_ON_BAT = 15; MAX_LOST_WORK_SECS_ON_BAT = 15;
CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_BOOST_ON_AC = 1; CPU_BOOST_ON_AC = 1;
CPU_BOOST_ON_BAT = 0; CPU_BOOST_ON_BAT = 0;
RUNTIME_PM_ON_AC = "on"; RUNTIME_PM_ON_AC = "on";
RUNTIME_PM_ON_BAT = "auto"; RUNTIME_PM_ON_BAT = "auto";
};
}; };
}; };
};
} }

View File

@ -3,31 +3,33 @@ let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && locale) { config =
time.timeZone = "Europe/Berlin"; with cfg;
lib.mkIf (enable && locale) {
time.timeZone = "Europe/Berlin";
# Select internationalisation properties. # Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = { i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8"; LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8"; LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8"; LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8"; LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8"; LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8"; LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8"; LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8"; LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8"; LC_TIME = "de_DE.UTF-8";
};
console.keyMap = "de";
services.xserver.xkb = {
layout = "de";
variant = "";
};
}; };
console.keyMap = "de";
services.xserver.xkb = {
layout = "de";
variant = "";
};
};
options.grimmShared.locale = lib.mkEnableOption "Sets german units but english language"; options.grimmShared.locale = lib.mkEnableOption "Sets german units but english language";
} }

View File

@ -1,20 +1,28 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && network && config.hardware.bluetooth.enable) { config =
services.blueman.enable = lib.mkIf graphical true; with cfg;
lib.mkIf (enable && network && config.hardware.bluetooth.enable) {
services.blueman.enable = lib.mkIf graphical true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ bluetuith ] ++ lib.optional sound.enable pkgs.bluez;
bluetuith
] ++ lib.optional sound.enable pkgs.bluez;
systemd.user.services.mpris-proxy = lib.mkIf sound.enable { systemd.user.services.mpris-proxy = lib.mkIf sound.enable {
description = "Mpris proxy"; description = "Mpris proxy";
after = [ "network.target" "sound.target" ]; after = [
wantedBy = [ "default.target" ]; "network.target"
serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; "sound.target"
];
wantedBy = [ "default.target" ];
serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy";
};
}; };
};
} }

View File

@ -1,19 +1,26 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && network) { config =
networking.networkmanager.enable = true; with cfg;
networking.useDHCP = lib.mkDefault true; lib.mkIf (enable && network) {
networking.networkmanager.enable = true;
networking.useDHCP = lib.mkDefault true;
hardware.bluetooth.enable = lib.mkDefault laptop_hardware.enable; hardware.bluetooth.enable = lib.mkDefault laptop_hardware.enable;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
wireguard-tools wireguard-tools
openconnect openconnect
]; ];
}; };
imports = [ ./bluetooth.nix ]; imports = [ ./bluetooth.nix ];

View File

@ -1,25 +1,37 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && printing) { config =
# Enable CUPS to print documents. with cfg;
services.printing.enable = true; lib.mkIf (enable && printing) {
services.printing.drivers = with pkgs; [ brgenml1lpr brgenml1cupswrapper ]; # Enable CUPS to print documents.
services.avahi = { services.printing.enable = true;
enable = true; services.printing.drivers = with pkgs; [
nssmdns4 = true; brgenml1lpr
openFirewall = true; brgenml1cupswrapper
}; ];
services.printing.cups-pdf.enable = true; services.avahi = {
hardware.sane.brscan4.enable = true; # enables support for SANE scanners enable = true;
nssmdns4 = true;
openFirewall = true;
};
services.printing.cups-pdf.enable = true;
hardware.sane.brscan4.enable = true; # enables support for SANE scanners
environment.systemPackages = with pkgs; (lib.optionals cfg.graphical [ environment.systemPackages =
kdePackages.skanpage with pkgs;
# libsForQt5.skanpage (lib.optionals cfg.graphical [
]); kdePackages.skanpage
}; # libsForQt5.skanpage
]);
};
options.grimmShared.printing = lib.mkEnableOption "Enables print and scan related options"; options.grimmShared.printing = lib.mkEnableOption "Enables print and scan related options";
} }

View File

@ -1,29 +1,36 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && sound.enable) { config =
sound.enable = true; with cfg;
hardware.pulseaudio.enable = false; lib.mkIf (enable && sound.enable) {
sound.enable = true;
hardware.pulseaudio.enable = false;
services.pipewire = { services.pipewire = {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
jack.enable = true; # osu uses jack jack.enable = true; # osu uses jack
lowLatency.enable = true; lowLatency.enable = true;
};
environment.systemPackages = with pkgs; [
pwvucontrol
playerctl
openal
pulseaudio
];
}; };
environment.systemPackages = with pkgs; [
pwvucontrol
playerctl
openal
pulseaudio
];
};
imports = [ imports = [
./spotify.nix ./spotify.nix
./midi.nix ./midi.nix

View File

@ -1,23 +1,28 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sound_font = pkgs.soundfont-fluid; sound_font = pkgs.soundfont-fluid;
in in
{ {
config = with cfg; lib.mkIf (enable && sound.midi) { config =
environment.systemPackages = with pkgs; [ with cfg;
mpv lib.mkIf (enable && sound.midi) {
timidity environment.systemPackages = with pkgs; [
ffmpeg-full mpv
sound_font timidity
]; ffmpeg-full
sound_font
];
environment.pathsToLink = [ environment.pathsToLink = [ "/share/soundfonts" ];
"/share/soundfonts"
];
environment.etc."timidity/timidity.cfg".text = "soundfont ${sound_font}/share/soundfonts/FluidR3_GM2-2.sf2"; environment.etc."timidity/timidity.cfg".text = "soundfont ${sound_font}/share/soundfonts/FluidR3_GM2-2.sf2";
}; };
options.grimmShared.sound.midi = lib.mkEnableOption "enable midi"; options.grimmShared.sound.midi = lib.mkEnableOption "enable midi";
} }

View File

@ -1,8 +1,9 @@
# source: https://github.com/fufexan/nix-gaming/raw/master/modules/pipewireLowLatency.nix # source: https://github.com/fufexan/nix-gaming/raw/master/modules/pipewireLowLatency.nix
{ config {
, pkgs config,
, lib pkgs,
, ... lib,
...
}: }:
let let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
@ -55,7 +56,10 @@ in
modules = [ modules = [
{ {
name = "libpipewire-module-rtkit"; name = "libpipewire-module-rtkit";
flags = [ "ifexists" "nofail" ]; flags = [
"ifexists"
"nofail"
];
args = { args = {
nice.level = -15; nice.level = -15;
rt = { rt = {
@ -93,11 +97,21 @@ in
configPackages = configPackages =
let let
# generate "matches" section of the rules # generate "matches" section of the rules
matches = toLua matches =
{ toLua
multiline = false; # looks better while inline {
indent = false; multiline = false; # looks better while inline
} [ [ [ "node.name" "matches" "alsa_output.*" ] ] ]; # nested lists are to produce `{{{ }}}` in the output indent = false;
}
[
[
[
"node.name"
"matches"
"alsa_output.*"
]
]
]; # nested lists are to produce `{{{ }}}` in the output
# generate "apply_properties" section of the rules # generate "apply_properties" section of the rules
apply_properties = toLua { } { apply_properties = toLua { } {

View File

@ -1,24 +1,27 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && spotify.enable) { config =
environment.systemPackages = [ with cfg;
pkgs.ncspot lib.mkIf (enable && spotify.enable) {
] ++ lib.optional graphical pkgs.spotify; environment.systemPackages = [ pkgs.ncspot ] ++ lib.optional graphical pkgs.spotify;
grimmShared = { grimmShared = {
sound.enable = true; sound.enable = true;
network = true; network = true;
};
}; };
};
options.grimmShared.spotify = { options.grimmShared.spotify = {
enable = lib.mkEnableOption "grimm-spotify"; enable = lib.mkEnableOption "grimm-spotify";
}; };
imports = [ imports = [ ./spotifyd.nix ];
./spotifyd.nix
];
} }

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
spotifyd_cache_dir = "/tmp/spotifyd"; spotifyd_cache_dir = "/tmp/spotifyd";
cfg = config.grimmShared; cfg = config.grimmShared;
@ -22,67 +27,77 @@ let
''; '';
in in
{ {
config = with cfg; lib.mkIf (enable && spotify.spotifyd.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
spotifyd lib.mkIf (enable && spotify.spotifyd.enable) {
spotifyd-dbus environment.systemPackages = with pkgs; [
]; spotifyd
spotifyd-dbus
];
systemd.services.init-spotifyd-cache-dir = { systemd.services.init-spotifyd-cache-dir = {
description = "Create the spotifyd cache dir"; description = "Create the spotifyd cache dir";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
script = '' script = ''
mkdir -p ${spotifyd_cache_dir} mkdir -p ${spotifyd_cache_dir}
chown spotifyd:spotifyd -R ${spotifyd_cache_dir} chown spotifyd:spotifyd -R ${spotifyd_cache_dir}
''; '';
};
grimmShared = {
sound.enable = true;
network = true;
};
services.pipewire.systemWide = true; # required for spotifyd as spotifyd runs as the spotifyd user
# spotifyd config
services.spotifyd = {
enable = true;
settings.global = {
bitrate = 320;
username = cfg.spotify.spotifyd.username;
device_name = "grimm_laptop";
password_cmd = let pass = cfg.spotify.spotifyd.pass; in with lib; if (lib.isPath pass || lib.isString pass) then "${pkgs.coreutils-full}/bin/cat ${pass}" else (getExe pass);
device_type = "computer";
dbus_type = "system";
device = "default";
control = "default";
volume_controller = "softvol";
# no_audio_cache = true;
spotifyd_cache_dir = spotifyd_cache_dir;
max_cache_size = 10000000000;
initial_volume = "90";
backend = "alsa"; # fixme
}; };
grimmShared = {
sound.enable = true;
network = true;
};
services.pipewire.systemWide = true; # required for spotifyd as spotifyd runs as the spotifyd user
# spotifyd config
services.spotifyd = {
enable = true;
settings.global = {
bitrate = 320;
username = cfg.spotify.spotifyd.username;
device_name = "grimm_laptop";
password_cmd =
let
pass = cfg.spotify.spotifyd.pass;
in
with lib;
if (lib.isPath pass || lib.isString pass) then
"${pkgs.coreutils-full}/bin/cat ${pass}"
else
(getExe pass);
device_type = "computer";
dbus_type = "system";
device = "default";
control = "default";
volume_controller = "softvol";
# no_audio_cache = true;
spotifyd_cache_dir = spotifyd_cache_dir;
max_cache_size = 10000000000;
initial_volume = "90";
backend = "alsa"; # fixme
};
};
services.dbus.packages = with pkgs; [ spotifyd-dbus ];
# spotifyd has access to global pipewire
users.users.spotifyd = {
isSystemUser = true;
group = "spotifyd";
extraGroups = [
"audio"
"pipewire"
];
};
# spotifyd is also a group
users.groups.spotifyd = { };
}; };
services.dbus.packages = with pkgs; [
spotifyd-dbus
];
# spotifyd has access to global pipewire
users.users.spotifyd = {
isSystemUser = true;
group = "spotifyd";
extraGroups = [ "audio" "pipewire" ];
};
# spotifyd is also a group
users.groups.spotifyd = { };
};
options.grimmShared.spotify.spotifyd = with lib; { options.grimmShared.spotify.spotifyd = with lib; {
enable = mkEnableOption "grimm-spotify-tui"; enable = mkEnableOption "grimm-spotify-tui";
@ -91,7 +106,6 @@ in
description = "spotify username"; description = "spotify username";
}; };
pass = mkOption { pass = mkOption {
type = types.either types.nonEmptyStr (types.either types.package types.path); type = types.either types.nonEmptyStr (types.either types.package types.path);
description = "command to execute to obtain login information or readable path to a file containing them"; description = "command to execute to obtain login information or readable path to a file containing them";

View File

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
@ -10,123 +15,128 @@ in
./python.nix ./python.nix
]; ];
config = with cfg; lib.mkIf (enable && tooling.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
(writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@") lib.mkIf (enable && tooling.enable) {
(writeShellScriptBin "tree" "${lib.getExe pkgs.eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time") environment.systemPackages =
(writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'') with pkgs;
urlencode [
pstree (writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@")
dos2unix (writeShellScriptBin "tree" "${lib.getExe pkgs.eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time")
(writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'')
urlencode
pstree
dos2unix
treefmt
gcc gcc
jdk17 jdk17
pkg-config pkg-config
unzip unzip
p7zip p7zip
tea tea
eza eza
fbcat fbcat
gomuks gomuks
btop btop
ranger ranger
wget wget
file file
util-linux util-linux
visualvm visualvm
imagemagick imagemagick
nmap nmap
hyfetch hyfetch
parted parted
glib glib
glibc glibc
expect expect
neovim-remote neovim-remote
] ++ lib.optionals cfg.graphical [ ]
wev ++ lib.optionals cfg.graphical [
qdirstat wev
libva-utils qdirstat
gparted libva-utils
]; gparted
];
programs.git = { programs.git = {
enable = true; enable = true;
lfs.enable = true; lfs.enable = true;
config = { config = {
init.defaultBranch = "main"; init.defaultBranch = "main";
credential.username = cfg.tooling.git_user; credential.username = cfg.tooling.git_user;
core.editor = lib.getExe pkgs.neovim; core.editor = lib.getExe pkgs.neovim;
user.name = cfg.tooling.git_user; user.name = cfg.tooling.git_user;
user.email = cfg.tooling.git_email; user.email = cfg.tooling.git_email;
push.autoSetupRemote = true; push.autoSetupRemote = true;
core.autocrlf = "input"; core.autocrlf = "input";
commit.gpgsign = true; commit.gpgsign = true;
pull.rebase = true; pull.rebase = true;
alias = { alias = {
pfusch = "push --force-with-lease --force-if-includes"; pfusch = "push --force-with-lease --force-if-includes";
fuck = "reset HEAD~1"; fuck = "reset HEAD~1";
fixup = "commit --fixup"; fixup = "commit --fixup";
};
}; };
}; };
};
environment.shellAliases = { environment.shellAliases = {
":q" = "exit"; ":q" = "exit";
"ls" = "eza"; "ls" = "eza";
}; };
programs.tmux = { programs.tmux = {
enable = true; enable = true;
historyLimit = 42000; historyLimit = 42000;
#keyMode = "vi"; #keyMode = "vi";
}; };
# virtualisation.docker.enable = true; # virtualisation.docker.enable = true;
services.dbus.implementation = "broker"; services.dbus.implementation = "broker";
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
vim-scala
fugitive
];
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ programs.neovim = {
vim-scala enable = true;
fugitive viAlias = true;
]; defaultEditor = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (lib.concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
programs.neovim = { luafile ${luarc}
enable = true;
viAlias = true;
defaultEditor = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (lib.concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
luafile ${luarc} if filereadable($HOME . "/.vimrc")
source ~/.vimrc
if filereadable($HOME . "/.vimrc") endif
source ~/.vimrc '';
endif packages.myVimPackage = {
''; start = tooling.nvim.plugins;
packages.myVimPackage = { opt = [ ];
start = tooling.nvim.plugins; };
opt = [ ];
}; };
}; };
};
programs.ssh.startAgent = true; programs.ssh.startAgent = true;
programs.thefuck.enable = true; programs.thefuck.enable = true;
}; };
options.grimmShared.tooling = with lib; { options.grimmShared.tooling = with lib; {
enable = mkEnableOption "grimm-tooling"; enable = mkEnableOption "grimm-tooling";

View File

@ -1,49 +1,53 @@
{ lib, pkgs, config, ... }: {
lib,
pkgs,
config,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
viewer_pkg = pkgs.zathura; viewer_pkg = pkgs.zathura;
viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",''; viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",'';
in in
{ {
config = with cfg; lib.mkIf (enable && tooling.enable && tooling.lilypond) { config =
environment.systemPackages = with pkgs; [ with cfg;
lilypond-with-fonts lib.mkIf (enable && tooling.enable && tooling.lilypond) {
] ++ lib.optional graphical viewer_pkg; environment.systemPackages =
environment.sessionVariables = { with pkgs;
LYEDITOR = "${lib.getExe pkgs.neovim-remote} -s +:'dr %(file)s | call cursor(%(line)s,%(char)s+1)'"; [ lilypond-with-fonts ] ++ lib.optional graphical viewer_pkg;
}; environment.sessionVariables = {
LYEDITOR = "${lib.getExe pkgs.neovim-remote} -s +:'dr %(file)s | call cursor(%(line)s,%(char)s+1)'";
};
grimmShared.sound.midi = true; grimmShared.sound.midi = true;
grimmShared.tooling.nvim = { grimmShared.tooling.nvim = {
extraLuaRC = lib.singleton '' extraLuaRC = lib.singleton ''
require('nvls').setup({ require('nvls').setup({
lilypond = { lilypond = {
options = { options = {
${viewer_def} ${viewer_def}
},
}, },
}, latex = {
latex = { options = {
options = { ${viewer_def}
${viewer_def} },
}, },
}, player = {
player = { options = {
options = { fluidsynth_flags = {
fluidsynth_flags = { "/run/current-system/sw/share/soundfonts/FluidR3_GM2-2.sf2"
"/run/current-system/sw/share/soundfonts/FluidR3_GM2-2.sf2" }
} }
} }
} })
}) '';
''; };
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ nvim-lilypond-suite ];
}; };
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
nvim-lilypond-suite
];
};
options.grimmShared.tooling.lilypond = lib.mkEnableOption "enable lilypond tooling"; options.grimmShared.tooling.lilypond = lib.mkEnableOption "enable lilypond tooling";
} }

View File

@ -1,4 +1,10 @@
{ pkgs, config, lib, inputs, ... }: {
pkgs,
config,
lib,
inputs,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
@ -7,7 +13,6 @@ in
(writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@") (writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@")
(writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@") (writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@")
(writeShellScriptBin "nixpkgs-review-head" "nixpkgs-review rev HEAD") (writeShellScriptBin "nixpkgs-review-head" "nixpkgs-review rev HEAD")
(writeShellScriptBin "fmt-all" ''find ./ -readable -writable -type f | grep "\.nix" | xargs nixpkgs-fmt'')
(writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"") (writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"")
nixpkgs-review nixpkgs-review
@ -20,16 +25,15 @@ in
niv niv
]; ];
environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; };
NIXPKGS_ALLOW_UNFREE = "1";
};
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ vim-nix ];
vim-nix
];
nix.settings = { nix.settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false; warn-dirty = false;
}; };
nix.gc = { nix.gc = {

View File

@ -1,30 +1,36 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && tooling.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
python3 lib.mkIf (enable && tooling.enable) {
] ++ lib.optionals cfg.graphical [ environment.systemPackages =
jetbrains.pycharm-community with pkgs;
]; [ python3 ] ++ lib.optionals cfg.graphical [ jetbrains.pycharm-community ];
programs.xonsh = { programs.xonsh = {
enable = true; enable = true;
config = '' config = ''
aliases[":q"] = "exit" aliases[":q"] = "exit"
aliases["ls"] = "eza" aliases["ls"] = "eza"
''; '';
package = pkgs.xonsh.override { package = pkgs.xonsh.override {
extraPackages = ps: with ps; [ extraPackages =
requests ps: with ps; [
matplotlib requests
numpy matplotlib
scipy numpy
pygobject3 scipy
]; pygobject3
];
};
}; };
}; };
};
} }

View File

@ -1,42 +1,55 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf enable { config =
security.polkit.enable = true; with cfg;
networking.firewall.enable = lib.mkIf network true; lib.mkIf enable {
security.rtkit.enable = true; security.polkit.enable = true;
networking.firewall.enable = lib.mkIf network true;
security.rtkit.enable = true;
security.doas.enable = true; security.doas.enable = true;
security.sudo.enable = false; security.sudo.enable = false;
security.doas.extraRules = [{ security.doas.extraRules = [
users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users); {
keepEnv = true; users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users);
persist = true; keepEnv = true;
}]; persist = true;
}
];
environment.systemPackages = with pkgs; [ environment.systemPackages =
mkpasswd with pkgs;
gnupg [
libsecret mkpasswd
vulnix gnupg
doas-sudo-shim # muscle memory libsecret
agenix vulnix
] ++ lib.optionals (tooling.enable && tooling.pass) [ doas-sudo-shim # muscle memory
pass agenix
(writeShellScriptBin "passw" "pass $@") ]
] ++ lib.optional graphical lxqt.lxqt-policykit; ++ lib.optionals (tooling.enable && tooling.pass) [
pass
(writeShellScriptBin "passw" "pass $@")
]
++ lib.optional graphical lxqt.lxqt-policykit;
services.passSecretService.enable = lib.mkIf (tooling.enable && tooling.pass) true; services.passSecretService.enable = lib.mkIf (tooling.enable && tooling.pass) true;
programs.gnupg.agent = { programs.gnupg.agent = {
settings = { settings = {
# default-cache-ttl = 6000; # default-cache-ttl = 6000;
};
pinentryPackage = with pkgs; lib.mkForce (if graphical then pinentry-qt else pinentry-tty);
enable = true;
}; };
pinentryPackage = with pkgs; lib.mkForce (if graphical then pinentry-qt else pinentry-tty);
enable = true;
}; };
};
options.grimmShared.tooling.pass = lib.mkEnableOption "Enables password-store, gnupg and such secret handling"; options.grimmShared.tooling.pass = lib.mkEnableOption "Enables password-store, gnupg and such secret handling";
} }

View File

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
browsers = [ browsers = [
@ -15,12 +20,8 @@ let
"org.kde.krita.desktop" "org.kde.krita.desktop"
"draw.desktop" "draw.desktop"
]; ];
audio_players = [ audio_players = [ "vlc.desktop" ];
"vlc.desktop" video_viewers = [ "vlc.desktop" ];
];
video_viewers = [
"vlc.desktop"
];
document_viewers = [ document_viewers = [
"org.pwmt.zathura-pdf-mupdf.desktop" "org.pwmt.zathura-pdf-mupdf.desktop"
"com.github.jeromerobert.pdfarranger.desktop" "com.github.jeromerobert.pdfarranger.desktop"
@ -34,108 +35,111 @@ let
tex_editors = [ ] ++ text_editors; tex_editors = [ ] ++ text_editors;
in in
{ {
config = with cfg; lib.mkIf (enable && portals && graphical) { config =
environment.systemPackages = with pkgs; [ with cfg;
deskwhich lib.mkIf (enable && portals && graphical) {
environment.systemPackages = with pkgs; [
deskwhich
zathura zathura
alacritty alacritty
imhex imhex
libreoffice-qt libreoffice-qt
filezilla filezilla
obsidian obsidian
nomacs nomacs
pdfarranger pdfarranger
geany geany
krita krita
weasis weasis
kicad kicad
prusa-slicer prusa-slicer
freecad freecad
openscad openscad
vlc vlc
blender blender
thunderbird thunderbird
xdg-terminal-exec xdg-terminal-exec
xdg-utils xdg-utils
]; ];
xdg.terminal-exec = { xdg.terminal-exec = {
enable = true; enable = true;
settings = { settings = {
default = [ "Alacritty.desktop" "kitty.desktop" ]; default = [
"Alacritty.desktop"
"kitty.desktop"
];
};
};
xdg.mime.enable = true;
xdg.mime.addedAssociations = {
"application/java-vm" = [
"idea-community.desktop"
"imhex.desktop"
];
"application/json" = text_editors ++ [ "firefox-beta.desktop" ];
"application/mp4" = video_viewers;
"application/ogg" = audio_players;
"application/octet-stream" = "imhex.desktop";
"application/pdf" = document_viewers;
"application/rss+xml" = text_editors;
"application/x-chess-pgn" = [ ] ++ text_editors; # fixme
"application/x-krita" = "org.kde.krita.desktop";
"application/x-latex" = tex_editors;
"application/x-tex" = tex_editors;
"application/x-texinfo" = tex_editors;
"application/xml" = text_editors;
"image/svg+xml" = image_viewers ++ browsers ++ text_editors;
"image/*" = image_viewers;
"image/vnd.dwg" = cad;
"model/*" = cad;
"gcode" = [
"PrusaGcodeviewer.desktop"
"PrusaSlicer.desktop"
];
"audio/*" = audio_players;
"text/*" = text_editors;
"text/plain" = text_editors;
"text/markdown" = [ "obsidian.desktop" ] ++ text_editors;
"text/csv" = [ "calc.desktop" ] ++ text_editors;
"text/html" = browsers ++ text_editors;
"text/x-python" = [ "pycharm-community.desktop" ] ++ text_editors;
"text/x-c" = [ "clion.desktop" ] ++ text_editors;
"text/x-java-source" = [ "idea-community.desktop" ] ++ text_editors;
"video/*" = video_viewers;
"inode/directory" = [
"ranger.desktop"
"dolphin.desktop"
];
"x-scheme-handler/mailto" = "thunderbird.desktop";
"application/vnd.oasis.opendocument.chart" = "calc.desktop";
"application/vnd.oasis.opendocument.chart-template" = "calc.desktop";
"application/vnd.oasis.opendocument.database" = "base.desktop";
"application/vnd.oasis.opendocument.formula" = "math.desktop";
"application/vnd.oasis.opendocument.formula-template" = "math.desktop";
"application/vnd.oasis.opendocument.graphics" = "draw.desktop";
"application/vnd.oasis.opendocument.graphics-template" = "draw.desktop";
"application/vnd.oasis.opendocument.image" = "draw.desktop";
"application/vnd.oasis.opendocument.image-template" = "draw.desktop";
"application/vnd.oasis.opendocument.presentation" = "impress.desktop";
"application/vnd.oasis.opendocument.presentation-template" = "impress.desktop";
"application/vnd.oasis.opendocument.spreadsheet" = "calc.desktop";
"application/vnd.oasis.opendocument.spreadsheet-template" = "calc.desktop";
"application/vnd.oasis.opendocument.text" = "writer.desktop";
"application/vnd.oasis.opendocument.text-master" = "writer.desktop";
"application/vnd.oasis.opendocument.text-template" = "writer.desktop";
"application/vnd.oasis.opendocument.text-web" = "writer.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.presentation" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.slide" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.slideshow" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.template" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" = "calc.desktop";
"application/vnd.openxmlformats-officedocument.spreadsheetml.template" = "calc.desktop";
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" = "writer.desktop";
"application/vnd.openxmlformats-officedocument.wordprocessingml.template" = "writer.desktop";
}; };
}; };
xdg.mime.enable = true;
xdg.mime.addedAssociations = {
"application/java-vm" = [
"idea-community.desktop"
"imhex.desktop"
];
"application/json" = text_editors ++ [
"firefox-beta.desktop"
];
"application/mp4" = video_viewers;
"application/ogg" = audio_players;
"application/octet-stream" = "imhex.desktop";
"application/pdf" = document_viewers;
"application/rss+xml" = text_editors;
"application/x-chess-pgn" = [ ] ++ text_editors; # fixme
"application/x-krita" = "org.kde.krita.desktop";
"application/x-latex" = tex_editors;
"application/x-tex" = tex_editors;
"application/x-texinfo" = tex_editors;
"application/xml" = text_editors;
"image/svg+xml" = image_viewers ++ browsers ++ text_editors;
"image/*" = image_viewers;
"image/vnd.dwg" = cad;
"model/*" = cad;
"gcode" = [
"PrusaGcodeviewer.desktop"
"PrusaSlicer.desktop"
];
"audio/*" = audio_players;
"text/*" = text_editors;
"text/plain" = text_editors;
"text/markdown" = [ "obsidian.desktop" ] ++ text_editors;
"text/csv" = [ "calc.desktop" ] ++ text_editors;
"text/html" = browsers ++ text_editors;
"text/x-python" = [ "pycharm-community.desktop" ] ++ text_editors;
"text/x-c" = [ "clion.desktop" ] ++ text_editors;
"text/x-java-source" = [ "idea-community.desktop" ] ++ text_editors;
"video/*" = video_viewers;
"inode/directory" = [
"ranger.desktop"
"dolphin.desktop"
];
"x-scheme-handler/mailto" = "thunderbird.desktop";
"application/vnd.oasis.opendocument.chart" = "calc.desktop";
"application/vnd.oasis.opendocument.chart-template" = "calc.desktop";
"application/vnd.oasis.opendocument.database" = "base.desktop";
"application/vnd.oasis.opendocument.formula" = "math.desktop";
"application/vnd.oasis.opendocument.formula-template" = "math.desktop";
"application/vnd.oasis.opendocument.graphics" = "draw.desktop";
"application/vnd.oasis.opendocument.graphics-template" = "draw.desktop";
"application/vnd.oasis.opendocument.image" = "draw.desktop";
"application/vnd.oasis.opendocument.image-template" = "draw.desktop";
"application/vnd.oasis.opendocument.presentation" = "impress.desktop";
"application/vnd.oasis.opendocument.presentation-template" = "impress.desktop";
"application/vnd.oasis.opendocument.spreadsheet" = "calc.desktop";
"application/vnd.oasis.opendocument.spreadsheet-template" = "calc.desktop";
"application/vnd.oasis.opendocument.text" = "writer.desktop";
"application/vnd.oasis.opendocument.text-master" = "writer.desktop";
"application/vnd.oasis.opendocument.text-template" = "writer.desktop";
"application/vnd.oasis.opendocument.text-web" = "writer.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.presentation" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.slide" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.slideshow" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.presentationml.template" = "impress.desktop";
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" = "calc.desktop";
"application/vnd.openxmlformats-officedocument.spreadsheetml.template" = "calc.desktop";
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" = "writer.desktop";
"application/vnd.openxmlformats-officedocument.wordprocessingml.template" = "writer.desktop";
};
};
} }

View File

@ -1,40 +1,48 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && portals) { config =
xdg.icons.enable = true; with cfg;
xdg.sounds.enable = lib.mkIf sound.enable true; lib.mkIf (enable && portals) {
xdg.icons.enable = true;
xdg.sounds.enable = lib.mkIf sound.enable true;
xdg.portal = { xdg.portal = {
enable = true; enable = true;
xdgOpenUsePortal = true; xdgOpenUsePortal = true;
extraPortals = with pkgs; [ extraPortals = with pkgs; [
xdg-desktop-portal-wlr xdg-desktop-portal-wlr
xdg-desktop-portal-kde xdg-desktop-portal-kde
xdg-desktop-portal-gtk xdg-desktop-portal-gtk
]; ];
wlr.enable = true; wlr.enable = true;
wlr.settings = with lib; mapAttrs' wlr.settings =
(name: value: nameValuePair ("screencast_" + name) { with lib;
output_name = value.id; mapAttrs' (
max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps); name: value:
chooser_type = "simple"; nameValuePair ("screencast_" + name) {
chooser_cmd = "${getExe pkgs.slurp} -f %o -or"; output_name = value.id;
}) max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps);
cfg.screens; chooser_type = "simple";
chooser_cmd = "${getExe pkgs.slurp} -f %o -or";
}
) cfg.screens;
};
environment.sessionVariables = {
XDG_CONFIG_HOME = "$HOME/.config";
};
environment.systemPackages = with pkgs; [ xwaylandvideobridge ];
}; };
environment.sessionVariables = {
XDG_CONFIG_HOME = "$HOME/.config";
};
environment.systemPackages = with pkgs; [
xwaylandvideobridge
];
};
options.grimmShared.portals = lib.mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts"; options.grimmShared.portals = lib.mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts";
} }

View File

@ -1,15 +1,14 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = imports = [
[ ./overlays
./overlays ./common
./common ./fake_flake.nix
./fake_flake.nix ./specific/grimm-nixos-laptop/configuration.nix
./specific/grimm-nixos-laptop/configuration.nix ./modules/users.nix
./modules/users.nix # ./modules/kvm.nix
# ./modules/kvm.nix ./sway
./sway ];
];
# Bootloader. # Bootloader.
boot = { boot = {

View File

@ -1,6 +1,7 @@
{ fetchFromGitea {
, lib fetchFromGitea,
, rustPlatform lib,
rustPlatform,
}: }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "deskwhich"; pname = "deskwhich";

View File

@ -1,4 +1,10 @@
{ pkgs, lib, config, system, ... }: {
pkgs,
lib,
config,
system,
...
}:
let let
nivSources = import ./nix/sources.nix; nivSources = import ./nix/sources.nix;
asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}"; asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}";
@ -32,23 +38,24 @@ in
nixpkgs.pkgs = nixpkgs.pkgs =
let let
src = nivSources.nixpkgs; src = nivSources.nixpkgs;
config = { allowUnfree = true; }; config = {
allowUnfree = true;
};
unpatched = import src { inherit config system; }; unpatched = import src { inherit config system; };
inherit (unpatched) applyPatches fetchpatch; inherit (unpatched) applyPatches fetchpatch;
in in
import import (applyPatches {
(applyPatches { name = "nixpkgs-patched";
name = "nixpkgs-patched"; inherit src;
inherit src; patches = map fetchpatch nixpkgs_patches;
patches = map fetchpatch nixpkgs_patches; }) { inherit config; };
}) { inherit config; };
nixpkgs.overlays = lib.singleton ( nixpkgs.overlays = lib.singleton (
final: prev: { agenix = final.callPackage "${nivSources.agenix}/pkgs/agenix.nix" { }; } final: prev: { agenix = final.callPackage "${nivSources.agenix}/pkgs/agenix.nix" { }; }
); );
_module.args = { _module.args = {
system = "x86_64-linux"; system = "x86_64-linux";
}; };
nix.settings.extra-substituters = [ nix.settings.extra-substituters = [

View File

@ -48,10 +48,12 @@ let
done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)" done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)"
fi fi
''; '';
in in
{ {
environment.systemPackages = [ loadnvidia loadvfio ]; environment.systemPackages = [
loadnvidia
loadvfio
];
security.sudo.extraConfig = "grimmauld ALL=(ALL) NOPASSWD:/run/current-system/sw/bin/loadnvidia, /run/current-system/sw/bin/loadvfio"; security.sudo.extraConfig = "grimmauld ALL=(ALL) NOPASSWD:/run/current-system/sw/bin/loadnvidia, /run/current-system/sw/bin/loadvfio";
virtualisation.libvirtd = { virtualisation.libvirtd = {
enable = true; enable = true;
@ -69,8 +71,6 @@ in
onShutdown = "shutdown"; onShutdown = "shutdown";
}; };
programs.virt-manager.enable = true; programs.virt-manager.enable = true;
virtualisation.spiceUSBRedirection.enable = true; virtualisation.spiceUSBRedirection.enable = true;
} }

View File

@ -1,4 +1,10 @@
{ lib, config, pkgs, ... }: { {
lib,
config,
pkgs,
...
}:
{
users.users.grimmauld = { users.users.grimmauld = {
isNormalUser = true; isNormalUser = true;
# shell = pkgs.xonsh; # shell = pkgs.xonsh;

View File

@ -6,134 +6,177 @@ let
# The fetchers. fetch_<type> fetches specs of type <type>. # The fetchers. fetch_<type> fetches specs of type <type>.
# #
fetch_file = pkgs: name: spec: fetch_file =
pkgs: name: spec:
let let
name' = sanitizeName name + "-src"; name' = sanitizeName name + "-src";
in in
if spec.builtin or true then if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; } builtins_fetchurl {
inherit (spec) url sha256;
name = name';
}
else else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; pkgs.fetchurl {
inherit (spec) url sha256;
name = name';
};
fetch_tarball = pkgs: name: spec: fetch_tarball =
pkgs: name: spec:
let let
name' = sanitizeName name + "-src"; name' = sanitizeName name + "-src";
in in
if spec.builtin or true then if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; } builtins_fetchTarball {
name = name';
inherit (spec) url sha256;
}
else else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; pkgs.fetchzip {
name = name';
inherit (spec) url sha256;
};
fetch_git = name: spec: fetch_git =
name: spec:
let let
ref = ref =
spec.ref or ( spec.ref or (
if spec ? branch then "refs/heads/${spec.branch}" else if spec ? branch then
if spec ? tag then "refs/tags/${spec.tag}" else "refs/heads/${spec.branch}"
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" else if spec ? tag then
"refs/tags/${spec.tag}"
else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"
); );
submodules = spec.submodules or false; submodules = spec.submodules or false;
submoduleArg = submoduleArg =
let let
nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0;
emptyArgWithWarning = emptyArgWithWarning =
if submodules if submodules then
then builtins.trace (
builtins.trace "The niv input \"${name}\" uses submodules "
( + "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
"The niv input \"${name}\" uses submodules " + "does not support them"
+ "but your nix's (${builtins.nixVersion}) builtins.fetchGit " ) { }
+ "does not support them" else
) { };
{ }
else { };
in in
if nixSupportsSubmodules if nixSupportsSubmodules then { inherit submodules; } else emptyArgWithWarning;
then { inherit submodules; }
else emptyArgWithWarning;
in in
builtins.fetchGit builtins.fetchGit (
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); {
url = spec.repo;
inherit (spec) rev;
inherit ref;
}
// submoduleArg
);
fetch_local = spec: spec.path; fetch_local = spec: spec.path;
fetch_builtin-tarball = name: throw fetch_builtin-tarball =
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. name:
$ niv modify ${name} -a type=tarball -a builtin=true''; throw ''
[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';
fetch_builtin-url = name: throw fetch_builtin-url =
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. name:
$ niv modify ${name} -a type=file -a builtin=true''; throw ''
[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';
# #
# Various helpers # Various helpers
# #
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name: sanitizeName =
( name:
concatMapStrings (s: if builtins.isList s then "-" else s) (concatMapStrings (s: if builtins.isList s then "-" else s) (
( builtins.split "[^[:alnum:]+._?=-]+" ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
builtins.split "[^[:alnum:]+._?=-]+" ));
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);
# The set of packages used when specs are fetched using non-builtins. # The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources: system: mkPkgs =
sources: system:
let let
sourcesNixpkgs = sourcesNixpkgs = import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; inherit system;
};
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.; hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in in
if builtins.hasAttr "nixpkgs" sources if builtins.hasAttr "nixpkgs" sources then
then sourcesNixpkgs sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then else if hasNixpkgsPath && !hasThisAsNixpkgsPath then
import <nixpkgs> { } import <nixpkgs> { }
else else
abort abort ''
'' Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or add a package called "nixpkgs" to your sources.json.
add a package called "nixpkgs" to your sources.json. '';
'';
# The actual fetching function. # The actual fetching function.
fetch = pkgs: name: spec: fetch =
pkgs: name: spec:
if ! builtins.hasAttr "type" spec then if !builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute" abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs name spec else if spec.type == "file" then
else if spec.type == "tarball" then fetch_tarball pkgs name spec fetch_file pkgs name spec
else if spec.type == "git" then fetch_git name spec else if spec.type == "tarball" then
else if spec.type == "local" then fetch_local spec fetch_tarball pkgs name spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name else if spec.type == "git" then
else if spec.type == "builtin-url" then fetch_builtin-url name fetch_git name spec
else if spec.type == "local" then
fetch_local spec
else if spec.type == "builtin-tarball" then
fetch_builtin-tarball name
else if spec.type == "builtin-url" then
fetch_builtin-url name
else else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use # If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source. # the path directly as opposed to the fetched source.
replace = name: drv: replace =
name: drv:
let let
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in in
if ersatz == "" then drv else if ersatz == "" then
# this turns the string into an actual Nix path (for both absolute and drv
# relative paths) else
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; # this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then
/. + ersatz
else
/. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions # Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist # a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or ( mapAttrs =
f: set: with builtins; builtins.mapAttrs or (
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) f: set:
); with builtins;
listToAttrs (
map (attr: {
name = attr;
value = f attr set.${attr};
}) (attrNames set)
)
);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); range =
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
@ -147,7 +190,12 @@ let
optionalAttrs = cond: as: if cond then as else { }; optionalAttrs = cond: as: if cond then as else { };
# fetchTarball version that is compatible between all the versions of Nix # fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs: builtins_fetchTarball =
{
url,
name ? null,
sha256,
}@attrs:
let let
inherit (builtins) lessThan nixVersion fetchTarball; inherit (builtins) lessThan nixVersion fetchTarball;
in in
@ -157,7 +205,12 @@ let
fetchTarball attrs; fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix # fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs: builtins_fetchurl =
{
url,
name ? null,
sha256,
}@attrs:
let let
inherit (builtins) lessThan nixVersion fetchurl; inherit (builtins) lessThan nixVersion fetchurl;
in in
@ -167,32 +220,30 @@ let
fetchurl attrs; fetchurl attrs;
# Create the final "sources" from the config # Create the final "sources" from the config
mkSources = config: mkSources =
mapAttrs config:
( mapAttrs (
name: spec: name: spec:
if builtins.hasAttr "outPath" spec if builtins.hasAttr "outPath" spec then
then abort "The values in sources.json should not have an 'outPath' attribute"
abort else
"The values in sources.json should not have an 'outPath' attribute" spec // { outPath = replace name (fetch config.pkgs name spec); }
else ) config.sources;
spec // { outPath = replace name (fetch config.pkgs name spec); }
)
config.sources;
# The "config" used by the fetchers # The "config" used by the fetchers
mkConfig = mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null {
, sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null,
, system ? builtins.currentSystem sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile),
, pkgs ? mkPkgs sources system system ? builtins.currentSystem,
}: rec { pkgs ? mkPkgs sources system,
}:
rec {
# The sources, i.e. the attribute set of spec name to spec # The sources, i.e. the attribute set of spec name to spec
inherit sources; inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs; inherit pkgs;
}; };
in in
mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

View File

@ -1,7 +1,24 @@
{ config, lib, ... }: { { config, lib, ... }:
nixpkgs.overlays = map (f: (final: prev: (import f { inherit final prev lib config; }))) [ {
./deskwhich.nix nixpkgs.overlays =
./mcontrolcenter.nix map
./the-powder-toy.nix (
]; f:
(
final: prev:
(import f {
inherit
final
prev
lib
config
;
})
)
)
[
./deskwhich.nix
./mcontrolcenter.nix
./the-powder-toy.nix
];
} }

View File

@ -1,3 +1,4 @@
{ final, prev, ... }: { { final, prev, ... }:
{
deskwhich = prev.callPackage ../custom/deskwhich/package.nix { }; deskwhich = prev.callPackage ../custom/deskwhich/package.nix { };
} }

View File

@ -1,8 +1,7 @@
{ final, prev, ... }: { { final, prev, ... }:
mcontrolcenter = prev.callPackage {
(prev.fetchurl { mcontrolcenter = prev.callPackage (prev.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/2efffaa70e6de4cb34fd694798af5d433250f4e8/pkgs/by-name/mc/mcontrolcenter/package.nix"; url = "https://raw.githubusercontent.com/NixOS/nixpkgs/2efffaa70e6de4cb34fd694798af5d433250f4e8/pkgs/by-name/mc/mcontrolcenter/package.nix";
hash = "sha256-WnjSrSAurmN6dWOzjjZMXXxh0lUigyRPlXlg3OC0lu8="; hash = "sha256-WnjSrSAurmN6dWOzjjZMXXxh0lUigyRPlXlg3OC0lu8=";
}) }) { };
{ };
} }

View File

@ -1,8 +1,7 @@
{ final, prev, ... }: { { final, prev, ... }:
the-powder-toy = prev.callPackage {
(prev.fetchurl { the-powder-toy = prev.callPackage (prev.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/9863d8c74a959d73df0c495a55097f804f7b379d/pkgs/by-name/th/the-powder-toy/package.nix"; url = "https://raw.githubusercontent.com/NixOS/nixpkgs/9863d8c74a959d73df0c495a55097f804f7b379d/pkgs/by-name/th/the-powder-toy/package.nix";
hash = "sha256-po6jhmdV+HNZBq4/vy6uQsDuW6PyvKcvysWNPZn4K7I="; hash = "sha256-po6jhmdV+HNZBq4/vy6uQsDuW6PyvKcvysWNPZn4K7I=";
}) }) { };
{ };
} }

View File

@ -1,4 +1,5 @@
{ pkgs, ... }: { { pkgs, ... }:
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix

View File

@ -1,47 +1,53 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
let let
cpus = "12"; cpus = "12";
in in
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/installer/scan/not-detected.nix") # ./modules/nvidia.nix
# ./modules/nvidia.nix ];
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
boot.kernelParams = [ "possible_cpus=${cpus}" ]; boot.kernelParams = [ "possible_cpus=${cpus}" ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/3a4a7076-98e7-4ecd-bb07-7e182a04ceac";
device = "/dev/disk/by-uuid/3a4a7076-98e7-4ecd-bb07-7e182a04ceac"; fsType = "ext4";
fsType = "ext4"; options = [ "relatime" ];
options = [ "relatime" ]; };
};
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/D20D-B5B0";
device = "/dev/disk/by-uuid/D20D-B5B0"; fsType = "vfat";
fsType = "vfat"; options = [
options = [ "umask=077" "relatime" ]; "umask=077"
}; "relatime"
];
};
swapDevices = [{ swapDevices = [
device = "/var/lib/swapfile"; {
size = 48 * 1024; device = "/var/lib/swapfile";
}]; size = 48 * 1024;
}
];
environment.sessionVariables = { environment.sessionVariables = {
OMP_NUM_THREADS = cpus; OMP_NUM_THREADS = cpus;
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ mcontrolcenter ];
mcontrolcenter
];
grimmShared = { grimmShared = {
screens = { screens = {
@ -52,12 +58,14 @@ in
internal = { internal = {
id = "eDP-1"; id = "eDP-1";
fps = [ 144 60 ]; fps = [
144
60
];
}; };
}; };
laptop_hardware.enable = true; laptop_hardware.enable = true;
}; };
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
inherit (lib) getExe; inherit (lib) getExe;
in in
@ -8,16 +13,35 @@ in
config = with pkgs; { config = with pkgs; {
backlight = { backlight = {
format = "{percent}%"; format = "{percent}%";
format-icons = [ "" "" "" "" "" "" "" "" "" ]; format-icons = [
""
""
""
""
""
""
""
""
""
];
}; };
battery = { battery = {
format = "{capacity}% {icon}"; format = "{capacity}% {icon}";
format-alt = "{time} {icon}"; format-alt = "{time} {icon}";
format-charging = "{capacity}% "; format-charging = "{capacity}% ";
format-icons = [ "" "" "" "" "" ]; format-icons = [
""
""
""
""
""
];
format-plugged = "{capacity}% "; format-plugged = "{capacity}% ";
on-click = "${getExe rmenu} -r powermenu --single-click true"; on-click = "${getExe rmenu} -r powermenu --single-click true";
states = { critical = 15; warning = 30; }; states = {
critical = 15;
warning = 30;
};
}; };
clock = { clock = {
format-alt = "{:%d.%m.%Y}"; format-alt = "{:%d.%m.%Y}";
@ -41,19 +65,31 @@ in
height = 30; height = 30;
idle_inhibitor = { idle_inhibitor = {
format = "{icon}"; format = "{icon}";
format-icons = { activated = ""; deactivated = ""; }; format-icons = {
activated = "";
deactivated = "";
};
}; };
keyboard-state = { keyboard-state = {
capslock = true; capslock = true;
format = "{name} {icon}"; format = "{name} {icon}";
format-icons = { locked = ""; unlocked = ""; }; format-icons = {
locked = "";
unlocked = "";
};
numlock = true; numlock = true;
}; };
memory = { format = "{}% "; }; memory = {
format = "{}% ";
};
modules-center = [ modules-center = [
# "wlr/taskbar" # "wlr/taskbar"
]; ];
modules-left = [ "sway/workspaces" "sway/mode" "sway/scratchpad" ]; modules-left = [
"sway/workspaces"
"sway/mode"
"sway/scratchpad"
];
modules-right = [ modules-right = [
"custom/media" "custom/media"
"idle_inhibitor" "idle_inhibitor"
@ -84,7 +120,11 @@ in
format-bluetooth-muted = "{icon} {format_source}"; format-bluetooth-muted = "{icon} {format_source}";
format-icons = { format-icons = {
car = ""; car = "";
default = [ "" "" "" ]; default = [
""
""
""
];
hands-free = ""; hands-free = "";
headphone = ""; headphone = "";
headset = ""; headset = "";
@ -98,10 +138,15 @@ in
on-click = "${getExe pwvucontrol}"; on-click = "${getExe pwvucontrol}";
}; };
spacing = 4; spacing = 4;
"sway/mode" = { format = "<span style=\"italic\">{}</span>"; }; "sway/mode" = {
format = "<span style=\"italic\">{}</span>";
};
"sway/scratchpad" = { "sway/scratchpad" = {
format = "{icon} {count}"; format = "{icon} {count}";
format-icons = [ "" "" ]; format-icons = [
""
""
];
show-empty = false; show-empty = false;
tooltip = true; tooltip = true;
tooltip-format = "{app}: {title}"; tooltip-format = "{app}: {title}";
@ -109,16 +154,24 @@ in
temperature = { temperature = {
critical-threshold = 80; critical-threshold = 80;
format = "{temperatureC}°C {icon}"; format = "{temperatureC}°C {icon}";
format-icons = [ "" "" "" ]; format-icons = [
""
""
""
];
};
tray = {
spacing = 10;
}; };
tray = { spacing = 10; };
"wlr/taskbar" = { "wlr/taskbar" = {
format = "{icon}"; format = "{icon}";
icon-size = 14; icon-size = 14;
ignore-list = [ ]; ignore-list = [ ];
on-click = "activate"; on-click = "activate";
on-click-middle = "close"; on-click-middle = "close";
rewrite = { "Firefox Web Browser" = "Firefox"; }; rewrite = {
"Firefox Web Browser" = "Firefox";
};
tooltip-format = "{title}"; tooltip-format = "{title}";
}; };
}; };

View File

@ -1,16 +1,24 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
searchclip = let inherit (lib) getExe; in with pkgs; writeShellScriptBin "searchclip" '' searchclip =
xdg-open https://www.google.com/search?q=$(wl-paste -p | ${getExe urlencode}) let
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//") inherit (lib) getExe;
sleep .1 in
swaymsg [app_id="$browser" urgent="newest"] focus with pkgs;
''; writeShellScriptBin "searchclip" ''
xdg-open https://www.google.com/search?q=$(wl-paste -p | ${getExe urlencode})
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
sleep .1
swaymsg [app_id="$browser" urgent="newest"] focus
'';
in in
{ {
imports = [ imports = [ ./bar ];
./bar
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
rmenu rmenu
@ -28,213 +36,214 @@ in
grimmShared.sway = { grimmShared.sway = {
enable = true; enable = true;
config = with pkgs; let config =
inherit (lib) getExe; with pkgs;
in let
{ inherit (lib) getExe;
definitions = { in
mod = "Mod4"; {
left = "h"; definitions = {
down = "j"; mod = "Mod4";
up = "k"; left = "h";
right = "l"; down = "j";
menu = "${getExe rmenu} -r drun | xargs swaymsg exec --"; up = "k";
menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --"; right = "l";
menu = "${getExe rmenu} -r drun | xargs swaymsg exec --";
menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --";
primecol = "#8800FF"; primecol = "#8800FF";
accentcol = "#5700a0"; accentcol = "#5700a0";
splitcol = "#69507f"; splitcol = "#69507f";
actsplitcol = "#cd97fc"; actsplitcol = "#cd97fc";
darkcol = "#202020"; darkcol = "#202020";
urgentcol = "#9e3c3c"; urgentcol = "#9e3c3c";
realwhite = "#C7D3E3"; realwhite = "#C7D3E3";
};
keybinds = {
"$mod+d" = "exec $menu";
"$mod+Shift+d" = "exec $menu_run";
"$mod+Shift+s" = ''exec ${getExe grim} -g "$(${getExe slurp} -d)" - | wl-copy'';
"$mod+Return" = "exec ${getExe xdg-terminal-exec} xonsh";
"$mod+Shift+Return" = "exec ${getExe xdg-terminal-exec}";
"$mod+Shift+q" = "kill";
"$mod+Shift+c" = "reload";
"$mod+Shift+e" = "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'";
# Move your focus around
"$mod+$left" = "focus left";
"$mod+$down" = "focus down";
"$mod+$up" = "focus up";
"$mod+$right" = "focus right";
# Or use $mod+[up|down|left|right]
"$mod+Left" = "focus left";
"$mod+Down" = "focus down";
"$mod+Up" = "focus up";
"$mod+Right" = "focus right";
# Move the focused window with the same, but add Shift
"$mod+Shift+$left" = "move left";
"$mod+Shift+$down" = "move down";
"$mod+Shift+$up" = "move up";
"$mod+Shift+$right" = "move right";
# Ditto, with arrow keys
"$mod+Shift+Left" = "move left";
"$mod+Shift+Down" = "move down";
"$mod+Shift+Up" = "move up";
"$mod+Shift+Right" = "move right";
#
# Workspaces:
#
# Switch to workspace
"$mod+1" = "workspace number 1";
"$mod+2" = "workspace number 2";
"$mod+3" = "workspace number 3";
"$mod+4" = "workspace number 4";
"$mod+5" = "workspace number 5";
"$mod+6" = "workspace number 6";
"$mod+7" = "workspace number 7";
"$mod+8" = "workspace number 8";
"$mod+9" = "workspace number 9";
"$mod+0" = "workspace number 10";
# Move focused container to workspace
"$mod+Shift+1" = "move container to workspace number 1";
"$mod+Shift+2" = "move container to workspace number 2";
"$mod+Shift+3" = "move container to workspace number 3";
"$mod+Shift+4" = "move container to workspace number 4";
"$mod+Shift+5" = "move container to workspace number 5";
"$mod+Shift+6" = "move container to workspace number 6";
"$mod+Shift+7" = "move container to workspace number 7";
"$mod+Shift+8" = "move container to workspace number 8";
"$mod+Shift+9" = "move container to workspace number 9";
"$mod+Shift+0" = "move container to workspace number 10";
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
#
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
"$mod+b" = "splith";
"$mod+v" = "splitv";
# Switch the current container between different layout styles
"$mod+s" = "layout stacking";
"$mod+w" = "layout tabbed";
"$mod+e" = "layout toggle split";
# Make the current focus fullscreen
"$mod+f" = "fullscreen";
# Toggle the current focus between tiling and floating mode
"$mod+Shift+space" = "floating toggle";
# Swap focus between the tiling area and the floating area
"$mod+space" = "focus mode_toggle";
# Move focus to the parent container
"$mod+a" = "focus parent";
"$mod+Shift+minus" = "move scratchpad";
"$mod+minus" = "scratchpad show";
"$mod+r" = "mode \"resize\"";
XF86AudioRaiseVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
XF86AudioLowerVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"Shift+XF86AudioLowerVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ -5%";
"Shift+XF86AudioRaiseVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ +5%";
XF86AudioMute = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
XF86AudioPlay = "exec playerctl play-pause";
XF86AudioNext = "exec playerctl next";
XF86AudioPrev = "exec playerctl previous";
"$mod+c" = "exec ${getExe swaymux}";
XF86MonBrightnessUp = "exec ${getExe brightnessctl} s 10+%";
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
XF86Explorer = "exec ${getExe xdg-terminal-exec} ${getExe ranger}";
XF86Search = "exec ${getExe searchclip}";
XF86HomePage =
let
open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
swaymsg [app_id="$browser"] focus || ${getExe deskwhich} $browser | xargs gio launch
'';
in
"exec ${getExe open}";
XF86Tools =
let
open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
# FIXME: spotify is being weird
while IFS= read -r pid; do
swaymsg [pid=$pid] focus && exit 0
done <<< $(pgrep spotify -u "$(whoami)")
${getExe deskwhich} spotify | xargs gio launch
'';
in
"exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
XF86Mail =
let
open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
swaymsg [app_id="$desk"] focus || ${getExe deskwhich} $desk | xargs gio launch
'';
in
"exec ${getExe open}";
# XF86Bluetooth = "exec blueman-manager";
};
autolaunch = with pkgs; [
# fixme: absolute paths
"blueman-applet"
"lxqt-policykit-agent"
"otd-daemon"
swaynotificationcenter
networkmanagerapplet
# (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart
"dbus-update-activation-environment"
];
extraConfig = ''
output * bg ${./wallpapers/switzerland.jpg} fill
floating_modifier $mod normal
input type:keyboard xkb_numlock enabled
include /etc/sway/config.d/*
# Borders, gaps, titlebars, behavior
default_border pixel 3
default_floating_border pixel 3
gaps inner 5
titlebar_padding 5 5
#5Smart things
smart_gaps on
hide_edge_borders --i3 smart
input * {
xkb_layout "de"
dwt disabled
}
for_window [app_id="swaymux"] floating enable
for_window [app_id="rmenu"] floating enable
for_window [app_id="firefox.*" title="Picture-in-Picture"] floating enable
for_window [app_id="lxqt-policykit-agent"] floating enable;
'';
modes.resize.keybinds = {
"$left" = "resize shrink width 10px";
"$down" = "resize grow height 10px";
"$up" = "resize shrink height 10px";
"$right" = "resize grow width 10px";
Left = "resize shrink width 10px";
Down = "resize grow height 10px";
Up = "resize shrink height 10px";
Right = "resize grow width 10px";
Return = "mode \"default\"";
Escape = "mode \"default\"";
};
}; };
keybinds = {
"$mod+d" = "exec $menu";
"$mod+Shift+d" = "exec $menu_run";
"$mod+Shift+s" = ''exec ${getExe grim} -g "$(${getExe slurp} -d)" - | wl-copy'';
"$mod+Return" = "exec ${getExe xdg-terminal-exec} xonsh";
"$mod+Shift+Return" = "exec ${getExe xdg-terminal-exec}";
"$mod+Shift+q" = "kill";
"$mod+Shift+c" = "reload";
"$mod+Shift+e" = "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'";
# Move your focus around
"$mod+$left" = "focus left";
"$mod+$down" = "focus down";
"$mod+$up" = "focus up";
"$mod+$right" = "focus right";
# Or use $mod+[up|down|left|right]
"$mod+Left" = "focus left";
"$mod+Down" = "focus down";
"$mod+Up" = "focus up";
"$mod+Right" = "focus right";
# Move the focused window with the same, but add Shift
"$mod+Shift+$left" = "move left";
"$mod+Shift+$down" = "move down";
"$mod+Shift+$up" = "move up";
"$mod+Shift+$right" = "move right";
# Ditto, with arrow keys
"$mod+Shift+Left" = "move left";
"$mod+Shift+Down" = "move down";
"$mod+Shift+Up" = "move up";
"$mod+Shift+Right" = "move right";
#
# Workspaces:
#
# Switch to workspace
"$mod+1" = "workspace number 1";
"$mod+2" = "workspace number 2";
"$mod+3" = "workspace number 3";
"$mod+4" = "workspace number 4";
"$mod+5" = "workspace number 5";
"$mod+6" = "workspace number 6";
"$mod+7" = "workspace number 7";
"$mod+8" = "workspace number 8";
"$mod+9" = "workspace number 9";
"$mod+0" = "workspace number 10";
# Move focused container to workspace
"$mod+Shift+1" = "move container to workspace number 1";
"$mod+Shift+2" = "move container to workspace number 2";
"$mod+Shift+3" = "move container to workspace number 3";
"$mod+Shift+4" = "move container to workspace number 4";
"$mod+Shift+5" = "move container to workspace number 5";
"$mod+Shift+6" = "move container to workspace number 6";
"$mod+Shift+7" = "move container to workspace number 7";
"$mod+Shift+8" = "move container to workspace number 8";
"$mod+Shift+9" = "move container to workspace number 9";
"$mod+Shift+0" = "move container to workspace number 10";
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
#
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
"$mod+b" = "splith";
"$mod+v" = "splitv";
# Switch the current container between different layout styles
"$mod+s" = "layout stacking";
"$mod+w" = "layout tabbed";
"$mod+e" = "layout toggle split";
# Make the current focus fullscreen
"$mod+f" = "fullscreen";
# Toggle the current focus between tiling and floating mode
"$mod+Shift+space" = "floating toggle";
# Swap focus between the tiling area and the floating area
"$mod+space" = "focus mode_toggle";
# Move focus to the parent container
"$mod+a" = "focus parent";
"$mod+Shift+minus" = "move scratchpad";
"$mod+minus" = "scratchpad show";
"$mod+r" = "mode \"resize\"";
XF86AudioRaiseVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
XF86AudioLowerVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"Shift+XF86AudioLowerVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ -5%";
"Shift+XF86AudioRaiseVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ +5%";
XF86AudioMute = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
XF86AudioPlay = "exec playerctl play-pause";
XF86AudioNext = "exec playerctl next";
XF86AudioPrev = "exec playerctl previous";
"$mod+c" = "exec ${getExe swaymux}";
XF86MonBrightnessUp = "exec ${getExe brightnessctl} s 10+%";
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
XF86Explorer = "exec ${getExe xdg-terminal-exec} ${getExe ranger}";
XF86Search = "exec ${getExe searchclip}";
XF86HomePage =
let
open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
swaymsg [app_id="$browser"] focus || ${getExe deskwhich} $browser | xargs gio launch
'';
in
"exec ${getExe open}";
XF86Tools =
let
open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
# FIXME: spotify is being weird
while IFS= read -r pid; do
swaymsg [pid=$pid] focus && exit 0
done <<< $(pgrep spotify -u "$(whoami)")
${getExe deskwhich} spotify | xargs gio launch
'';
in
"exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
XF86Mail =
let
open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
swaymsg [app_id="$desk"] focus || ${getExe deskwhich} $desk | xargs gio launch
'';
in
"exec ${getExe open}";
# XF86Bluetooth = "exec blueman-manager";
};
autolaunch = with pkgs; [
# fixme: absolute paths
"blueman-applet"
"lxqt-policykit-agent"
"otd-daemon"
swaynotificationcenter
networkmanagerapplet
# (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart
"dbus-update-activation-environment"
];
extraConfig = ''
output * bg ${./wallpapers/switzerland.jpg} fill
floating_modifier $mod normal
input type:keyboard xkb_numlock enabled
include /etc/sway/config.d/*
# Borders, gaps, titlebars, behavior
default_border pixel 3
default_floating_border pixel 3
gaps inner 5
titlebar_padding 5 5
#5Smart things
smart_gaps on
hide_edge_borders --i3 smart
input * {
xkb_layout "de"
dwt disabled
}
for_window [app_id="swaymux"] floating enable
for_window [app_id="rmenu"] floating enable
for_window [app_id="firefox.*" title="Picture-in-Picture"] floating enable
for_window [app_id="lxqt-policykit-agent"] floating enable;
'';
modes.resize.keybinds = {
"$left" = "resize shrink width 10px";
"$down" = "resize grow height 10px";
"$up" = "resize shrink height 10px";
"$right" = "resize grow width 10px";
Left = "resize shrink width 10px";
Down = "resize grow height 10px";
Up = "resize shrink height 10px";
Right = "resize grow width 10px";
Return = "mode \"default\"";
Escape = "mode \"default\"";
};
};
}; };
} }

4
treefmt.toml Normal file
View File

@ -0,0 +1,4 @@
[formatter.nix]
command = "nixfmt"
includes = ["*.nix"]
excludes = ["tests/**"]