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

View file

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

View file

@ -5,42 +5,51 @@
...
}:
let
cfg = config.grimmShared;
inherit (config.grimmShared)
enable
firefox
tooling
locale
sway
;
inherit (lib)
mkIf
optionals
mapAttrs
optionalAttrs
;
in
{
config =
with cfg;
lib.mkIf (enable && firefox.enable) {
config = mkIf (enable && firefox.enable) {
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 = {
package = pkgs.firefox-beta;
enable = true;
nativeMessagingHosts.packages =
[ ]
++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ];
languagePacks = lib.optionals cfg.locale [
++ lib.optionals (tooling.enable && tooling.pass) [ pkgs.passff-host ];
languagePacks = optionals locale [
"de"
"en-US"
];
policies = {
ExtensionSettings = lib.mkMerge [
(lib.mkIf cfg.firefox.disableUserPlugins { "*".installation_mode = "blocked"; })
(lib.mapAttrs (guid: shortId: {
ExtensionSettings =
(mkIf firefox.disableUserPlugins { "*".installation_mode = "blocked"; })
// (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) {
}) firefox.plugins)
// (mkIf (tooling.enable && 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 = {
@ -63,7 +72,7 @@ in
"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; };
} // optionalAttrs sway.enable { "browser.tabs.inTitlebar" = 0; };
};
};
};
@ -77,6 +86,6 @@ in
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
cfg = config.grimmShared;
inherit (config.grimmShared) enable gaming;
inherit (lib) mkIf getExe mkEnableOption;
in
{
config =
with cfg;
lib.mkIf (enable && gaming) {
config = mkIf (enable && gaming) {
programs.steam = {
enable = true;
gamescopeSession.enable = true;
@ -46,17 +45,17 @@ in
prismlauncher
mangohud
the-powder-toy
(pkgs.symlinkJoin {
(symlinkJoin {
name = "osu";
paths = [
(pkgs.writeShellScriptBin "osu!" ''
exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin}
(writeShellScriptBin "osu!" ''
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,
...
}:
let
inherit (config.grimmShared) enable graphical;
in
{
config =
with config.grimmShared;
lib.mkIf (enable && graphical) {
config = lib.mkIf (enable && graphical) {
fonts = {
packages = with pkgs; [
noto-fonts

View file

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

View file

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

View file

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

View file

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

View file

@ -6,20 +6,25 @@
...
}:
let
cfg = config.grimmShared;
inherit (lib)
optionals
optional
optionalString
concatLines
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;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms);
enable_perf_policy = (elem system x86_energy_perf_policy.meta.platforms);
powersave =
with pkgs;
writeShellScriptBin "powersave-mode" (
powersave = writeShellScriptBin "powersave-mode" (
concatLines (
[
"${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} --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 (
[
"${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} --turbo-enable 1" # enable turbo
]
++ optional cfg.sway.enable "init-screens-max"
++ optional sway.enable "init-screens-max"
)
);
auto =
let
inherit (pkgs) tlp;
in
pkgs.writeShellScriptBin "auto-mode" ''
auto = 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) {
config = mkIf (enable && laptop_hardware.enable) {
environment.systemPackages =
with pkgs;
[
(with pkgs; [
acpi
powertop
brightnessctl
])
++ [
cpupower
powersave
performance

View file

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

View file

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

View file

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

View file

@ -5,12 +5,10 @@
...
}:
let
cfg = config.grimmShared;
inherit (config.grimmShared) enable printing graphical;
in
{
config =
with cfg;
lib.mkIf (enable && printing) {
config = lib.mkIf (enable && printing) {
# Enable CUPS to print documents.
services.printing.enable = true;
services.printing.drivers = with pkgs; [
@ -25,12 +23,12 @@ in
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
environment.systemPackages = (
lib.optionals graphical [
pkgs.kdePackages.skanpage
# libsForQt5.skanpage
]);
]
);
};
options.grimmShared.printing = lib.mkEnableOption "Enables print and scan related options";

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@
}:
let
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" ''
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
@ -27,11 +27,9 @@ let
'';
in
{
config =
with cfg;
lib.mkIf (enable && spotify.spotifyd.enable) {
environment.systemPackages = with pkgs; [
spotifyd
config = lib.mkIf (enable && spotify.spotifyd.enable) {
environment.systemPackages = [
pkgs.spotifyd
spotifyd-dbus
];
@ -58,17 +56,14 @@ in
enable = true;
settings.global = {
bitrate = 320;
username = cfg.spotify.spotifyd.username;
username = spotify.spotifyd.username;
device_name = "grimm_laptop";
password_cmd =
let
pass = cfg.spotify.spotifyd.pass;
pass = spotify.spotifyd.pass;
inherit (lib) isPath isString getExe;
in
with lib;
if (lib.isPath pass || lib.isString pass) then
"${pkgs.coreutils-full}/bin/cat ${pass}"
else
(getExe pass);
if (isPath pass || isString pass) then "${pkgs.coreutils-full}/bin/cat ${pass}" else (getExe pass);
device_type = "computer";
dbus_type = "system";
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
users.users.spotifyd = {

View file

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

View file

@ -5,19 +5,23 @@
...
}:
let
cfg = config.grimmShared;
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
getExe
optional
mkIf
optionalString
mkEnableOption
;
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
{
config =
with cfg;
lib.mkIf (enable && tooling.enable && tooling.lilypond) {
environment.systemPackages =
with pkgs;
[ lilypond-with-fonts ] ++ lib.optional graphical viewer_pkg;
config = mkIf (enable && tooling.enable && tooling.lilypond) {
environment.systemPackages = [ pkgs.lilypond-with-fonts ] ++ optional graphical viewer_pkg;
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;
@ -49,5 +53,5 @@ in
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,
config,
lib,
inputs,
...
}:
let
cfg = config.grimmShared;
in
{ pkgs, lib, ... }:
{
environment.systemPackages = with pkgs; [
(writeShellScriptBin "nix-referrers" "nix-store --query --referrers $@")
@ -43,6 +34,7 @@ in
dates = "weekly";
options = "--delete-older-than 30d";
};
# nix.package = pkgs.nixVersions.latest;
nix.optimise.automatic = true;
}

View file

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

View file

@ -5,12 +5,19 @@
...
}:
let
cfg = config.grimmShared;
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
optional
optionals
filterAttrs
mkForce
mkIf
attrNames
mkEnableOption
;
in
{
config =
with cfg;
lib.mkIf enable {
config = mkIf enable {
security.polkit.enable = true;
security.rtkit.enable = true;
@ -18,37 +25,36 @@ in
security.sudo.enable = false;
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;
persist = true;
}
];
environment.systemPackages =
with pkgs;
[
(with pkgs; [
mkpasswd
gnupg
libsecret
vulnix
doas-sudo-shim # muscle memory
agenix
])
++ optionals (tooling.enable && tooling.pass) [
pkgs.pass
(pkgs.writeShellScriptBin "passw" "pass $@")
]
++ lib.optionals (tooling.enable && tooling.pass) [
pass
(writeShellScriptBin "passw" "pass $@")
]
++ lib.optional graphical lxqt.lxqt-policykit;
++ optional graphical pkgs.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 = {
settings = {
# 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;
};
};
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
cfg = config.grimmShared;
inherit (config.grimmShared) enable portals graphical;
browsers = [
"firefox-beta.desktop"
"firefox.desktop"
@ -35,9 +35,7 @@ let
tex_editors = [ ] ++ text_editors;
in
{
config =
with cfg;
lib.mkIf (enable && portals && graphical) {
config = lib.mkIf (enable && portals && graphical) {
environment.systemPackages = with pkgs; [
deskwhich

View file

@ -5,12 +5,25 @@
...
}:
let
cfg = config.grimmShared;
inherit (config.grimmShared)
enable
portals
sound
screens
;
inherit (lib)
mkIf
mkEnableOption
mapAttrs'
foldl'
min
getExe
isInt
nameValuePair
;
in
{
config =
with cfg;
lib.mkIf (enable && portals) {
config = mkIf (enable && portals) {
xdg.icons.enable = true;
xdg.sounds.enable = lib.mkIf sound.enable true;
@ -24,9 +37,7 @@ in
];
wlr.enable = true;
wlr.settings =
with lib;
mapAttrs' (
wlr.settings = mapAttrs' (
name: value:
nameValuePair ("screencast_" + name) {
output_name = value.id;
@ -34,7 +45,7 @@ in
chooser_type = "simple";
chooser_cmd = "${getExe pkgs.slurp} -f %o -or";
}
) cfg.screens;
) screens;
};
environment.sessionVariables = {
@ -44,5 +55,5 @@ in
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 @@
{
config,
lib,
pkgs,
...
}:
{ lib, pkgs, ... }:
{
imports = [
./overlays

View file

@ -3,7 +3,7 @@
lib,
rustPlatform,
}:
rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage {
pname = "deskwhich";
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,
gobject-introspection,
gtk3,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
{ final, prev, ... }:
{ prev, ... }:
{
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: {
src = prev.fetchFromGitHub {

View file

@ -1,4 +1,4 @@
{ final, prev, ... }:
{ prev, ... }:
{
mcontrolcenter = prev.callPackage (prev.fetchurl {
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 { };
}

View file

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

View file

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

View file

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

View file

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

View file

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