From 2e8ca0ee0dcdcf7e7f26423213eedeb104d3a5c3 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Tue, 7 May 2024 23:31:41 +0200 Subject: [PATCH] treefmt --- .require_update | 0 common/cloudsync.nix | 194 ++++---- common/default.nix | 7 +- common/firefox.nix | 106 +++-- common/gaming.nix | 98 ++-- common/graphics/fonts.nix | 39 +- common/graphics/opengl.nix | 112 ++--- common/graphics/qt.nix | 86 ++-- common/graphics/sway.nix | 185 ++++---- common/hardware/laptop.nix | 158 ++++--- common/hardware/tlp.nix | 157 ++++--- common/localisation.nix | 46 +- common/network/bluetooth.nix | 32 +- common/network/default.nix | 27 +- common/printing.nix | 46 +- common/sound/default.nix | 45 +- common/sound/midi.nix | 31 +- common/sound/pipewireLowLatency.nix | 34 +- common/sound/spotify.nix | 27 +- common/sound/spotifyd.nix | 130 +++--- common/tooling/default.nix | 210 +++++---- common/tooling/lilypond.nix | 70 +-- common/tooling/nix.nix | 22 +- common/tooling/python.nix | 50 +- common/tooling/security.nix | 73 +-- common/xdg/mime.nix | 218 ++++----- common/xdg/portals.nix | 68 +-- configuration.nix | 19 +- custom/deskwhich/package.nix | 7 +- fake_flake.nix | 27 +- modules/kvm.nix | 8 +- modules/users.nix | 8 +- nix/sources.nix | 227 +++++---- overlays/default.nix | 29 +- overlays/deskwhich.nix | 3 +- overlays/mcontrolcenter.nix | 13 +- overlays/the-powder-toy.nix | 13 +- specific/grimm-nixos-laptop/configuration.nix | 3 +- .../hardware-configuration.nix | 62 +-- sway/bar/default.nix | 81 +++- sway/default.nix | 441 +++++++++--------- treefmt.toml | 4 + 42 files changed, 1811 insertions(+), 1405 deletions(-) delete mode 100644 .require_update create mode 100644 treefmt.toml diff --git a/.require_update b/.require_update deleted file mode 100644 index e69de29..0000000 diff --git a/common/cloudsync.nix b/common/cloudsync.nix index 93e84c5..6ddcf03 100644 --- a/common/cloudsync.nix +++ b/common/cloudsync.nix @@ -1,95 +1,119 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; - sync_mod = with lib; types.submodule ({ config, ... }: { - options = { - remote = mkOption { - type = types.nonEmptyStr; - description = "path on the cloud server"; - }; + sync_mod = + with lib; + types.submodule ( + { config, ... }: + { + options = { + remote = mkOption { + type = types.nonEmptyStr; + description = "path on the cloud server"; + }; - local = mkOption { - type = types.nonEmptyStr; - default = "$HOME/" + (concatStrings (builtins.match "/*(.+)" config.remote)); - description = "local path to sync"; - }; - }; - }); + local = mkOption { + type = types.nonEmptyStr; + default = "$HOME/" + (concatStrings (builtins.match "/*(.+)" config.remote)); + description = "local path to sync"; + }; + }; + } + ); in { - config = with cfg; lib.mkIf (enable && cloudSync.enable) ( - let - 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}"; - in - { - environment.systemPackages = with pkgs; [ - (writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server)) - nextcloud-client - ]; + config = + with cfg; + lib.mkIf (enable && cloudSync.enable) ( + let + 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}"; + in + { + environment.systemPackages = with pkgs; [ + (writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server)) + nextcloud-client + ]; - systemd.services = lib.mkMerge (lib.mapAttrsToList - (local_user: user_conf: - let - paths = user_conf.syncPaths; - sync_script = lib.strings.concatLines (map - ({ local, remote }: - let - remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote); - in - "${cloud_cmd} /${remote_clean} ${local} ${sync_server}") - paths); - in - { - # user-specific sync jobs - "nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) { - description = "Auto sync Nextcloud"; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; - serviceConfig.Type = "simple"; - serviceConfig.User = local_user; - serviceConfig.Group = "users"; - script = sync_script; - # TimeoutStopSec = "180"; - # KillMode = "process"; - # KillSignal = "SIGINT"; - wantedBy = [ "multi-user.target" ]; - enable = true; + systemd.services = lib.mkMerge ( + lib.mapAttrsToList ( + local_user: user_conf: + let + paths = user_conf.syncPaths; + sync_script = lib.strings.concatLines ( + map ( + { local, remote }: + let + remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote); + in + "${cloud_cmd} /${remote_clean} ${local} ${sync_server}" + ) paths + ); + in + { + # user-specific sync jobs + "nextcloud-autosync-${local_user}" = lib.mkIf (paths != [ ]) { + description = "Auto sync Nextcloud"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + serviceConfig.Type = "simple"; + serviceConfig.User = local_user; + serviceConfig.Group = "users"; + script = sync_script; + # TimeoutStopSec = "180"; + # 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; { enable = mkEnableOption "cloud_sync"; diff --git a/common/default.nix b/common/default.nix index a339f26..e1ae97b 100644 --- a/common/default.nix +++ b/common/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; { options.grimmShared = { diff --git a/common/firefox.nix b/common/firefox.nix index 1df454a..97ede67 100644 --- a/common/firefox.nix +++ b/common/firefox.nix @@ -1,64 +1,72 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && firefox.enable) { - environment.systemPackages = [ ] - ++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ]; + config = + with cfg; + lib.mkIf (enable && firefox.enable) { + environment.systemPackages = + [ ] + ++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ]; - programs.firefox = { - package = pkgs.firefox-beta; - enable = true; - nativeMessagingHosts.packages = [ ] - ++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ]; - languagePacks = lib.optionals cfg.locale [ "de" "en-US" ]; - policies = { - ExtensionSettings = lib.mkMerge [ - (lib.mkIf cfg.firefox.disableUserPlugins { - "*".installation_mode = "blocked"; - }) - (lib.mapAttrs - (guid: shortId: { + programs.firefox = { + package = pkgs.firefox-beta; + enable = true; + nativeMessagingHosts.packages = + [ ] + ++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ]; + languagePacks = lib.optionals cfg.locale [ + "de" + "en-US" + ]; + policies = { + ExtensionSettings = lib.mkMerge [ + (lib.mkIf cfg.firefox.disableUserPlugins { "*".installation_mode = "blocked"; }) + (lib.mapAttrs (guid: shortId: { # explicit plugins by config install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; 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) { - # password-store support - "passff@invicem.pro" = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/passff/latest.xpi"; - installation_mode = "force_installed"; - }; - }) - ]; - DisableTelemetry = true; - DisableFirefoxStudies = true; - EnableTrackingProtection = { - Value = true; - Locked = true; - Cryptomining = true; - Fingerprinting = true; - }; - DisablePocket = true; - DisableFirefoxAccounts = true; - DisableAccounts = true; - DisableFirefoxScreenshots = true; - OverrideFirstRunPage = ""; - OverridePostUpdatePage = ""; - DontCheckDefaultBrowser = true; - Preferences = { - "pdfjs.enableScripting" = false; + ]; + DisableTelemetry = true; + DisableFirefoxStudies = true; + EnableTrackingProtection = { + Value = true; + Locked = true; + Cryptomining = true; + Fingerprinting = true; + }; + DisablePocket = true; + DisableFirefoxAccounts = true; + DisableAccounts = true; + DisableFirefoxScreenshots = true; + OverrideFirstRunPage = ""; + OverridePostUpdatePage = ""; + DontCheckDefaultBrowser = true; + Preferences = { + "pdfjs.enableScripting" = false; - "media.hardware-video-decoding.enabled" = true; - "media.ffmpeg.vaapi.enabled" = true; - "media.rdd-ffmpeg.enabled" = true; - "media.navigator.mediadatadecoder_vpx_enabled" = true; - } // lib.optionalAttrs cfg.sway.enable { "browser.tabs.inTitlebar" = 0; }; + "media.hardware-video-decoding.enabled" = true; + "media.ffmpeg.vaapi.enabled" = true; + "media.rdd-ffmpeg.enabled" = true; + "media.navigator.mediadatadecoder_vpx_enabled" = true; + } // lib.optionalAttrs cfg.sway.enable { "browser.tabs.inTitlebar" = 0; }; + }; }; }; - }; options.grimmShared.firefox = with lib; { enable = mkEnableOption "grimm-firefox"; diff --git a/common/gaming.nix b/common/gaming.nix index 9ba5338..ffee865 100644 --- a/common/gaming.nix +++ b/common/gaming.nix @@ -1,56 +1,62 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && gaming) { - programs.steam = { - enable = true; - gamescopeSession.enable = true; - gamescopeSession.env = { - DRI_PRIME = "1"; + config = + with cfg; + lib.mkIf (enable && gaming) { + programs.steam = { + enable = true; + 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"; } diff --git a/common/graphics/fonts.nix b/common/graphics/fonts.nix index b8ac495..1d1d10a 100644 --- a/common/graphics/fonts.nix +++ b/common/graphics/fonts.nix @@ -1,20 +1,27 @@ -{ lib, pkgs, config, ... }: { - config = with config.grimmShared; lib.mkIf (enable && graphical) { - fonts = { - packages = with pkgs; [ - noto-fonts - noto-fonts-cjk - font-awesome - noto-fonts-emoji - roboto - liberation_ttf - ]; + lib, + pkgs, + config, + ... +}: +{ + config = + with config.grimmShared; + 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"; - }; - }; } diff --git a/common/graphics/opengl.nix b/common/graphics/opengl.nix index 59824d7..8dd9140 100644 --- a/common/graphics/opengl.nix +++ b/common/graphics/opengl.nix @@ -1,66 +1,74 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; - screen = with lib; types.submodule { - options = { - fps = mkOption { - type = types.either types.int (types.nonEmptyListOf types.int); - default = 60; - description = "max framerate of screen"; - }; + screen = + with lib; + types.submodule { + options = { + fps = mkOption { + type = types.either types.int (types.nonEmptyListOf types.int); + default = 60; + description = "max framerate of screen"; + }; - mode = mkOption { - type = types.nonEmptyStr; - default = "1920x1080"; - description = "pixel format of the screen"; - }; + mode = mkOption { + type = types.nonEmptyStr; + default = "1920x1080"; + description = "pixel format of the screen"; + }; - id = mkOption { - type = types.nonEmptyStr; - description = "ID of the screen"; - }; + id = mkOption { + type = types.nonEmptyStr; + description = "ID of the screen"; + }; - pos = mkOption { - type = types.nullOr types.nonEmptyStr; - default = null; - example = "0,0"; - description = "position where to place the screen"; + pos = mkOption { + type = types.nullOr types.nonEmptyStr; + default = null; + example = "0,0"; + description = "position where to place the screen"; + }; }; }; - }; in { - config = with cfg; lib.mkIf (enable && graphical) { - # Enable OpenGL - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - extraPackages = with pkgs; [ ]; + config = + with cfg; + lib.mkIf (enable && graphical) { + # Enable OpenGL + hardware.opengl = { + enable = true; + 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; { graphical = mkOption { type = types.bool; diff --git a/common/graphics/qt.nix b/common/graphics/qt.nix index d8d07aa..6594430 100644 --- a/common/graphics/qt.nix +++ b/common/graphics/qt.nix @@ -1,49 +1,55 @@ -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && graphical) { - qt = { - enable = true; - style = "kvantum"; - 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 = { + config = + with cfg; + lib.mkIf (enable && graphical) { + qt = { enable = true; - theme = "catppuccin-sddm-corners"; - wayland.enable = true; - wayland.compositor = "weston"; + style = "kvantum"; + platformTheme = "qt5ct"; }; - defaultSession = lib.optionalString cfg.sway.enable "sway"; - }; - boot.plymouth = { - themePackages = with pkgs; [ - catppuccin-plymouth - ]; - theme = "catppuccin-macchiato"; - enable = true; + 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; + 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; + }; }; - }; } diff --git a/common/graphics/sway.nix b/common/graphics/sway.nix index 9d67520..4bc51c6 100644 --- a/common/graphics/sway.nix +++ b/common/graphics/sway.nix @@ -1,79 +1,97 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; - sway_conf = with lib; types.submodule ({ config, ... }: rec { - options = { - keybinds = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "set of keybinds assigning key combo to action"; - }; + sway_conf = + with lib; + types.submodule ( + { config, ... }: + rec { + options = { + keybinds = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "set of keybinds assigning key combo to action"; + }; - autolaunch = mkOption { - type = types.listOf (types.either types.nonEmptyStr types.package); - default = [ ]; - description = "set of commands to be run at sway startup"; - }; + autolaunch = mkOption { + type = types.listOf (types.either types.nonEmptyStr types.package); + default = [ ]; + description = "set of commands to be run at sway startup"; + }; - execAlways = mkOption { - type = types.listOf (types.either types.nonEmptyStr types.package); - default = [ ]; - description = "set of commands to be run at sway reload"; - }; + execAlways = mkOption { + type = types.listOf (types.either types.nonEmptyStr types.package); + default = [ ]; + description = "set of commands to be run at sway reload"; + }; - extraConfig = mkOption { - type = types.str; - default = ""; - description = "additional sway config to be included"; - }; + extraConfig = mkOption { + type = types.str; + default = ""; + description = "additional sway config to be included"; + }; - definitions = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "set of definitions assigning variable to value"; - }; + definitions = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "set of definitions assigning variable to value"; + }; - modes = mkOption { - type = types.attrsOf sway_conf; - default = { }; - description = "possible modes to switch to, e.g. resize"; - }; - }; - }); + modes = mkOption { + type = types.attrsOf sway_conf; + default = { }; + description = "possible modes to switch to, e.g. resize"; + }; + }; + } + ); - build_screen_def = fps_func: with lib; let - output_def = mapAttrsToList - (name: value: + build_screen_def = + fps_func: + with lib; + let + output_def = mapAttrsToList ( + name: value: "output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz" + (optionalString (value.pos != null) " position ${value.pos}") - ) - cfg.screens; - in - '' - for pid in $(${pkgs.procps}/bin/pgrep sway -x) - do - uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid)) - export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock" - if [[ -e "$SWAYSOCK" ]] ; then - echo "sock is $SWAYSOCK" - ${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}' - fi - done - ''; + ) cfg.screens; + in + '' + for pid in $(${pkgs.procps}/bin/pgrep sway -x) + do + uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid)) + export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock" + if [[ -e "$SWAYSOCK" ]] ; then + echo "sock is $SWAYSOCK" + ${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}' + fi + done + ''; inherit (lib) getExe; 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); - init_screens_min_fps = with lib; pkgs.writeShellScriptBin "init-screens-min" - (build_screen_def fps_min); - init_screens_max_fps = with lib; pkgs.writeShellScriptBin "init-screens-max" - (build_screen_def fps_max); + init_screens_min_fps = + with lib; + pkgs.writeShellScriptBin "init-screens-min" (build_screen_def fps_min); + 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}"; in { config = 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" ( (lib.getExe config.programs.waybar.package) + (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 ''; - build_conf = with lib; sway_conf: + build_conf = + with lib; + sway_conf: let build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${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_mode_lines = mapAttrsToList (name: value: '' - mode "${name}" { - ${concatLines (map (item: " " + item ) (build_conf value))}}''); + build_mode_lines = mapAttrsToList ( + name: value: '' + mode "${name}" { + ${concatLines (map (item: " " + item) (build_conf value))}}'' + ); in - ([ ] + ( + [ ] ++ (build_definition_lines sway_conf.definitions) ++ (build_keybind_lines sway_conf.keybinds) ++ (build_exec_lines "exec" sway_conf.autolaunch) @@ -113,17 +136,17 @@ in sway_conf = lib.concatLines ( (build_conf cfg.sway.config) ++ lib.optional cfg.sway.bar.enable bar_config - ++ (lib.mapAttrsToList - (name: value: - "output ${value.id} mode ${value.mode}" - + (lib.optionalString (value.pos != null) " position ${value.pos}") - ) - cfg.screens) + ++ (lib.mapAttrsToList ( + name: value: + "output ${value.id} mode ${value.mode}" + + (lib.optionalString (value.pos != null) " position ${value.pos}") + ) cfg.screens) ); conf_path = "sway.conf"; in - with cfg; lib.mkIf (enable && sway.enable) { + with cfg; + lib.mkIf (enable && sway.enable) { environment.etc."${conf_path}".text = sway_conf; grimmShared.sway.config.execAlways = [ @@ -131,17 +154,19 @@ in init_screens_auto ]; - environment.systemPackages = [ - waybar_full - dbus-sway-environment - init_screens_min_fps - init_screens_max_fps - init_screens_auto - ] ++ (with pkgs; [ - procps - slurp - libnotify - ]); + environment.systemPackages = + [ + waybar_full + dbus-sway-environment + init_screens_min_fps + init_screens_max_fps + init_screens_auto + ] + ++ (with pkgs; [ + procps + slurp + libnotify + ]); systemd.services.reload-sway = { description = "Reload all running sway instances"; diff --git a/common/hardware/laptop.nix b/common/hardware/laptop.nix index 1e87567..62ea880 100644 --- a/common/hardware/laptop.nix +++ b/common/hardware/laptop.nix @@ -1,73 +1,82 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { - environment.systemPackages = with pkgs; [ - lm_sensors - lshw - pciutils - usbutils - opentabletdriver - ddcutil - python312Packages.py-cpuinfo - (writeShellScriptBin "lsiommu" ./lsiommu) - ] ++ lib.optionals graphical [ - ddcui - wootility - ]; + config = + with cfg; + lib.mkIf (enable && laptop_hardware.enable) { + environment.systemPackages = + with pkgs; + [ + lm_sensors + lshw + pciutils + usbutils + opentabletdriver + ddcutil + python312Packages.py-cpuinfo + (writeShellScriptBin "lsiommu" ./lsiommu) + ] + ++ lib.optionals graphical [ + ddcui + wootility + ]; - hardware.i2c.enable = true; - services.libinput.enable = true; - hardware.opentabletdriver.enable = true; - services.udisks2.enable = true; + hardware.i2c.enable = true; + services.libinput.enable = true; + hardware.opentabletdriver.enable = true; + services.udisks2.enable = true; - services.udev.extraRules = '' - SUBSYSTEM=="i2c-dev", ACTION=="add",\ - ATTR{name}=="NVIDIA i2c adapter*",\ - TAG+="ddcci",\ - TAG+="systemd",\ - 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 + services.udev.extraRules = '' + SUBSYSTEM=="i2c-dev", ACTION=="add",\ + ATTR{name}=="NVIDIA i2c adapter*",\ + TAG+="ddcci",\ + TAG+="systemd",\ + ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service" ''; - serviceConfig.Type = "oneshot"; - }; - boot = { - kernelParams = [ - # "splash" - "quiet" - # "intel_iommu=on" - # "iommu=force" - # "pcie_acs_override=downstream" - # "mmio_stale_data=full,nosmt" - # "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: { + 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 = { + kernelParams = [ + # "splash" + "quiet" + # "intel_iommu=on" + # "iommu=force" + # "pcie_acs_override=downstream" + # "mmio_stale_data=full,nosmt" + # "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 = [ (pkgs.fetchpatch { url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch"; @@ -75,22 +84,21 @@ in }) ]; })) - ]; - kernelModules = [ - # "kvm-intel" - # "vfio_pci" - # "vfio_iommu_type1" - # "vfio" - "ddcci_backlight" - "i2c-dev" - "ec_sys" - ]; - # blacklistedKernelModules = [ "i2c_nvidia_gpu" ]; + ]; + kernelModules = [ + # "kvm-intel" + # "vfio_pci" + # "vfio_iommu_type1" + # "vfio" + "ddcci_backlight" + "i2c-dev" + "ec_sys" + ]; + # blacklistedKernelModules = [ "i2c_nvidia_gpu" ]; + }; }; - }; options.grimmShared.laptop_hardware = { enable = lib.mkEnableOption "grimm-laptop"; }; } - diff --git a/common/hardware/tlp.nix b/common/hardware/tlp.nix index 81c7fd9..7d763e3 100644 --- a/common/hardware/tlp.nix +++ b/common/hardware/tlp.nix @@ -1,77 +1,110 @@ -{ pkgs, config, lib, system, ... }: +{ + pkgs, + config, + lib, + system, + ... +}: let 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; enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms); - powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([ - "${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed - "${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")); + powersave = + with pkgs; + writeShellScriptBin "powersave-mode" ( + concatLines ( + [ + "${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed + "${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 ([ - "${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed - "${getExe pkgs.brightnessctl} s 100%" # display brightness - ] ++ optionals enable_perf_policy [ - "${getExe x86_energy_perf_policy} 0" # performance preference - "${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo - ] ++ 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} - ''; + performance = pkgs.writeShellScriptBin "performance-mode" ( + concatLines ( + [ + "${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed + "${getExe pkgs.brightnessctl} s 100%" # display brightness + ] + ++ optionals enable_perf_policy [ + "${getExe x86_energy_perf_policy} 0" # performance preference + "${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo + ] + ++ 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 { - config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { - environment.systemPackages = with pkgs; [ - acpi - powertop - brightnessctl - cpupower - powersave - performance - auto - ] ++ optionals graphical [ - tlpui - ] ++ optional enable_perf_policy x86_energy_perf_policy; + config = + with cfg; + lib.mkIf (enable && laptop_hardware.enable) { + environment.systemPackages = + with pkgs; + [ + acpi + powertop + brightnessctl + cpupower + powersave + performance + auto + ] + ++ optionals graphical [ tlpui ] + ++ optional enable_perf_policy x86_energy_perf_policy; - services.acpid = { - enable = true; - acEventCommands = getExe auto; - }; + services.acpid = { + enable = true; + acEventCommands = getExe auto; + }; - powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; - powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; + powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; + powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; - services.power-profiles-daemon.enable = false; - services.upower.enable = true; - #boot.extraModulePackages = [ - # cpupower - #] ++ optional enable_perf_policy x86_energy_perf_policy; + services.power-profiles-daemon.enable = false; + services.upower.enable = true; + #boot.extraModulePackages = [ + # cpupower + #] ++ optional enable_perf_policy x86_energy_perf_policy; - services.tlp = { - enable = true; - settings = { - USB_AUTOSUSPEND = 1; - USB_EXCLUDE_BTUSB = 1; - USB_EXCLUDE_PHONE = 1; - SOUND_POWER_SAVE_ON_AC = 0; - SOUND_POWER_SAVE_ON_BAT = 1; - SATA_LINKPWR_ON_AC = "max_performance"; - SATA_LINKPWR_ON_BAT = "min_power"; - MAX_LOST_WORK_SECS_ON_BAT = 15; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_BOOST_ON_AC = 1; - CPU_BOOST_ON_BAT = 0; - RUNTIME_PM_ON_AC = "on"; - RUNTIME_PM_ON_BAT = "auto"; + services.tlp = { + enable = true; + settings = { + USB_AUTOSUSPEND = 1; + USB_EXCLUDE_BTUSB = 1; + USB_EXCLUDE_PHONE = 1; + SOUND_POWER_SAVE_ON_AC = 0; + SOUND_POWER_SAVE_ON_BAT = 1; + SATA_LINKPWR_ON_AC = "max_performance"; + SATA_LINKPWR_ON_BAT = "min_power"; + MAX_LOST_WORK_SECS_ON_BAT = 15; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_BOOST_ON_AC = 1; + CPU_BOOST_ON_BAT = 0; + RUNTIME_PM_ON_AC = "on"; + RUNTIME_PM_ON_BAT = "auto"; + }; }; }; - }; } - diff --git a/common/localisation.nix b/common/localisation.nix index 8c6f9b1..1566873 100644 --- a/common/localisation.nix +++ b/common/localisation.nix @@ -3,31 +3,33 @@ let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && locale) { - time.timeZone = "Europe/Berlin"; + config = + with cfg; + lib.mkIf (enable && locale) { + time.timeZone = "Europe/Berlin"; - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "de_DE.UTF-8"; + LC_IDENTIFICATION = "de_DE.UTF-8"; + LC_MEASUREMENT = "de_DE.UTF-8"; + LC_MONETARY = "de_DE.UTF-8"; + LC_NAME = "de_DE.UTF-8"; + LC_NUMERIC = "de_DE.UTF-8"; + LC_PAPER = "de_DE.UTF-8"; + LC_TELEPHONE = "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"; } diff --git a/common/network/bluetooth.nix b/common/network/bluetooth.nix index 2bc1edc..a58e3a4 100644 --- a/common/network/bluetooth.nix +++ b/common/network/bluetooth.nix @@ -1,20 +1,28 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && network && config.hardware.bluetooth.enable) { - services.blueman.enable = lib.mkIf graphical true; + config = + with cfg; + lib.mkIf (enable && network && config.hardware.bluetooth.enable) { + services.blueman.enable = lib.mkIf graphical true; - environment.systemPackages = with pkgs; [ - bluetuith - ] ++ lib.optional sound.enable pkgs.bluez; + environment.systemPackages = with pkgs; [ bluetuith ] ++ lib.optional sound.enable pkgs.bluez; - systemd.user.services.mpris-proxy = lib.mkIf sound.enable { - description = "Mpris proxy"; - after = [ "network.target" "sound.target" ]; - wantedBy = [ "default.target" ]; - serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; + systemd.user.services.mpris-proxy = lib.mkIf sound.enable { + description = "Mpris proxy"; + after = [ + "network.target" + "sound.target" + ]; + wantedBy = [ "default.target" ]; + serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; + }; }; - }; } diff --git a/common/network/default.nix b/common/network/default.nix index a45ace2..dcdc58f 100644 --- a/common/network/default.nix +++ b/common/network/default.nix @@ -1,19 +1,26 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && network) { - networking.networkmanager.enable = true; - networking.useDHCP = lib.mkDefault true; + config = + with cfg; + 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; [ - wireguard-tools - openconnect - ]; - }; + environment.systemPackages = with pkgs; [ + wireguard-tools + openconnect + ]; + }; imports = [ ./bluetooth.nix ]; diff --git a/common/printing.nix b/common/printing.nix index da8edd5..00db50b 100644 --- a/common/printing.nix +++ b/common/printing.nix @@ -1,25 +1,37 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && printing) { - # Enable CUPS to print documents. - services.printing.enable = true; - services.printing.drivers = with pkgs; [ brgenml1lpr brgenml1cupswrapper ]; - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - services.printing.cups-pdf.enable = true; - hardware.sane.brscan4.enable = true; # enables support for SANE scanners + config = + with cfg; + lib.mkIf (enable && printing) { + # Enable CUPS to print documents. + services.printing.enable = true; + services.printing.drivers = with pkgs; [ + brgenml1lpr + brgenml1cupswrapper + ]; + services.avahi = { + 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 [ - kdePackages.skanpage - # libsForQt5.skanpage - ]); - }; + environment.systemPackages = + with pkgs; + (lib.optionals cfg.graphical [ + kdePackages.skanpage + # libsForQt5.skanpage + ]); + }; options.grimmShared.printing = lib.mkEnableOption "Enables print and scan related options"; } diff --git a/common/sound/default.nix b/common/sound/default.nix index 665c120..99e4ed2 100644 --- a/common/sound/default.nix +++ b/common/sound/default.nix @@ -1,29 +1,36 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && sound.enable) { - sound.enable = true; - hardware.pulseaudio.enable = false; + config = + with cfg; + lib.mkIf (enable && sound.enable) { + sound.enable = true; + hardware.pulseaudio.enable = false; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; # osu uses jack - lowLatency.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; # osu uses jack + lowLatency.enable = true; + }; + + environment.systemPackages = with pkgs; [ + pwvucontrol + playerctl + openal + pulseaudio + ]; }; - environment.systemPackages = with pkgs; [ - pwvucontrol - playerctl - openal - pulseaudio - ]; - }; - imports = [ ./spotify.nix ./midi.nix diff --git a/common/sound/midi.nix b/common/sound/midi.nix index 7f0a1e8..725173c 100644 --- a/common/sound/midi.nix +++ b/common/sound/midi.nix @@ -1,23 +1,28 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.grimmShared; sound_font = pkgs.soundfont-fluid; in { - config = with cfg; lib.mkIf (enable && sound.midi) { - environment.systemPackages = with pkgs; [ - mpv - timidity - ffmpeg-full - sound_font - ]; + config = + with cfg; + lib.mkIf (enable && sound.midi) { + environment.systemPackages = with pkgs; [ + mpv + timidity + ffmpeg-full + sound_font + ]; - environment.pathsToLink = [ - "/share/soundfonts" - ]; + environment.pathsToLink = [ "/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"; } diff --git a/common/sound/pipewireLowLatency.nix b/common/sound/pipewireLowLatency.nix index 4285b96..0df8139 100644 --- a/common/sound/pipewireLowLatency.nix +++ b/common/sound/pipewireLowLatency.nix @@ -1,8 +1,9 @@ # source: https://github.com/fufexan/nix-gaming/raw/master/modules/pipewireLowLatency.nix -{ config -, pkgs -, lib -, ... +{ + config, + pkgs, + lib, + ... }: let inherit (lib.modules) mkIf; @@ -55,7 +56,10 @@ in modules = [ { name = "libpipewire-module-rtkit"; - flags = [ "ifexists" "nofail" ]; + flags = [ + "ifexists" + "nofail" + ]; args = { nice.level = -15; rt = { @@ -93,11 +97,21 @@ in configPackages = let # generate "matches" section of the rules - matches = toLua - { - multiline = false; # looks better while inline - indent = false; - } [ [ [ "node.name" "matches" "alsa_output.*" ] ] ]; # nested lists are to produce `{{{ }}}` in the output + matches = + toLua + { + multiline = false; # looks better while inline + indent = false; + } + [ + [ + [ + "node.name" + "matches" + "alsa_output.*" + ] + ] + ]; # nested lists are to produce `{{{ }}}` in the output # generate "apply_properties" section of the rules apply_properties = toLua { } { diff --git a/common/sound/spotify.nix b/common/sound/spotify.nix index 2da09b4..a13ad4a 100644 --- a/common/sound/spotify.nix +++ b/common/sound/spotify.nix @@ -1,24 +1,27 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && spotify.enable) { - environment.systemPackages = [ - pkgs.ncspot - ] ++ lib.optional graphical pkgs.spotify; + config = + with cfg; + lib.mkIf (enable && spotify.enable) { + environment.systemPackages = [ pkgs.ncspot ] ++ lib.optional graphical pkgs.spotify; - grimmShared = { - sound.enable = true; - network = true; + grimmShared = { + sound.enable = true; + network = true; + }; }; - }; options.grimmShared.spotify = { enable = lib.mkEnableOption "grimm-spotify"; }; - imports = [ - ./spotifyd.nix - ]; + imports = [ ./spotifyd.nix ]; } diff --git a/common/sound/spotifyd.nix b/common/sound/spotifyd.nix index 8966fb4..7102207 100644 --- a/common/sound/spotifyd.nix +++ b/common/sound/spotifyd.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let spotifyd_cache_dir = "/tmp/spotifyd"; cfg = config.grimmShared; @@ -22,67 +27,77 @@ let ''; in { - config = with cfg; lib.mkIf (enable && spotify.spotifyd.enable) { - environment.systemPackages = with pkgs; [ - spotifyd - spotifyd-dbus - ]; + config = + with cfg; + lib.mkIf (enable && spotify.spotifyd.enable) { + environment.systemPackages = with pkgs; [ + spotifyd + spotifyd-dbus + ]; - systemd.services.init-spotifyd-cache-dir = { - description = "Create the spotifyd cache dir"; - wantedBy = [ "multi-user.target" ]; + systemd.services.init-spotifyd-cache-dir = { + description = "Create the spotifyd cache dir"; + wantedBy = [ "multi-user.target" ]; - serviceConfig.Type = "oneshot"; - script = '' - mkdir -p ${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 + serviceConfig.Type = "oneshot"; + script = '' + mkdir -p ${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 + }; + }; + + 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; { enable = mkEnableOption "grimm-spotify-tui"; @@ -91,7 +106,6 @@ in description = "spotify username"; }; - pass = mkOption { 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"; diff --git a/common/tooling/default.nix b/common/tooling/default.nix index 3fe88bb..426fec0 100644 --- a/common/tooling/default.nix +++ b/common/tooling/default.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in @@ -10,123 +15,128 @@ in ./python.nix ]; - config = with cfg; lib.mkIf (enable && tooling.enable) { - environment.systemPackages = with pkgs; [ - (writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@") - (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 + config = + with cfg; + lib.mkIf (enable && tooling.enable) { + environment.systemPackages = + with pkgs; + [ + (writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@") + (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 - jdk17 - pkg-config - unzip - p7zip + gcc + jdk17 + pkg-config + unzip + p7zip - tea - eza + tea + eza - fbcat - gomuks - btop - ranger - wget - file - util-linux - visualvm - imagemagick - nmap + fbcat + gomuks + btop + ranger + wget + file + util-linux + visualvm + imagemagick + nmap - hyfetch - parted - glib - glibc - expect - neovim-remote - ] ++ lib.optionals cfg.graphical [ - wev - qdirstat - libva-utils - gparted - ]; + hyfetch + parted + glib + glibc + expect + neovim-remote + ] + ++ lib.optionals cfg.graphical [ + wev + qdirstat + libva-utils + gparted + ]; - programs.git = { - enable = true; - lfs.enable = true; - config = { - init.defaultBranch = "main"; - credential.username = cfg.tooling.git_user; - core.editor = lib.getExe pkgs.neovim; - user.name = cfg.tooling.git_user; - user.email = cfg.tooling.git_email; - push.autoSetupRemote = true; - core.autocrlf = "input"; - commit.gpgsign = true; - pull.rebase = true; - alias = { - pfusch = "push --force-with-lease --force-if-includes"; - fuck = "reset HEAD~1"; - fixup = "commit --fixup"; + programs.git = { + enable = true; + lfs.enable = true; + config = { + init.defaultBranch = "main"; + credential.username = cfg.tooling.git_user; + core.editor = lib.getExe pkgs.neovim; + user.name = cfg.tooling.git_user; + user.email = cfg.tooling.git_email; + push.autoSetupRemote = true; + core.autocrlf = "input"; + commit.gpgsign = true; + pull.rebase = true; + alias = { + pfusch = "push --force-with-lease --force-if-includes"; + fuck = "reset HEAD~1"; + fixup = "commit --fixup"; + }; }; }; - }; - environment.shellAliases = { - ":q" = "exit"; - "ls" = "eza"; - }; + environment.shellAliases = { + ":q" = "exit"; + "ls" = "eza"; + }; - programs.tmux = { - enable = true; - historyLimit = 42000; - #keyMode = "vi"; - }; + programs.tmux = { + enable = true; + historyLimit = 42000; + #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; [ - vim-scala - fugitive - ]; + programs.neovim = { + 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 - programs.neovim = { - 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} - luafile ${luarc} - - if filereadable($HOME . "/.vimrc") - source ~/.vimrc - endif - ''; - packages.myVimPackage = { - start = tooling.nvim.plugins; - opt = [ ]; + if filereadable($HOME . "/.vimrc") + source ~/.vimrc + endif + ''; + packages.myVimPackage = { + start = tooling.nvim.plugins; + opt = [ ]; + }; }; }; - }; - programs.ssh.startAgent = true; - programs.thefuck.enable = true; - }; + programs.ssh.startAgent = true; + programs.thefuck.enable = true; + }; options.grimmShared.tooling = with lib; { enable = mkEnableOption "grimm-tooling"; diff --git a/common/tooling/lilypond.nix b/common/tooling/lilypond.nix index 9b75c11..3ace45d 100644 --- a/common/tooling/lilypond.nix +++ b/common/tooling/lilypond.nix @@ -1,49 +1,53 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: let cfg = config.grimmShared; viewer_pkg = pkgs.zathura; viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",''; in { - config = with cfg; lib.mkIf (enable && tooling.enable && tooling.lilypond) { - environment.systemPackages = with pkgs; [ - 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)'"; - }; + config = + with cfg; + lib.mkIf (enable && tooling.enable && tooling.lilypond) { + environment.systemPackages = + with pkgs; + [ 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 = { - extraLuaRC = lib.singleton '' - require('nvls').setup({ - lilypond = { - options = { - ${viewer_def} + grimmShared.tooling.nvim = { + extraLuaRC = lib.singleton '' + require('nvls').setup({ + lilypond = { + options = { + ${viewer_def} + }, }, - }, - latex = { - options = { - ${viewer_def} + latex = { + options = { + ${viewer_def} + }, }, - }, - player = { - options = { - fluidsynth_flags = { - "/run/current-system/sw/share/soundfonts/FluidR3_GM2-2.sf2" + player = { + options = { + fluidsynth_flags = { + "/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"; - } diff --git a/common/tooling/nix.nix b/common/tooling/nix.nix index e9ac6f8..aaf4d1b 100644 --- a/common/tooling/nix.nix +++ b/common/tooling/nix.nix @@ -1,4 +1,10 @@ -{ pkgs, config, lib, inputs, ... }: +{ + pkgs, + config, + lib, + inputs, + ... +}: let cfg = config.grimmShared; in @@ -7,7 +13,6 @@ in (writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@") (writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@") (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\"") nixpkgs-review @@ -20,16 +25,15 @@ in niv ]; - environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { - NIXPKGS_ALLOW_UNFREE = "1"; - }; + environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; }; - grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ - vim-nix - ]; + grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ vim-nix ]; nix.settings = { - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; warn-dirty = false; }; nix.gc = { diff --git a/common/tooling/python.nix b/common/tooling/python.nix index 6c857a8..f1112dd 100644 --- a/common/tooling/python.nix +++ b/common/tooling/python.nix @@ -1,30 +1,36 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && tooling.enable) { - environment.systemPackages = with pkgs; [ - python3 - ] ++ lib.optionals cfg.graphical [ - jetbrains.pycharm-community - ]; + config = + with cfg; + lib.mkIf (enable && tooling.enable) { + environment.systemPackages = + with pkgs; + [ python3 ] ++ lib.optionals cfg.graphical [ jetbrains.pycharm-community ]; - programs.xonsh = { - enable = true; - config = '' - aliases[":q"] = "exit" - aliases["ls"] = "eza" - ''; - package = pkgs.xonsh.override { - extraPackages = ps: with ps; [ - requests - matplotlib - numpy - scipy - pygobject3 - ]; + programs.xonsh = { + enable = true; + config = '' + aliases[":q"] = "exit" + aliases["ls"] = "eza" + ''; + package = pkgs.xonsh.override { + extraPackages = + ps: with ps; [ + requests + matplotlib + numpy + scipy + pygobject3 + ]; + }; }; }; - }; } diff --git a/common/tooling/security.nix b/common/tooling/security.nix index 493d953..61d8884 100644 --- a/common/tooling/security.nix +++ b/common/tooling/security.nix @@ -1,42 +1,55 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf enable { - security.polkit.enable = true; - networking.firewall.enable = lib.mkIf network true; - security.rtkit.enable = true; + config = + with cfg; + lib.mkIf enable { + security.polkit.enable = true; + networking.firewall.enable = lib.mkIf network true; + security.rtkit.enable = true; - security.doas.enable = true; - security.sudo.enable = false; - security.doas.extraRules = [{ - users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users); - keepEnv = true; - persist = true; - }]; + security.doas.enable = true; + security.sudo.enable = false; + security.doas.extraRules = [ + { + users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users); + keepEnv = true; + persist = true; + } + ]; - environment.systemPackages = with pkgs; [ - mkpasswd - gnupg - libsecret - vulnix - doas-sudo-shim # muscle memory - agenix - ] ++ lib.optionals (tooling.enable && tooling.pass) [ - pass - (writeShellScriptBin "passw" "pass $@") - ] ++ lib.optional graphical lxqt.lxqt-policykit; + environment.systemPackages = + with pkgs; + [ + mkpasswd + gnupg + libsecret + vulnix + doas-sudo-shim # muscle memory + agenix + ] + ++ 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; - programs.gnupg.agent = { - settings = { - # default-cache-ttl = 6000; + services.passSecretService.enable = lib.mkIf (tooling.enable && tooling.pass) true; + programs.gnupg.agent = { + settings = { + # 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"; } diff --git a/common/xdg/mime.nix b/common/xdg/mime.nix index 7ed24ce..f14d386 100644 --- a/common/xdg/mime.nix +++ b/common/xdg/mime.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; browsers = [ @@ -15,12 +20,8 @@ let "org.kde.krita.desktop" "draw.desktop" ]; - audio_players = [ - "vlc.desktop" - ]; - video_viewers = [ - "vlc.desktop" - ]; + audio_players = [ "vlc.desktop" ]; + video_viewers = [ "vlc.desktop" ]; document_viewers = [ "org.pwmt.zathura-pdf-mupdf.desktop" "com.github.jeromerobert.pdfarranger.desktop" @@ -34,108 +35,111 @@ let tex_editors = [ ] ++ text_editors; in { - config = with cfg; lib.mkIf (enable && portals && graphical) { - environment.systemPackages = with pkgs; [ - deskwhich + config = + with cfg; + lib.mkIf (enable && portals && graphical) { + environment.systemPackages = with pkgs; [ + deskwhich - zathura - alacritty - imhex - libreoffice-qt - filezilla - obsidian - nomacs - pdfarranger - geany - krita - weasis - kicad - prusa-slicer - freecad - openscad - vlc - blender - thunderbird - xdg-terminal-exec - xdg-utils - ]; + zathura + alacritty + imhex + libreoffice-qt + filezilla + obsidian + nomacs + pdfarranger + geany + krita + weasis + kicad + prusa-slicer + freecad + openscad + vlc + blender + thunderbird + xdg-terminal-exec + xdg-utils + ]; - xdg.terminal-exec = { - enable = true; - settings = { - default = [ "Alacritty.desktop" "kitty.desktop" ]; + xdg.terminal-exec = { + enable = true; + settings = { + 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"; - }; - }; } diff --git a/common/xdg/portals.nix b/common/xdg/portals.nix index b4f9a80..234a0ee 100644 --- a/common/xdg/portals.nix +++ b/common/xdg/portals.nix @@ -1,40 +1,48 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.grimmShared; in { - config = with cfg; lib.mkIf (enable && portals) { - xdg.icons.enable = true; - xdg.sounds.enable = lib.mkIf sound.enable true; + config = + with cfg; + lib.mkIf (enable && portals) { + xdg.icons.enable = true; + xdg.sounds.enable = lib.mkIf sound.enable true; - xdg.portal = { - enable = true; - xdgOpenUsePortal = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-wlr - xdg-desktop-portal-kde - xdg-desktop-portal-gtk - ]; + xdg.portal = { + enable = true; + xdgOpenUsePortal = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-kde + xdg-desktop-portal-gtk + ]; - wlr.enable = true; - wlr.settings = with lib; mapAttrs' - (name: value: nameValuePair ("screencast_" + name) { - output_name = value.id; - max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps); - chooser_type = "simple"; - chooser_cmd = "${getExe pkgs.slurp} -f %o -or"; - }) - cfg.screens; + wlr.enable = true; + wlr.settings = + with lib; + mapAttrs' ( + name: value: + nameValuePair ("screencast_" + name) { + output_name = value.id; + max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps); + 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"; } diff --git a/configuration.nix b/configuration.nix index 20aaaba..514313c 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,15 +1,14 @@ { config, pkgs, ... }: { - imports = - [ - ./overlays - ./common - ./fake_flake.nix - ./specific/grimm-nixos-laptop/configuration.nix - ./modules/users.nix - # ./modules/kvm.nix - ./sway - ]; + imports = [ + ./overlays + ./common + ./fake_flake.nix + ./specific/grimm-nixos-laptop/configuration.nix + ./modules/users.nix + # ./modules/kvm.nix + ./sway + ]; # Bootloader. boot = { diff --git a/custom/deskwhich/package.nix b/custom/deskwhich/package.nix index 1b425af..985f352 100644 --- a/custom/deskwhich/package.nix +++ b/custom/deskwhich/package.nix @@ -1,6 +1,7 @@ -{ fetchFromGitea -, lib -, rustPlatform +{ + fetchFromGitea, + lib, + rustPlatform, }: rustPlatform.buildRustPackage rec { pname = "deskwhich"; diff --git a/fake_flake.nix b/fake_flake.nix index 8d2b2d9..0493c2a 100644 --- a/fake_flake.nix +++ b/fake_flake.nix @@ -1,4 +1,10 @@ -{ pkgs, lib, config, system, ... }: +{ + pkgs, + lib, + config, + system, + ... +}: let nivSources = import ./nix/sources.nix; asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}"; @@ -32,23 +38,24 @@ in nixpkgs.pkgs = let src = nivSources.nixpkgs; - config = { allowUnfree = true; }; + config = { + allowUnfree = true; + }; unpatched = import src { inherit config system; }; inherit (unpatched) applyPatches fetchpatch; in - import - (applyPatches { - name = "nixpkgs-patched"; - inherit src; - patches = map fetchpatch nixpkgs_patches; - }) { inherit config; }; + import (applyPatches { + name = "nixpkgs-patched"; + inherit src; + patches = map fetchpatch nixpkgs_patches; + }) { inherit config; }; nixpkgs.overlays = lib.singleton ( final: prev: { agenix = final.callPackage "${nivSources.agenix}/pkgs/agenix.nix" { }; } ); - _module.args = { - system = "x86_64-linux"; + _module.args = { + system = "x86_64-linux"; }; nix.settings.extra-substituters = [ diff --git a/modules/kvm.nix b/modules/kvm.nix index 4226c39..2854ddc 100644 --- a/modules/kvm.nix +++ b/modules/kvm.nix @@ -48,10 +48,12 @@ let done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)" fi ''; - 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"; virtualisation.libvirtd = { enable = true; @@ -69,8 +71,6 @@ in onShutdown = "shutdown"; }; - - programs.virt-manager.enable = true; virtualisation.spiceUSBRedirection.enable = true; } diff --git a/modules/users.nix b/modules/users.nix index d3e57e7..7677f02 100644 --- a/modules/users.nix +++ b/modules/users.nix @@ -1,4 +1,10 @@ -{ lib, config, pkgs, ... }: { +{ + lib, + config, + pkgs, + ... +}: +{ users.users.grimmauld = { isNormalUser = true; # shell = pkgs.xonsh; diff --git a/nix/sources.nix b/nix/sources.nix index fe3dadf..f7930e5 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -6,134 +6,177 @@ let # The fetchers. fetch_ fetches specs of type . # - fetch_file = pkgs: name: spec: + fetch_file = + pkgs: name: spec: let name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } + builtins_fetchurl { + inherit (spec) url sha256; + name = name'; + } 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 name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + builtins_fetchTarball { + name = name'; + inherit (spec) url sha256; + } 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 ref = spec.ref or ( - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" + if spec ? branch then + "refs/heads/${spec.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; submoduleArg = let nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; emptyArgWithWarning = - if submodules - then - builtins.trace - ( - "The niv input \"${name}\" uses submodules " - + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " - + "does not support them" - ) - { } - else { }; + if submodules then + builtins.trace ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) { } + else + { }; in - if nixSupportsSubmodules - then { inherit submodules; } - else emptyArgWithWarning; + if nixSupportsSubmodules then { inherit submodules; } else emptyArgWithWarning; in - builtins.fetchGit - ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); + builtins.fetchGit ( + { + url = spec.repo; + inherit (spec) rev; + inherit ref; + } + // submoduleArg + ); fetch_local = spec: spec.path; - fetch_builtin-tarball = name: 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-tarball = + name: + 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 - ''[${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''; + fetch_builtin-url = + name: + 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 # # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); + sanitizeName = + name: + (concatMapStrings (s: if builtins.isList s then "-" else s) ( + builtins.split "[^[:alnum:]+._?=-]+" ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + )); # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: + mkPkgs = + sources: system: let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + sourcesNixpkgs = import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { + inherit system; + }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then import { } else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; # 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" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then 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 if spec.type == "file" then + fetch_file pkgs name spec + else if spec.type == "tarball" then + fetch_tarball pkgs name spec + else if spec.type == "git" then + 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 abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; # If the environment variable NIV_OVERRIDE_${name} is set, then use # the path directly as opposed to the fetched source. - replace = name: drv: + replace = + name: drv: let saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; in - if ersatz == "" then drv else - # 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}"; + if ersatz == "" then + drv + else + # 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 # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); + mapAttrs = + builtins.mapAttrs or ( + 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 - 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 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 { }; # 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 inherit (builtins) lessThan nixVersion fetchTarball; in @@ -157,7 +205,12 @@ let fetchTarball attrs; # 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 inherit (builtins) lessThan nixVersion fetchurl; in @@ -167,32 +220,30 @@ let fetchurl attrs; # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) - config.sources; + mkSources = + config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec then + abort "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; # The "config" used by the fetchers mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { + { + sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null, + sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile), + system ? builtins.currentSystem, + pkgs ? mkPkgs sources system, + }: + rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers inherit pkgs; }; - in mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/overlays/default.nix b/overlays/default.nix index dc81283..e4f1b4d 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,7 +1,24 @@ -{ config, lib, ... }: { - nixpkgs.overlays = map (f: (final: prev: (import f { inherit final prev lib config; }))) [ - ./deskwhich.nix - ./mcontrolcenter.nix - ./the-powder-toy.nix - ]; +{ config, lib, ... }: +{ + nixpkgs.overlays = + map + ( + f: + ( + final: prev: + (import f { + inherit + final + prev + lib + config + ; + }) + ) + ) + [ + ./deskwhich.nix + ./mcontrolcenter.nix + ./the-powder-toy.nix + ]; } diff --git a/overlays/deskwhich.nix b/overlays/deskwhich.nix index 865e877..0c97931 100644 --- a/overlays/deskwhich.nix +++ b/overlays/deskwhich.nix @@ -1,3 +1,4 @@ -{ final, prev, ... }: { +{ final, prev, ... }: +{ deskwhich = prev.callPackage ../custom/deskwhich/package.nix { }; } diff --git a/overlays/mcontrolcenter.nix b/overlays/mcontrolcenter.nix index 9c18850..9adc5fc 100644 --- a/overlays/mcontrolcenter.nix +++ b/overlays/mcontrolcenter.nix @@ -1,8 +1,7 @@ -{ final, prev, ... }: { - mcontrolcenter = prev.callPackage - (prev.fetchurl { - url = "https://raw.githubusercontent.com/NixOS/nixpkgs/2efffaa70e6de4cb34fd694798af5d433250f4e8/pkgs/by-name/mc/mcontrolcenter/package.nix"; - hash = "sha256-WnjSrSAurmN6dWOzjjZMXXxh0lUigyRPlXlg3OC0lu8="; - }) - { }; +{ final, prev, ... }: +{ + mcontrolcenter = prev.callPackage (prev.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/2efffaa70e6de4cb34fd694798af5d433250f4e8/pkgs/by-name/mc/mcontrolcenter/package.nix"; + hash = "sha256-WnjSrSAurmN6dWOzjjZMXXxh0lUigyRPlXlg3OC0lu8="; + }) { }; } diff --git a/overlays/the-powder-toy.nix b/overlays/the-powder-toy.nix index 51f69ef..eb66055 100644 --- a/overlays/the-powder-toy.nix +++ b/overlays/the-powder-toy.nix @@ -1,8 +1,7 @@ -{ final, prev, ... }: { - the-powder-toy = prev.callPackage - (prev.fetchurl { - url = "https://raw.githubusercontent.com/NixOS/nixpkgs/9863d8c74a959d73df0c495a55097f804f7b379d/pkgs/by-name/th/the-powder-toy/package.nix"; - hash = "sha256-po6jhmdV+HNZBq4/vy6uQsDuW6PyvKcvysWNPZn4K7I="; - }) - { }; +{ final, prev, ... }: +{ + the-powder-toy = prev.callPackage (prev.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/9863d8c74a959d73df0c495a55097f804f7b379d/pkgs/by-name/th/the-powder-toy/package.nix"; + hash = "sha256-po6jhmdV+HNZBq4/vy6uQsDuW6PyvKcvysWNPZn4K7I="; + }) { }; } diff --git a/specific/grimm-nixos-laptop/configuration.nix b/specific/grimm-nixos-laptop/configuration.nix index e1bdb5a..b48d468 100644 --- a/specific/grimm-nixos-laptop/configuration.nix +++ b/specific/grimm-nixos-laptop/configuration.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix diff --git a/specific/grimm-nixos-laptop/hardware-configuration.nix b/specific/grimm-nixos-laptop/hardware-configuration.nix index 604899e..b0f0a18 100644 --- a/specific/grimm-nixos-laptop/hardware-configuration.nix +++ b/specific/grimm-nixos-laptop/hardware-configuration.nix @@ -1,47 +1,53 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: let cpus = "12"; in { - imports = - [ - (modulesPath + "/installer/scan/not-detected.nix") - # ./modules/nvidia.nix - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + # ./modules/nvidia.nix + ]; boot.initrd.kernelModules = [ ]; boot.extraModulePackages = [ ]; boot.kernelParams = [ "possible_cpus=${cpus}" ]; - fileSystems."/" = - { - device = "/dev/disk/by-uuid/3a4a7076-98e7-4ecd-bb07-7e182a04ceac"; - fsType = "ext4"; - options = [ "relatime" ]; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/3a4a7076-98e7-4ecd-bb07-7e182a04ceac"; + fsType = "ext4"; + options = [ "relatime" ]; + }; - fileSystems."/boot" = - { - device = "/dev/disk/by-uuid/D20D-B5B0"; - fsType = "vfat"; - options = [ "umask=077" "relatime" ]; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/D20D-B5B0"; + fsType = "vfat"; + options = [ + "umask=077" + "relatime" + ]; + }; - swapDevices = [{ - device = "/var/lib/swapfile"; - size = 48 * 1024; - }]; + swapDevices = [ + { + device = "/var/lib/swapfile"; + size = 48 * 1024; + } + ]; environment.sessionVariables = { OMP_NUM_THREADS = cpus; }; - environment.systemPackages = with pkgs; [ - mcontrolcenter - ]; + environment.systemPackages = with pkgs; [ mcontrolcenter ]; grimmShared = { screens = { @@ -52,12 +58,14 @@ in internal = { id = "eDP-1"; - fps = [ 144 60 ]; + fps = [ + 144 + 60 + ]; }; }; laptop_hardware.enable = true; }; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/sway/bar/default.nix b/sway/bar/default.nix index 8b7702b..5438cf8 100644 --- a/sway/bar/default.nix +++ b/sway/bar/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let inherit (lib) getExe; in @@ -8,16 +13,35 @@ in config = with pkgs; { backlight = { format = "{percent}%"; - format-icons = [ "" "" "" "" "" "" "" "" "" ]; + format-icons = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + ]; }; battery = { format = "{capacity}% {icon}"; format-alt = "{time} {icon}"; format-charging = "{capacity}% "; - format-icons = [ "" "" "" "" "" ]; + format-icons = [ + "" + "" + "" + "" + "" + ]; format-plugged = "{capacity}% "; on-click = "${getExe rmenu} -r powermenu --single-click true"; - states = { critical = 15; warning = 30; }; + states = { + critical = 15; + warning = 30; + }; }; clock = { format-alt = "{:%d.%m.%Y}"; @@ -41,19 +65,31 @@ in height = 30; idle_inhibitor = { format = "{icon}"; - format-icons = { activated = ""; deactivated = ""; }; + format-icons = { + activated = ""; + deactivated = ""; + }; }; keyboard-state = { capslock = true; format = "{name} {icon}"; - format-icons = { locked = ""; unlocked = ""; }; + format-icons = { + locked = ""; + unlocked = ""; + }; numlock = true; }; - memory = { format = "{}% "; }; + memory = { + format = "{}% "; + }; modules-center = [ # "wlr/taskbar" ]; - modules-left = [ "sway/workspaces" "sway/mode" "sway/scratchpad" ]; + modules-left = [ + "sway/workspaces" + "sway/mode" + "sway/scratchpad" + ]; modules-right = [ "custom/media" "idle_inhibitor" @@ -84,7 +120,11 @@ in format-bluetooth-muted = "{icon} {format_source}"; format-icons = { car = ""; - default = [ "" "" "" ]; + default = [ + "" + "" + "" + ]; hands-free = ""; headphone = ""; headset = ""; @@ -98,10 +138,15 @@ in on-click = "${getExe pwvucontrol}"; }; spacing = 4; - "sway/mode" = { format = "{}"; }; + "sway/mode" = { + format = "{}"; + }; "sway/scratchpad" = { format = "{icon} {count}"; - format-icons = [ "" "" ]; + format-icons = [ + "" + "" + ]; show-empty = false; tooltip = true; tooltip-format = "{app}: {title}"; @@ -109,16 +154,24 @@ in temperature = { critical-threshold = 80; format = "{temperatureC}°C {icon}"; - format-icons = [ "" "" "" ]; + format-icons = [ + "" + "" + "" + ]; + }; + tray = { + spacing = 10; }; - tray = { spacing = 10; }; "wlr/taskbar" = { format = "{icon}"; icon-size = 14; ignore-list = [ ]; on-click = "activate"; on-click-middle = "close"; - rewrite = { "Firefox Web Browser" = "Firefox"; }; + rewrite = { + "Firefox Web Browser" = "Firefox"; + }; tooltip-format = "{title}"; }; }; diff --git a/sway/default.nix b/sway/default.nix index 7b2ea7d..caf1ae1 100644 --- a/sway/default.nix +++ b/sway/default.nix @@ -1,16 +1,24 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let - searchclip = let inherit (lib) getExe; in 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 - ''; + searchclip = + let + inherit (lib) getExe; + in + 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 { - imports = [ - ./bar - ]; + imports = [ ./bar ]; environment.systemPackages = with pkgs; [ rmenu @@ -28,213 +36,214 @@ in grimmShared.sway = { enable = true; - config = with pkgs; let - inherit (lib) getExe; - in - { - definitions = { - mod = "Mod4"; - left = "h"; - down = "j"; - up = "k"; - right = "l"; - menu = "${getExe rmenu} -r drun | xargs swaymsg exec --"; - menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --"; + config = + with pkgs; + let + inherit (lib) getExe; + in + { + definitions = { + mod = "Mod4"; + left = "h"; + down = "j"; + up = "k"; + right = "l"; + menu = "${getExe rmenu} -r drun | xargs swaymsg exec --"; + menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --"; - primecol = "#8800FF"; - accentcol = "#5700a0"; - splitcol = "#69507f"; - actsplitcol = "#cd97fc"; - darkcol = "#202020"; - urgentcol = "#9e3c3c"; - realwhite = "#C7D3E3"; + primecol = "#8800FF"; + accentcol = "#5700a0"; + splitcol = "#69507f"; + actsplitcol = "#cd97fc"; + darkcol = "#202020"; + urgentcol = "#9e3c3c"; + 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\""; - }; - }; }; } - diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..0d8323d --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,4 @@ +[formatter.nix] +command = "nixfmt" +includes = ["*.nix"] +excludes = ["tests/**"]