clean up some scopes

This commit is contained in:
Grimmauld 2024-05-11 22:55:59 +02:00
parent 95d2252b1e
commit fad8e51f94
Signed by: Grimmauld
GPG key ID: C2946668769F91FB
54 changed files with 1281 additions and 1296 deletions

View file

@ -5,10 +5,17 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (lib)
sync_mod = types
with lib; mkOption
types.submodule ( concatStrings
mkIf
mkEnableOption
;
inherit (config.grimmShared) enable cloudSync;
inherit (pkgs) nextcloud-client writeShellScriptBin;
sync_mod = types.submodule (
{ config, ... }: { config, ... }:
{ {
options = { options = {
@ -27,15 +34,13 @@ let
); );
in in
{ {
config = config = mkIf (enable && cloudSync.enable) (
with cfg;
lib.mkIf (enable && cloudSync.enable) (
let let
cloud_cmd = ''${pkgs.nextcloud-client}/bin/nextcloudcmd -u ${config.grimmShared.cloudSync.username} -p "$(cat ${config.grimmShared.cloudSync.passwordFile})" -h -n --path''; cloud_cmd = ''${nextcloud-client}/bin/nextcloudcmd -u ${cloudSync.username} -p "$(cat ${cloudSync.passwordFile})" -h -n --path'';
sync_server = "https://${config.grimmShared.cloudSync.server}"; sync_server = "https://${cloudSync.server}";
in in
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = [
(writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server)) (writeShellScriptBin "cloudsync-cmd" (cloud_cmd + " $@ " + sync_server))
nextcloud-client nextcloud-client
]; ];
@ -99,9 +104,7 @@ in
} }
); );
options.users.users = options.users.users = mkOption {
with lib;
mkOption {
type = types.attrsOf ( type = types.attrsOf (
types.submodule { types.submodule {
options = { options = {
@ -115,7 +118,7 @@ in
); );
}; };
options.grimmShared.cloudSync = with lib; { options.grimmShared.cloudSync = {
enable = mkEnableOption "cloud_sync"; enable = mkEnableOption "cloud_sync";
username = mkOption { username = mkOption {

View file

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

View file

@ -5,42 +5,51 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared)
enable
firefox
tooling
locale
sway
;
inherit (lib)
mkIf
optionals
mapAttrs
optionalAttrs
;
in in
{ {
config = config = mkIf (enable && firefox.enable) {
with cfg;
lib.mkIf (enable && firefox.enable) {
environment.systemPackages = environment.systemPackages =
[ ] [ ]
++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ]; ++ optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ];
programs.firefox = { programs.firefox = {
package = pkgs.firefox-beta; package = pkgs.firefox-beta;
enable = true; enable = true;
nativeMessagingHosts.packages = nativeMessagingHosts.packages =
[ ] [ ]
++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ]; ++ lib.optionals (tooling.enable && tooling.pass) [ pkgs.passff-host ];
languagePacks = lib.optionals cfg.locale [ languagePacks = optionals locale [
"de" "de"
"en-US" "en-US"
]; ];
policies = { policies = {
ExtensionSettings = lib.mkMerge [ ExtensionSettings =
(lib.mkIf cfg.firefox.disableUserPlugins { "*".installation_mode = "blocked"; }) (mkIf firefox.disableUserPlugins { "*".installation_mode = "blocked"; })
(lib.mapAttrs (guid: shortId: { // (mapAttrs (guid: shortId: {
# explicit plugins by config # explicit plugins by config
install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi";
installation_mode = "force_installed"; installation_mode = "force_installed";
}) cfg.firefox.plugins) }) firefox.plugins)
(lib.mkIf (cfg.tooling.enable && cfg.tooling.pass) { // (mkIf (tooling.enable && tooling.pass) {
# password-store support # password-store support
"passff@invicem.pro" = { "passff@invicem.pro" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/passff/latest.xpi"; install_url = "https://addons.mozilla.org/firefox/downloads/latest/passff/latest.xpi";
installation_mode = "force_installed"; installation_mode = "force_installed";
}; };
}) });
];
DisableTelemetry = true; DisableTelemetry = true;
DisableFirefoxStudies = true; DisableFirefoxStudies = true;
EnableTrackingProtection = { EnableTrackingProtection = {
@ -63,7 +72,7 @@ in
"media.ffmpeg.vaapi.enabled" = true; "media.ffmpeg.vaapi.enabled" = true;
"media.rdd-ffmpeg.enabled" = true; "media.rdd-ffmpeg.enabled" = true;
"media.navigator.mediadatadecoder_vpx_enabled" = true; "media.navigator.mediadatadecoder_vpx_enabled" = true;
} // lib.optionalAttrs cfg.sway.enable { "browser.tabs.inTitlebar" = 0; }; } // optionalAttrs sway.enable { "browser.tabs.inTitlebar" = 0; };
}; };
}; };
}; };
@ -77,6 +86,6 @@ in
description = "set of plugins to install. Format: guid = short-id"; description = "set of plugins to install. Format: guid = short-id";
}; };
disableUserPlugins = lib.mkEnableOption "disables user controlled plugins"; disableUserPlugins = mkEnableOption "disables user controlled plugins";
}; };
} }

View file

@ -5,12 +5,11 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable gaming;
inherit (lib) mkIf getExe mkEnableOption;
in in
{ {
config = config = mkIf (enable && gaming) {
with cfg;
lib.mkIf (enable && gaming) {
programs.steam = { programs.steam = {
enable = true; enable = true;
gamescopeSession.enable = true; gamescopeSession.enable = true;
@ -46,17 +45,17 @@ in
prismlauncher prismlauncher
mangohud mangohud
the-powder-toy the-powder-toy
(pkgs.symlinkJoin { (symlinkJoin {
name = "osu"; name = "osu";
paths = [ paths = [
(pkgs.writeShellScriptBin "osu!" '' (writeShellScriptBin "osu!" ''
exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin} exec gamemoderun ${getExe osu-lazer-bin}
'') '')
pkgs.osu-lazer-bin osu-lazer-bin
]; ];
}) })
]; ];
}; };
options.grimmShared.gaming = lib.mkEnableOption "enables steam, heroic, prism and gamemoded"; options.grimmShared.gaming = mkEnableOption "enables steam, heroic, prism and gamemoded";
} }

View file

@ -4,10 +4,11 @@
config, config,
... ...
}: }:
let
inherit (config.grimmShared) enable graphical;
in
{ {
config = config = lib.mkIf (enable && graphical) {
with config.grimmShared;
lib.mkIf (enable && graphical) {
fonts = { fonts = {
packages = with pkgs; [ packages = with pkgs; [
noto-fonts noto-fonts

View file

@ -5,10 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable graphical screens;
screen = inherit (lib) types mkOption mkIf;
with lib;
types.submodule { screen = types.submodule {
options = { options = {
fps = mkOption { fps = mkOption {
type = types.either types.int (types.nonEmptyListOf types.int); type = types.either types.int (types.nonEmptyListOf types.int);
@ -37,15 +37,13 @@ let
}; };
in in
{ {
config = config = mkIf (enable && graphical) {
with cfg;
lib.mkIf (enable && graphical) {
# Enable OpenGL # Enable OpenGL
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
driSupport = true; driSupport = true;
driSupport32Bit = true; driSupport32Bit = true;
extraPackages = with pkgs; [ ]; extraPackages = [ ];
}; };
chaotic.mesa-git.enable = true; chaotic.mesa-git.enable = true;
@ -69,10 +67,10 @@ in
]; ];
}; };
options.grimmShared = with lib; { options.grimmShared = {
graphical = mkOption { graphical = mkOption {
type = types.bool; type = types.bool;
default = cfg.screens != { }; default = screens != { };
description = "whether to force enable graphical components"; description = "whether to force enable graphical components";
}; };

View file

@ -5,12 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable graphical sway;
in in
{ {
config = config = lib.mkIf (enable && graphical) {
with cfg;
lib.mkIf (enable && graphical) {
qt = { qt = {
enable = true; enable = true;
style = "kvantum"; style = "kvantum";
@ -43,7 +41,7 @@ in
wayland.enable = true; wayland.enable = true;
wayland.compositor = "weston"; wayland.compositor = "weston";
}; };
defaultSession = lib.optionalString cfg.sway.enable "sway"; defaultSession = lib.optionalString sway.enable "sway";
}; };
boot.plymouth = { boot.plymouth = {

View file

@ -5,12 +5,30 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable sway screens;
sway_conf = inherit (lib)
with lib; types
types.submodule ( mkOption
{ config, ... }: mkEnableOption
rec { mapAttrsToList
optionalString
concatMapStrings
isInt
min
max
foldl'
getExe
isPath
isDerivation
concatLines
optional
mkIf
;
inherit (pkgs) writeShellScriptBin;
sway_conf = types.submodule (
{ ... }:
{
options = { options = {
keybinds = mkOption { keybinds = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
@ -53,13 +71,12 @@ let
build_screen_def = build_screen_def =
fps_func: fps_func:
with lib;
let let
output_def = mapAttrsToList ( output_def = mapAttrsToList (
name: value: name: value:
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz" "output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
+ (optionalString (value.pos != null) " position ${value.pos}") + (optionalString (value.pos != null) " position ${value.pos}")
) cfg.screens; ) screens;
in in
'' ''
for pid in $(${pkgs.procps}/bin/pgrep sway -x) for pid in $(${pkgs.procps}/bin/pgrep sway -x)
@ -72,30 +89,25 @@ let
fi fi
done done
''; '';
inherit (lib) getExe;
fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps); fps_min = fps: if isInt fps then fps else (foldl' min 2147483647 fps);
fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps); fps_max = fps: if isInt fps then fps else (foldl' max 0 fps);
init_screens_min_fps = init_screens_min_fps = writeShellScriptBin "init-screens-min" (build_screen_def fps_min);
with lib; init_screens_max_fps = writeShellScriptBin "init-screens-max" (build_screen_def fps_max);
pkgs.writeShellScriptBin "init-screens-min" (build_screen_def fps_min); init_screens_auto = writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}";
init_screens_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 in
{ {
config = config =
let let
bar_conf_file = bar_conf_file =
if (lib.isPath cfg.sway.bar.config) then if (isPath sway.bar.config) then
cfg.sway.bar.config sway.bar.config
else else
pkgs.writers.writeJSON "config.json" cfg.sway.bar.config; pkgs.writers.writeJSON "config.json" sway.bar.config;
waybar_full = pkgs.writeShellScriptBin "waybar-full" ( waybar_full = writeShellScriptBin "waybar-full" (
(lib.getExe config.programs.waybar.package) (getExe config.programs.waybar.package)
+ (lib.optionalString (!isNull cfg.sway.bar.config) " -c ${bar_conf_file}") + (optionalString (!isNull sway.bar.config) " -c ${bar_conf_file}")
+ (lib.optionalString (!isNull cfg.sway.bar.style) " -s ${cfg.sway.bar.style}") + (optionalString (!isNull sway.bar.style) " -s ${sway.bar.style}")
); );
bar_config = '' bar_config = ''
@ -111,7 +123,6 @@ in
''; '';
build_conf = build_conf =
with lib;
sway_conf: sway_conf:
let let
build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}"); build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}");
@ -133,20 +144,19 @@ in
++ optional (sway_conf.extraConfig != "") sway_conf.extraConfig ++ optional (sway_conf.extraConfig != "") sway_conf.extraConfig
); );
sway_conf = lib.concatLines ( sway_conf = concatLines (
(build_conf cfg.sway.config) (build_conf sway.config)
++ lib.optional cfg.sway.bar.enable bar_config ++ optional sway.bar.enable bar_config
++ (lib.mapAttrsToList ( ++ (mapAttrsToList (
name: value: name: value:
"output ${value.id} mode ${value.mode}" "output ${value.id} mode ${value.mode}"
+ (lib.optionalString (value.pos != null) " position ${value.pos}") + (optionalString (value.pos != null) " position ${value.pos}")
) cfg.screens) ) screens)
); );
conf_path = "sway.conf"; conf_path = "sway.conf";
in in
with cfg; mkIf (enable && sway.enable) {
lib.mkIf (enable && sway.enable) {
environment.etc."${conf_path}".text = sway_conf; environment.etc."${conf_path}".text = sway_conf;
grimmShared.sway.config.execAlways = [ grimmShared.sway.config.execAlways = [
@ -232,7 +242,7 @@ in
}; };
}; };
options.grimmShared.sway = with lib; { options.grimmShared.sway = {
enable = mkEnableOption "grimm-sway"; enable = mkEnableOption "grimm-sway";
bar = { bar = {

View file

@ -5,12 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable laptop_hardware graphical;
in in
{ {
config = config = lib.mkIf (enable && laptop_hardware.enable) {
with cfg;
lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages = environment.systemPackages =
with pkgs; with pkgs;
[ [

View file

@ -6,20 +6,25 @@
... ...
}: }:
let let
cfg = config.grimmShared;
inherit (lib) inherit (lib)
optionals optionals
optional optional
optionalString
concatLines concatLines
getExe getExe
elem
mkIf
;
inherit (pkgs) writeShellScriptBin tlp tlpui;
inherit (config.grimmShared)
enable
laptop_hardware
graphical
sway
; ;
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower; inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms); enable_perf_policy = (elem system x86_energy_perf_policy.meta.platforms);
powersave = powersave = writeShellScriptBin "powersave-mode" (
with pkgs;
writeShellScriptBin "powersave-mode" (
concatLines ( concatLines (
[ [
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed "${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
@ -29,11 +34,11 @@ let
"${getExe x86_energy_perf_policy} 15" # power save preference "${getExe x86_energy_perf_policy} 15" # power save preference
"${getExe x86_energy_perf_policy} --turbo-enable 0" # disable turbo "${getExe x86_energy_perf_policy} --turbo-enable 0" # disable turbo
] ]
++ optional cfg.sway.enable "init-screens-min" ++ optional sway.enable "init-screens-min"
) )
); );
performance = pkgs.writeShellScriptBin "performance-mode" ( performance = writeShellScriptBin "performance-mode" (
concatLines ( concatLines (
[ [
"${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed "${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed
@ -43,28 +48,23 @@ let
"${getExe x86_energy_perf_policy} 0" # performance preference "${getExe x86_energy_perf_policy} 0" # performance preference
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo "${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
] ]
++ optional cfg.sway.enable "init-screens-max" ++ optional sway.enable "init-screens-max"
) )
); );
auto = auto = writeShellScriptBin "auto-mode" ''
let
inherit (pkgs) tlp;
in
pkgs.writeShellScriptBin "auto-mode" ''
${tlp}/bin/run-on-ac ${getExe performance} ${tlp}/bin/run-on-ac ${getExe performance}
${tlp}/bin/run-on-bat ${getExe powersave} ${tlp}/bin/run-on-bat ${getExe powersave}
''; '';
in in
{ {
config = config = mkIf (enable && laptop_hardware.enable) {
with cfg;
lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages = environment.systemPackages =
with pkgs; (with pkgs; [
[
acpi acpi
powertop powertop
brightnessctl brightnessctl
])
++ [
cpupower cpupower
powersave powersave
performance performance

View file

@ -1,11 +1,9 @@
{ config, lib, ... }: { config, lib, ... }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable locale;
in in
{ {
config = config = lib.mkIf (enable && locale) {
with cfg;
lib.mkIf (enable && locale) {
time.timeZone = "Europe/Berlin"; time.timeZone = "Europe/Berlin";
# Select internationalisation properties. # Select internationalisation properties.

View file

@ -5,15 +5,18 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared)
enable
network
graphical
sound
;
in in
{ {
config = config = lib.mkIf (enable && network && config.hardware.bluetooth.enable) {
with cfg;
lib.mkIf (enable && network && config.hardware.bluetooth.enable) {
services.blueman.enable = lib.mkIf graphical true; services.blueman.enable = lib.mkIf graphical true;
environment.systemPackages = with pkgs; [ bluetuith ] ++ lib.optional sound.enable pkgs.bluez; environment.systemPackages = [ pkgs.bluetuith ] ++ lib.optional sound.enable pkgs.bluez;
systemd.user.services.mpris-proxy = lib.mkIf sound.enable { systemd.user.services.mpris-proxy = lib.mkIf sound.enable {
description = "Mpris proxy"; description = "Mpris proxy";

View file

@ -5,12 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable network laptop_hardware;
in in
{ {
config = config = lib.mkIf (enable && network) {
with cfg;
lib.mkIf (enable && network) {
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;

View file

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

View file

@ -5,12 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable sound;
in in
{ {
config = config = lib.mkIf (enable && sound.enable) {
with cfg;
lib.mkIf (enable && sound.enable) {
sound.enable = true; sound.enable = true;
hardware.pulseaudio.enable = false; hardware.pulseaudio.enable = false;

View file

@ -5,19 +5,18 @@
... ...
}: }:
let let
cfg = config.grimmShared;
sound_font = pkgs.soundfont-fluid; sound_font = pkgs.soundfont-fluid;
inherit (config.grimmShared) enable sound;
in in
{ {
config = config = lib.mkIf (enable && sound.midi) {
with cfg; environment.systemPackages =
lib.mkIf (enable && sound.midi) { (with pkgs; [
environment.systemPackages = with pkgs; [
mpv mpv
timidity timidity
ffmpeg-full ffmpeg-full
sound_font ])
]; ++ [ sound_font ];
environment.pathsToLink = [ "/share/soundfonts" ]; environment.pathsToLink = [ "/share/soundfonts" ];

View file

@ -5,12 +5,10 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable spotify graphical;
in in
{ {
config = config = lib.mkIf (enable && spotify.enable) {
with cfg;
lib.mkIf (enable && spotify.enable) {
environment.systemPackages = [ pkgs.ncspot ] ++ lib.optional graphical pkgs.spotify; environment.systemPackages = [ pkgs.ncspot ] ++ lib.optional graphical pkgs.spotify;
grimmShared = { grimmShared = {

View file

@ -6,7 +6,7 @@
}: }:
let let
spotifyd_cache_dir = "/tmp/spotifyd"; spotifyd_cache_dir = "/tmp/spotifyd";
cfg = config.grimmShared; inherit (config.grimmShared) enable spotify;
spotifyd-dbus = pkgs.writeTextDir "share/dbus-1/system.d/org.mpris.MediaPlayer2.spotifyd.conf" '' spotifyd-dbus = pkgs.writeTextDir "share/dbus-1/system.d/org.mpris.MediaPlayer2.spotifyd.conf" ''
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- --> <?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
@ -27,11 +27,9 @@ let
''; '';
in in
{ {
config = config = lib.mkIf (enable && spotify.spotifyd.enable) {
with cfg; environment.systemPackages = [
lib.mkIf (enable && spotify.spotifyd.enable) { pkgs.spotifyd
environment.systemPackages = with pkgs; [
spotifyd
spotifyd-dbus spotifyd-dbus
]; ];
@ -58,17 +56,14 @@ in
enable = true; enable = true;
settings.global = { settings.global = {
bitrate = 320; bitrate = 320;
username = cfg.spotify.spotifyd.username; username = spotify.spotifyd.username;
device_name = "grimm_laptop"; device_name = "grimm_laptop";
password_cmd = password_cmd =
let let
pass = cfg.spotify.spotifyd.pass; pass = spotify.spotifyd.pass;
inherit (lib) isPath isString getExe;
in in
with lib; if (isPath pass || isString pass) then "${pkgs.coreutils-full}/bin/cat ${pass}" else (getExe pass);
if (lib.isPath pass || lib.isString pass) then
"${pkgs.coreutils-full}/bin/cat ${pass}"
else
(getExe pass);
device_type = "computer"; device_type = "computer";
dbus_type = "system"; dbus_type = "system";
device = "default"; device = "default";
@ -82,7 +77,7 @@ in
}; };
}; };
services.dbus.packages = with pkgs; [ spotifyd-dbus ]; services.dbus.packages = [ spotifyd-dbus ];
# spotifyd has access to global pipewire # spotifyd has access to global pipewire
users.users.spotifyd = { users.users.spotifyd = {

View file

@ -5,7 +5,16 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
mkEnableOption
mkOption
types
getExe
optionals
mkIf
concatLines
;
in in
{ {
imports = [ imports = [
@ -15,14 +24,12 @@ in
./python.nix ./python.nix
]; ];
config = config = mkIf (enable && tooling.enable) {
with cfg;
lib.mkIf (enable && tooling.enable) {
environment.systemPackages = environment.systemPackages =
with pkgs; with pkgs;
[ [
(writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@") (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 "tree" "${getExe eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time")
(writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'') (writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'')
(writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@") (writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@")
@ -60,7 +67,7 @@ in
glibc glibc
expect expect
] ]
++ lib.optionals cfg.graphical [ ++ optionals graphical [
wev wev
qdirstat qdirstat
libva-utils libva-utils
@ -74,10 +81,10 @@ in
lfs.enable = true; lfs.enable = true;
config = { config = {
init.defaultBranch = "main"; init.defaultBranch = "main";
credential.username = cfg.tooling.git_user; credential.username = tooling.git_user;
core.editor = lib.getExe pkgs.neovim; core.editor = getExe pkgs.neovim;
user.name = cfg.tooling.git_user; user.name = tooling.git_user;
user.email = cfg.tooling.git_email; user.email = tooling.git_email;
push.autoSetupRemote = true; push.autoSetupRemote = true;
core.autocrlf = "input"; core.autocrlf = "input";
commit.gpgsign = true; commit.gpgsign = true;
@ -123,7 +130,7 @@ in
configure = { configure = {
customRC = customRC =
let let
luarc = pkgs.writeText "init.lua" (lib.concatLines tooling.nvim.extraLuaRC); luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in in
'' ''
set number set number
@ -149,12 +156,12 @@ in
programs.ssh = { programs.ssh = {
startAgent = true; startAgent = true;
enableAskPassword = graphical; enableAskPassword = graphical;
askPassword = lib.mkIf graphical (lib.getExe pkgs.lxqt.lxqt-openssh-askpass); askPassword = mkIf graphical (getExe pkgs.lxqt.lxqt-openssh-askpass);
}; };
programs.thefuck.enable = true; programs.thefuck.enable = true;
}; };
options.grimmShared.tooling = with lib; { options.grimmShared.tooling = {
enable = mkEnableOption "grimm-tooling"; enable = mkEnableOption "grimm-tooling";
nvim = { nvim = {

View file

@ -5,19 +5,23 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
getExe
optional
mkIf
optionalString
mkEnableOption
;
viewer_pkg = pkgs.zathura; viewer_pkg = pkgs.zathura;
viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",''; viewer_def = optionalString graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",'';
in in
{ {
config = config = mkIf (enable && tooling.enable && tooling.lilypond) {
with cfg; environment.systemPackages = [ pkgs.lilypond-with-fonts ] ++ optional graphical viewer_pkg;
lib.mkIf (enable && tooling.enable && tooling.lilypond) {
environment.systemPackages =
with pkgs;
[ lilypond-with-fonts ] ++ lib.optional graphical viewer_pkg;
environment.sessionVariables = { environment.sessionVariables = {
LYEDITOR = "${lib.getExe pkgs.neovim-remote} -s +:'dr %(file)s | call cursor(%(line)s,%(char)s+1)'"; LYEDITOR = "${getExe pkgs.neovim-remote} -s +:'dr %(file)s | call cursor(%(line)s,%(char)s+1)'";
}; };
grimmShared.sound.midi = true; grimmShared.sound.midi = true;
@ -49,5 +53,5 @@ in
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ nvim-lilypond-suite ]; grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ nvim-lilypond-suite ];
}; };
options.grimmShared.tooling.lilypond = lib.mkEnableOption "enable lilypond tooling"; options.grimmShared.tooling.lilypond = mkEnableOption "enable lilypond tooling";
} }

View file

@ -1,13 +1,4 @@
{ { pkgs, lib, ... }:
pkgs,
config,
lib,
inputs,
...
}:
let
cfg = config.grimmShared;
in
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@") (writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@")
@ -43,6 +34,7 @@ in
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 30d"; options = "--delete-older-than 30d";
}; };
# nix.package = pkgs.nixVersions.latest; # nix.package = pkgs.nixVersions.latest;
nix.optimise.automatic = true; nix.optimise.automatic = true;
} }

View file

@ -5,26 +5,21 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable tooling graphical;
in pyLibs =
{
config =
with cfg;
lib.mkIf (enable && tooling.enable) {
environment.systemPackages =
with pkgs;
[
(python3.withPackages (
python-pkgs: with python-pkgs; [ python-pkgs: with python-pkgs; [
requests requests
matplotlib matplotlib
numpy numpy
scipy scipy
pygobject3 pygobject3
] ];
)) in
] {
++ lib.optionals cfg.graphical [ jetbrains.pycharm-community ]; config = lib.mkIf (enable && tooling.enable) {
environment.systemPackages = [
(pkgs.python3.withPackages pyLibs)
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
programs.xonsh = { programs.xonsh = {
enable = true; enable = true;
@ -33,16 +28,7 @@ in
name: value: ''aliases["${name}"] = "${value}"'' name: value: ''aliases["${name}"] = "${value}"''
) config.environment.shellAliases ) config.environment.shellAliases
); );
package = pkgs.xonsh.wrapper.override { package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
extraPackages =
ps: with ps; [
requests
matplotlib
numpy
scipy
pygobject3
];
};
}; };
}; };
} }

View file

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

View file

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared) enable portals graphical;
browsers = [ browsers = [
"firefox-beta.desktop" "firefox-beta.desktop"
"firefox.desktop" "firefox.desktop"
@ -35,9 +35,7 @@ let
tex_editors = [ ] ++ text_editors; tex_editors = [ ] ++ text_editors;
in in
{ {
config = config = lib.mkIf (enable && portals && graphical) {
with cfg;
lib.mkIf (enable && portals && graphical) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
deskwhich deskwhich

View file

@ -5,12 +5,25 @@
... ...
}: }:
let let
cfg = config.grimmShared; inherit (config.grimmShared)
enable
portals
sound
screens
;
inherit (lib)
mkIf
mkEnableOption
mapAttrs'
foldl'
min
getExe
isInt
nameValuePair
;
in in
{ {
config = config = mkIf (enable && portals) {
with cfg;
lib.mkIf (enable && portals) {
xdg.icons.enable = true; xdg.icons.enable = true;
xdg.sounds.enable = lib.mkIf sound.enable true; xdg.sounds.enable = lib.mkIf sound.enable true;
@ -24,9 +37,7 @@ in
]; ];
wlr.enable = true; wlr.enable = true;
wlr.settings = wlr.settings = mapAttrs' (
with lib;
mapAttrs' (
name: value: name: value:
nameValuePair ("screencast_" + name) { nameValuePair ("screencast_" + name) {
output_name = value.id; output_name = value.id;
@ -34,7 +45,7 @@ in
chooser_type = "simple"; chooser_type = "simple";
chooser_cmd = "${getExe pkgs.slurp} -f %o -or"; chooser_cmd = "${getExe pkgs.slurp} -f %o -or";
} }
) cfg.screens; ) screens;
}; };
environment.sessionVariables = { environment.sessionVariables = {
@ -44,5 +55,5 @@ in
environment.systemPackages = with pkgs; [ xwaylandvideobridge ]; environment.systemPackages = with pkgs; [ xwaylandvideobridge ];
}; };
options.grimmShared.portals = lib.mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts"; options.grimmShared.portals = mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts";
} }

View file

@ -1,9 +1,4 @@
{ { lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
{ {
imports = [ imports = [
./overlays ./overlays

View file

@ -3,7 +3,7 @@
lib, lib,
rustPlatform, rustPlatform,
}: }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage {
pname = "deskwhich"; pname = "deskwhich";
version = "unstable-2024-04-30"; version = "unstable-2024-04-30";

View file

@ -0,0 +1,16 @@
{
writeShellScriptBin,
lib,
urlencode,
}:
let
inherit (lib) getExe;
in
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//")
if [[ -v SWAYSOCK ]]; then
sleep .1
swaymsg [app_id="$browser" urgent="newest"] focus
fi
''

View file

@ -1,5 +1,4 @@
{ {
cairo,
fetchFromGitHub, fetchFromGitHub,
gobject-introspection, gobject-introspection,
gtk3, gtk3,

View file

@ -56,7 +56,11 @@ in
distroName = "LixOS"; distroName = "LixOS";
}; };
environment.sessionVariables = with config.system.nixos; { environment.sessionVariables =
let
inherit (config.system.nixos) distroName version codeName;
in
{
distro = "${distroName} ${version} (${codeName}) ${system}"; distro = "${distroName} ${version} (${codeName}) ${system}";
}; };
@ -66,15 +70,23 @@ in
programs.ccache.enable = true; programs.ccache.enable = true;
environment.systemPackages = environment.systemPackages =
with pkgs; let
with lib; inherit (lib)
getExe
attrNames
optionalString
elem
concatLines
;
inherit (pkgs) writeShellScriptBin nix-output-monitor;
in
[ [
(writeShellScriptBin "nixos-build-all" ( (writeShellScriptBin "nixos-build-all" (
concatLines ( concatLines (
map ( map (
n: n:
"NIXOS_TARGET_HOST=${n} nixos-rebuild build --show-trace --upgrade" "NIXOS_TARGET_HOST=${n} nixos-rebuild build --show-trace --upgrade"
+ optionalString (elem nix-output-monitor config.environment.systemPackages) " |& ${lib.getExe pkgs.nix-output-monitor}" + optionalString (elem nix-output-monitor config.environment.systemPackages) " |& ${getExe nix-output-monitor}"
) (attrNames host_modules) ) (attrNames host_modules)
) )
)) ))

View file

@ -1,6 +1,6 @@
{ config, ... }: { config, ... }:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) vhosts;
inherit (config.networking) domain; inherit (config.networking) domain;
in in
{ {

View file

@ -1,10 +1,4 @@
{ { lib, config, ... }:
lib,
config,
inputs,
pkgs,
...
}:
let let
inherit (config.networking) domain; inherit (config.networking) domain;
root_email = "contact@${domain}"; root_email = "contact@${domain}";
@ -25,12 +19,16 @@ in
./nix_cache.nix ./nix_cache.nix
]; ];
options.serverConfig = with lib; { options.serverConfig =
let
inherit (lib) mkOption types mkEnableOption;
in
{
ports = mkOption { ports = mkOption {
type = types.attrsOf ( type = types.attrsOf (
types.submodule ( types.submodule (
{ config, ... }: { ... }:
rec { {
options = { options = {
port = mkOption { port = mkOption {
type = types.int; type = types.int;

View file

@ -1,11 +1,6 @@
{ { config, pkgs, ... }:
config,
lib,
pkgs,
...
}:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) ports;
in in
{ {
age.secrets.matrix_discord_bridge_token.file = ../secrets/matrix_discord_bridge_token.age; age.secrets.matrix_discord_bridge_token.file = ../secrets/matrix_discord_bridge_token.age;

View file

@ -1,6 +1,6 @@
{ config, ... }: { config, ... }:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) vhosts;
inherit (config.networking) domain; inherit (config.networking) domain;
in in
{ {

View file

@ -1,10 +1,4 @@
{ { config, pkgs, ... }:
lib,
config,
inputs,
pkgs,
...
}:
let let
inherit (config.networking) domain; inherit (config.networking) domain;
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) ports vhosts;

View file

@ -1,6 +1,6 @@
{ config, ... }: { config, ... }:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) vhosts;
inherit (config.networking) domain; inherit (config.networking) domain;
in in
{ {

View file

@ -1,13 +1,12 @@
{ {
lib, lib,
config, config,
inputs,
pkgs, pkgs,
... ...
}: }:
let let
inherit (config.networking) domain; inherit (config.networking) domain;
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) vhosts;
in in
{ {
services.postgresql = { services.postgresql = {

View file

@ -1,4 +1,4 @@
{ config, ... }: { ... }:
let let
in in
{ {

View file

@ -1,9 +1,4 @@
{ { pkgs, config, ... }:
lib,
pkgs,
config,
...
}:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) ports vhosts;
in in

View file

@ -1,12 +1,6 @@
{ { config, ... }:
lib,
config,
inputs,
pkgs,
...
}:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) vhosts;
in in
{ {
services.harmonia = { services.harmonia = {

View file

@ -13,7 +13,14 @@ in
static_configs = [ static_configs = [
{ {
targets = targets =
with lib; let
inherit (lib)
toString
filter
isAttrs
attrValues
;
in
map (v: "127.0.0.1:${toString v.port}") ( map (v: "127.0.0.1:${toString v.port}") (
filter (v: (isAttrs v) && v.enable) (attrValues config.services.prometheus.exporters) filter (v: (isAttrs v) && v.enable) (attrValues config.services.prometheus.exporters)
); );

View file

@ -1,10 +1,4 @@
{ { config, pkgs, ... }:
lib,
config,
inputs,
pkgs,
...
}:
let let
inherit (config.serverConfig) ports vhosts; inherit (config.serverConfig) ports vhosts;
in in
@ -15,7 +9,6 @@ in
PUFFER_WEB_HOST = ":${builtins.toString vhosts.puffer_host.port}"; PUFFER_WEB_HOST = ":${builtins.toString vhosts.puffer_host.port}";
PUFFER_DAEMON_SFTP_HOST = ":${builtins.toString ports.puffer_sftp_port.port}"; PUFFER_DAEMON_SFTP_HOST = ":${builtins.toString ports.puffer_sftp_port.port}";
}; };
extraPackages = with pkgs; [ ];
extraGroups = [ "docker" ]; extraGroups = [ "docker" ];
}; };

View file

@ -1,9 +1,4 @@
{ { prev, config, ... }:
final,
prev,
config,
...
}:
{ {
ccacheWrapper = prev.ccacheWrapper.override { ccacheWrapper = prev.ccacheWrapper.override {
extraConfig = '' extraConfig = ''

View file

@ -27,5 +27,6 @@
./tlpui.nix ./tlpui.nix
./mcontrolcenter.nix ./mcontrolcenter.nix
./ccache-wrapper.nix ./ccache-wrapper.nix
./searchclip.nix
]; ];
} }

View file

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

View file

@ -1,4 +1,4 @@
{ final, prev, ... }: { prev, ... }:
{ {
matrix-appservice-discord = prev.matrix-appservice-discord.overrideAttrs (old: { matrix-appservice-discord = prev.matrix-appservice-discord.overrideAttrs (old: {
src = prev.fetchFromGitHub { src = prev.fetchFromGitHub {

View file

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

4
overlays/searchclip.nix Normal file
View file

@ -0,0 +1,4 @@
{ prev, ... }:
{
searchclip = prev.callPackage ../custom/searchclip/package.nix { };
}

View file

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

View file

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

View file

@ -1,13 +1,4 @@
{ { lib, ... }:
lib,
config,
inputs,
pkgs,
...
}:
let
inherit (config.networking) domain;
in
{ {
imports = [ ./hardware-configuration.nix ]; imports = [ ./hardware-configuration.nix ];

View file

@ -1,16 +1,18 @@
{ { lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
let let
inherit (lib) getExe; inherit (lib) getExe;
inherit (pkgs)
rmenu
btop
xdg-terminal-exec
waybar-mpris
pwvucontrol
;
in in
{ {
grimmShared.sway.bar = { grimmShared.sway.bar = {
enable = true; enable = true;
config = with pkgs; { config = {
backlight = { backlight = {
format = "{percent}%"; format = "{percent}%";
format-icons = [ format-icons = [

View file

@ -1,22 +1,4 @@
{ { pkgs, 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
'';
in
{ {
imports = [ ./bar ]; imports = [ ./bar ];
@ -37,9 +19,19 @@ in
grimmShared.sway = { grimmShared.sway = {
enable = true; enable = true;
config = config =
with pkgs;
let let
inherit (lib) getExe; inherit (lib) getExe;
inherit (pkgs)
rmenu
xdg-terminal-exec
slurp
swaymux
grim
brightnessctl
searchclip
ranger
deskwhich
;
in in
{ {
definitions = { definitions = {

View file

@ -35,15 +35,16 @@
{ remote = "Videos"; } { remote = "Videos"; }
]; ];
packages = packages = lib.optionals config.grimmShared.graphical (
with pkgs; with pkgs;
lib.optionals config.grimmShared.graphical [ [
webcord webcord
discord discord
obs-studio obs-studio
element-desktop element-desktop
ghidra ghidra
# rmview # rmview
]; ]
);
}; };
} }