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

View File

View File

@ -1,7 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sync_mod = with lib; types.submodule ({ config, ... }: { sync_mod =
with lib;
types.submodule (
{ config, ... }:
{
options = { options = {
remote = mkOption { remote = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
@ -14,10 +23,13 @@ let
description = "local path to sync"; description = "local path to sync";
}; };
}; };
}); }
);
in in
{ {
config = with cfg; lib.mkIf (enable && cloudSync.enable) ( config =
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 = ''${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}"; sync_server = "https://${config.grimmShared.cloudSync.server}";
@ -28,17 +40,20 @@ in
nextcloud-client nextcloud-client
]; ];
systemd.services = lib.mkMerge (lib.mapAttrsToList systemd.services = lib.mkMerge (
(local_user: user_conf: lib.mapAttrsToList (
local_user: user_conf:
let let
paths = user_conf.syncPaths; paths = user_conf.syncPaths;
sync_script = lib.strings.concatLines (map sync_script = lib.strings.concatLines (
({ local, remote }: map (
{ local, remote }:
let let
remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote); remote_clean = lib.strings.concatStrings (builtins.match "/*(.+)" remote);
in in
"${cloud_cmd} /${remote_clean} ${local} ${sync_server}") "${cloud_cmd} /${remote_clean} ${local} ${sync_server}"
paths); ) paths
);
in in
{ {
# user-specific sync jobs # user-specific sync jobs
@ -56,11 +71,13 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
enable = true; enable = true;
}; };
}) }
config.users.users); ) config.users.users
);
systemd.timers = lib.mkMerge (lib.mapAttrsToList systemd.timers = lib.mkMerge (
(local_user: user_conf: lib.mapAttrsToList (
local_user: user_conf:
let let
paths = user_conf.syncPaths; paths = user_conf.syncPaths;
in in
@ -70,16 +87,23 @@ in
description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes"; description = "Automatic sync files with Nextcloud when booted up after 5 minutes then rerun every 60 minutes";
timerConfig.OnBootSec = "5min"; timerConfig.OnBootSec = "5min";
timerConfig.OnUnitActiveSec = "60min"; timerConfig.OnUnitActiveSec = "60min";
wantedBy = [ "multi-user.target" "timers.target" ]; wantedBy = [
"multi-user.target"
"timers.target"
];
enable = true; enable = true;
}; };
}) }
config.users.users); ) config.users.users
);
} }
); );
options.users.users = with lib; mkOption { options.users.users =
type = types.attrsOf (types.submodule { with lib;
mkOption {
type = types.attrsOf (
types.submodule {
options = { options = {
syncPaths = mkOption { syncPaths = mkOption {
type = types.listOf sync_mod; type = types.listOf sync_mod;
@ -87,10 +111,10 @@ in
description = "paths to sync via nextcloud"; description = "paths to sync via nextcloud";
}; };
}; };
}); }
);
}; };
options.grimmShared.cloudSync = with lib; { options.grimmShared.cloudSync = with lib; {
enable = mkEnableOption "cloud_sync"; enable = mkEnableOption "cloud_sync";

View File

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

View File

@ -1,30 +1,38 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && firefox.enable) { config =
environment.systemPackages = [ ] with cfg;
lib.mkIf (enable && firefox.enable) {
environment.systemPackages =
[ ]
++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ]; ++ lib.optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ];
programs.firefox = { programs.firefox = {
package = pkgs.firefox-beta; package = pkgs.firefox-beta;
enable = true; enable = true;
nativeMessagingHosts.packages = [ ] nativeMessagingHosts.packages =
[ ]
++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ]; ++ lib.optionals (cfg.tooling.enable && cfg.tooling.pass) [ pkgs.passff-host ];
languagePacks = lib.optionals cfg.locale [ "de" "en-US" ]; languagePacks = lib.optionals cfg.locale [
"de"
"en-US"
];
policies = { policies = {
ExtensionSettings = lib.mkMerge [ ExtensionSettings = lib.mkMerge [
(lib.mkIf cfg.firefox.disableUserPlugins { (lib.mkIf cfg.firefox.disableUserPlugins { "*".installation_mode = "blocked"; })
"*".installation_mode = "blocked"; (lib.mapAttrs (guid: shortId: {
})
(lib.mapAttrs
(guid: shortId: {
# explicit plugins by config # explicit plugins by config
install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi";
installation_mode = "force_installed"; installation_mode = "force_installed";
}) }) cfg.firefox.plugins)
cfg.firefox.plugins)
(lib.mkIf (cfg.tooling.enable && cfg.tooling.pass) { (lib.mkIf (cfg.tooling.enable && cfg.tooling.pass) {
# password-store support # password-store support
"passff@invicem.pro" = { "passff@invicem.pro" = {

View File

@ -1,18 +1,23 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && gaming) { config =
with cfg;
lib.mkIf (enable && gaming) {
programs.steam = { programs.steam = {
enable = true; enable = true;
gamescopeSession.enable = true; gamescopeSession.enable = true;
gamescopeSession.env = { gamescopeSession.env = {
DRI_PRIME = "1"; DRI_PRIME = "1";
}; };
extraCompatPackages = with pkgs; [ extraCompatPackages = with pkgs; [ proton-ge-bin ];
proton-ge-bin
];
# extest.enable = true; # extest.enable = true;
}; };
@ -44,7 +49,8 @@ in
(pkgs.symlinkJoin { (pkgs.symlinkJoin {
name = "osu"; name = "osu";
paths = [ paths = [
(pkgs.writeShellScriptBin "osu!" ''exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin} (pkgs.writeShellScriptBin "osu!" ''
exec gamemoderun ${lib.getExe pkgs.osu-lazer-bin}
'') '')
pkgs.osu-lazer-bin pkgs.osu-lazer-bin
]; ];

View File

@ -1,6 +1,13 @@
{ lib, pkgs, config, ... }:
{ {
config = with config.grimmShared; lib.mkIf (enable && graphical) { lib,
pkgs,
config,
...
}:
{
config =
with config.grimmShared;
lib.mkIf (enable && graphical) {
fonts = { fonts = {
packages = with pkgs; [ packages = with pkgs; [
noto-fonts noto-fonts

View File

@ -1,7 +1,14 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
screen = with lib; types.submodule { screen =
with lib;
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);
@ -30,7 +37,9 @@ let
}; };
in in
{ {
config = with cfg; lib.mkIf (enable && graphical) { config =
with cfg;
lib.mkIf (enable && graphical) {
# Enable OpenGL # Enable OpenGL
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
@ -60,7 +69,6 @@ in
]; ];
}; };
options.grimmShared = with lib; { options.grimmShared = with lib; {
graphical = mkOption { graphical = mkOption {
type = types.bool; type = types.bool;

View File

@ -1,16 +1,26 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && graphical) { config =
with cfg;
lib.mkIf (enable && graphical) {
qt = { qt = {
enable = true; enable = true;
style = "kvantum"; style = "kvantum";
platformTheme = "qt5ct"; platformTheme = "qt5ct";
}; };
environment.systemPackages = with pkgs; with kdePackages; [ environment.systemPackages =
with pkgs;
with kdePackages;
[
qtstyleplugin-kvantum qtstyleplugin-kvantum
catppuccin-sddm-corners catppuccin-sddm-corners
libsForQt5.qtgraphicaleffects libsForQt5.qtgraphicaleffects
@ -24,9 +34,7 @@ in
qtwayland qtwayland
]; ];
environment.pathsToLink = [ environment.pathsToLink = [ "/share/Kvantum" ];
"/share/Kvantum"
];
services.displayManager = { services.displayManager = {
sddm = { sddm = {
@ -39,9 +47,7 @@ in
}; };
boot.plymouth = { boot.plymouth = {
themePackages = with pkgs; [ themePackages = with pkgs; [ catppuccin-plymouth ];
catppuccin-plymouth
];
theme = "catppuccin-macchiato"; theme = "catppuccin-macchiato";
enable = true; enable = true;
}; };

View File

@ -1,7 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sway_conf = with lib; types.submodule ({ config, ... }: rec { sway_conf =
with lib;
types.submodule (
{ config, ... }:
rec {
options = { options = {
keybinds = mkOption { keybinds = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
@ -39,15 +48,18 @@ let
description = "possible modes to switch to, e.g. resize"; description = "possible modes to switch to, e.g. resize";
}; };
}; };
}); }
);
build_screen_def = fps_func: with lib; let build_screen_def =
output_def = mapAttrsToList fps_func:
(name: value: with lib;
let
output_def = mapAttrsToList (
name: value:
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz" "output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
+ (optionalString (value.pos != null) " position ${value.pos}") + (optionalString (value.pos != null) " position ${value.pos}")
) ) cfg.screens;
cfg.screens;
in in
'' ''
for pid in $(${pkgs.procps}/bin/pgrep sway -x) for pid in $(${pkgs.procps}/bin/pgrep sway -x)
@ -64,16 +76,22 @@ let
fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps); fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps);
fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps); fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps);
init_screens_min_fps = with lib; pkgs.writeShellScriptBin "init-screens-min" init_screens_min_fps =
(build_screen_def fps_min); with lib;
init_screens_max_fps = with lib; pkgs.writeShellScriptBin "init-screens-max" pkgs.writeShellScriptBin "init-screens-min" (build_screen_def fps_min);
(build_screen_def fps_max); init_screens_max_fps =
with lib;
pkgs.writeShellScriptBin "init-screens-max" (build_screen_def fps_max);
init_screens_auto = pkgs.writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}"; init_screens_auto = pkgs.writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}";
in in
{ {
config = config =
let let
bar_conf_file = if (lib.isPath cfg.sway.bar.config) then cfg.sway.bar.config else pkgs.writers.writeJSON "config.json" cfg.sway.bar.config; bar_conf_file =
if (lib.isPath cfg.sway.bar.config) then
cfg.sway.bar.config
else
pkgs.writers.writeJSON "config.json" cfg.sway.bar.config;
waybar_full = pkgs.writeShellScriptBin "waybar-full" ( waybar_full = pkgs.writeShellScriptBin "waybar-full" (
(lib.getExe config.programs.waybar.package) (lib.getExe config.programs.waybar.package)
+ (lib.optionalString (!isNull cfg.sway.bar.config) " -c ${bar_conf_file}") + (lib.optionalString (!isNull cfg.sway.bar.config) " -c ${bar_conf_file}")
@ -92,16 +110,21 @@ in
systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr
''; '';
build_conf = with lib; sway_conf: build_conf =
with lib;
sway_conf:
let let
build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}"); build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}");
build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}"); build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}");
build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item))); build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item)));
build_mode_lines = mapAttrsToList (name: value: '' build_mode_lines = mapAttrsToList (
name: value: ''
mode "${name}" { mode "${name}" {
${concatLines (map (item: " " + item ) (build_conf value))}}''); ${concatLines (map (item: " " + item) (build_conf value))}}''
);
in in
([ ] (
[ ]
++ (build_definition_lines sway_conf.definitions) ++ (build_definition_lines sway_conf.definitions)
++ (build_keybind_lines sway_conf.keybinds) ++ (build_keybind_lines sway_conf.keybinds)
++ (build_exec_lines "exec" sway_conf.autolaunch) ++ (build_exec_lines "exec" sway_conf.autolaunch)
@ -113,17 +136,17 @@ in
sway_conf = lib.concatLines ( sway_conf = lib.concatLines (
(build_conf cfg.sway.config) (build_conf cfg.sway.config)
++ lib.optional cfg.sway.bar.enable bar_config ++ lib.optional cfg.sway.bar.enable bar_config
++ (lib.mapAttrsToList ++ (lib.mapAttrsToList (
(name: value: name: value:
"output ${value.id} mode ${value.mode}" "output ${value.id} mode ${value.mode}"
+ (lib.optionalString (value.pos != null) " position ${value.pos}") + (lib.optionalString (value.pos != null) " position ${value.pos}")
) ) cfg.screens)
cfg.screens)
); );
conf_path = "sway.conf"; conf_path = "sway.conf";
in in
with cfg; lib.mkIf (enable && sway.enable) { with cfg;
lib.mkIf (enable && sway.enable) {
environment.etc."${conf_path}".text = sway_conf; environment.etc."${conf_path}".text = sway_conf;
grimmShared.sway.config.execAlways = [ grimmShared.sway.config.execAlways = [
@ -131,13 +154,15 @@ in
init_screens_auto init_screens_auto
]; ];
environment.systemPackages = [ environment.systemPackages =
[
waybar_full waybar_full
dbus-sway-environment dbus-sway-environment
init_screens_min_fps init_screens_min_fps
init_screens_max_fps init_screens_max_fps
init_screens_auto init_screens_auto
] ++ (with pkgs; [ ]
++ (with pkgs; [
procps procps
slurp slurp
libnotify libnotify

View File

@ -1,10 +1,19 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages =
with pkgs;
[
lm_sensors lm_sensors
lshw lshw
pciutils pciutils
@ -13,7 +22,8 @@ in
ddcutil ddcutil
python312Packages.py-cpuinfo python312Packages.py-cpuinfo
(writeShellScriptBin "lsiommu" ./lsiommu) (writeShellScriptBin "lsiommu" ./lsiommu)
] ++ lib.optionals graphical [ ]
++ lib.optionals graphical [
ddcui ddcui
wootility wootility
]; ];
@ -66,8 +76,7 @@ in
]; ];
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
extraModulePackages = [ extraModulePackages = [
(config.boot.kernelPackages.ddcci-driver.overrideAttrs (config.boot.kernelPackages.ddcci-driver.overrideAttrs (old: {
(old: {
patches = [ patches = [
(pkgs.fetchpatch { (pkgs.fetchpatch {
url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch"; url = "https://gitlab.com/Sweenu/ddcci-driver-linux/-/commit/7f851f5fb8fbcd7b3a93aaedff90b27124e17a7e.patch";
@ -93,4 +102,3 @@ in
enable = lib.mkEnableOption "grimm-laptop"; enable = lib.mkEnableOption "grimm-laptop";
}; };
} }

View File

@ -1,33 +1,67 @@
{ pkgs, config, lib, system, ... }: {
pkgs,
config,
lib,
system,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
inherit (lib) optionals optional optionalString concatLines getExe; inherit (lib)
optionals
optional
optionalString
concatLines
getExe
;
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower; inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms); enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms);
powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([ powersave =
with pkgs;
writeShellScriptBin "powersave-mode" (
concatLines (
[
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed "${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
"${getExe pkgs.brightnessctl} s 20%" # display brightness "${getExe pkgs.brightnessctl} s 20%" # display brightness
] ++ optionals enable_perf_policy [ ]
++ optionals enable_perf_policy [
"${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 cfg.sway.enable "init-screens-min"
)
);
performance = pkgs.writeShellScriptBin "performance-mode" (concatLines ([ performance = pkgs.writeShellScriptBin "performance-mode" (
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
"${getExe pkgs.brightnessctl} s 100%" # display brightness "${getExe pkgs.brightnessctl} s 100%" # display brightness
] ++ optionals enable_perf_policy [ ]
++ optionals enable_perf_policy [
"${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")); ]
auto = let inherit (pkgs) tlp; in pkgs.writeShellScriptBin "auto-mode" '' ++ 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-ac ${getExe performance}
${tlp}/bin/run-on-bat ${getExe powersave} ${tlp}/bin/run-on-bat ${getExe powersave}
''; '';
in in
{ {
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages =
with pkgs;
[
acpi acpi
powertop powertop
brightnessctl brightnessctl
@ -35,9 +69,9 @@ in
powersave powersave
performance performance
auto auto
] ++ optionals graphical [ ]
tlpui ++ optionals graphical [ tlpui ]
] ++ optional enable_perf_policy x86_energy_perf_policy; ++ optional enable_perf_policy x86_energy_perf_policy;
services.acpid = { services.acpid = {
enable = true; enable = true;
@ -74,4 +108,3 @@ in
}; };
}; };
} }

View File

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

View File

@ -1,18 +1,26 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && network && config.hardware.bluetooth.enable) { config =
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; [ environment.systemPackages = with pkgs; [ bluetuith ] ++ lib.optional sound.enable pkgs.bluez;
bluetuith
] ++ lib.optional sound.enable pkgs.bluez;
systemd.user.services.mpris-proxy = lib.mkIf sound.enable { systemd.user.services.mpris-proxy = lib.mkIf sound.enable {
description = "Mpris proxy"; description = "Mpris proxy";
after = [ "network.target" "sound.target" ]; after = [
"network.target"
"sound.target"
];
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; serviceConfig.ExecStart = "${pkgs.bluez}/bin/mpris-proxy";
}; };

View File

@ -1,9 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && network) { config =
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

@ -1,12 +1,22 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && printing) { config =
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; [ brgenml1lpr brgenml1cupswrapper ]; services.printing.drivers = with pkgs; [
brgenml1lpr
brgenml1cupswrapper
];
services.avahi = { services.avahi = {
enable = true; enable = true;
nssmdns4 = true; nssmdns4 = true;
@ -15,7 +25,9 @@ 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 = with pkgs; (lib.optionals cfg.graphical [ environment.systemPackages =
with pkgs;
(lib.optionals cfg.graphical [
kdePackages.skanpage kdePackages.skanpage
# libsForQt5.skanpage # libsForQt5.skanpage
]); ]);

View File

@ -1,9 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && sound.enable) { config =
with cfg;
lib.mkIf (enable && sound.enable) {
sound.enable = true; sound.enable = true;
hardware.pulseaudio.enable = false; hardware.pulseaudio.enable = false;

View File

@ -1,10 +1,17 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
sound_font = pkgs.soundfont-fluid; sound_font = pkgs.soundfont-fluid;
in in
{ {
config = with cfg; lib.mkIf (enable && sound.midi) { config =
with cfg;
lib.mkIf (enable && sound.midi) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
mpv mpv
timidity timidity
@ -12,9 +19,7 @@ in
sound_font sound_font
]; ];
environment.pathsToLink = [ environment.pathsToLink = [ "/share/soundfonts" ];
"/share/soundfonts"
];
environment.etc."timidity/timidity.cfg".text = "soundfont ${sound_font}/share/soundfonts/FluidR3_GM2-2.sf2"; environment.etc."timidity/timidity.cfg".text = "soundfont ${sound_font}/share/soundfonts/FluidR3_GM2-2.sf2";
}; };

View File

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

View File

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

View File

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
spotifyd_cache_dir = "/tmp/spotifyd"; spotifyd_cache_dir = "/tmp/spotifyd";
cfg = config.grimmShared; cfg = config.grimmShared;
@ -22,7 +27,9 @@ let
''; '';
in in
{ {
config = with cfg; lib.mkIf (enable && spotify.spotifyd.enable) { config =
with cfg;
lib.mkIf (enable && spotify.spotifyd.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
spotifyd spotifyd
spotifyd-dbus spotifyd-dbus
@ -53,7 +60,15 @@ in
bitrate = 320; bitrate = 320;
username = cfg.spotify.spotifyd.username; username = cfg.spotify.spotifyd.username;
device_name = "grimm_laptop"; 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); 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"; device_type = "computer";
dbus_type = "system"; dbus_type = "system";
device = "default"; device = "default";
@ -67,16 +82,16 @@ in
}; };
}; };
services.dbus.packages = with pkgs; [ spotifyd-dbus ];
services.dbus.packages = with pkgs; [
spotifyd-dbus
];
# spotifyd has access to global pipewire # spotifyd has access to global pipewire
users.users.spotifyd = { users.users.spotifyd = {
isSystemUser = true; isSystemUser = true;
group = "spotifyd"; group = "spotifyd";
extraGroups = [ "audio" "pipewire" ]; extraGroups = [
"audio"
"pipewire"
];
}; };
# spotifyd is also a group # spotifyd is also a group
@ -91,7 +106,6 @@ in
description = "spotify username"; description = "spotify username";
}; };
pass = mkOption { pass = mkOption {
type = types.either types.nonEmptyStr (types.either types.package types.path); type = types.either types.nonEmptyStr (types.either types.package types.path);
description = "command to execute to obtain login information or readable path to a file containing them"; description = "command to execute to obtain login information or readable path to a file containing them";

View File

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
@ -10,14 +15,19 @@ in
./python.nix ./python.nix
]; ];
config = with cfg; lib.mkIf (enable && tooling.enable) { config =
environment.systemPackages = with pkgs; [ with cfg;
lib.mkIf (enable && tooling.enable) {
environment.systemPackages =
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" "${lib.getExe pkgs.eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time")
(writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'') (writeShellScriptBin "spawn" ''exec "$@" &> /dev/null &'')
urlencode urlencode
pstree pstree
dos2unix dos2unix
treefmt
gcc gcc
jdk17 jdk17
@ -45,7 +55,8 @@ in
glibc glibc
expect expect
neovim-remote neovim-remote
] ++ lib.optionals cfg.graphical [ ]
++ lib.optionals cfg.graphical [
wev wev
qdirstat qdirstat
libva-utils libva-utils
@ -88,7 +99,6 @@ in
services.dbus.implementation = "broker"; services.dbus.implementation = "broker";
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
vim-scala vim-scala
fugitive fugitive

View File

@ -1,14 +1,21 @@
{ lib, pkgs, config, ... }: {
lib,
pkgs,
config,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
viewer_pkg = pkgs.zathura; viewer_pkg = pkgs.zathura;
viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",''; viewer_def = lib.optionalString cfg.graphical ''pdf_viewer = "${lib.getExe pkgs.zathura}",'';
in in
{ {
config = with cfg; lib.mkIf (enable && tooling.enable && tooling.lilypond) { config =
environment.systemPackages = with pkgs; [ with cfg;
lilypond-with-fonts lib.mkIf (enable && tooling.enable && tooling.lilypond) {
] ++ lib.optional graphical viewer_pkg; environment.systemPackages =
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 = "${lib.getExe pkgs.neovim-remote} -s +:'dr %(file)s | call cursor(%(line)s,%(char)s+1)'";
}; };
@ -39,11 +46,8 @@ in
''; '';
}; };
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ nvim-lilypond-suite ];
nvim-lilypond-suite
];
}; };
options.grimmShared.tooling.lilypond = lib.mkEnableOption "enable lilypond tooling"; options.grimmShared.tooling.lilypond = lib.mkEnableOption "enable lilypond tooling";
} }

View File

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

View File

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

View File

@ -1,32 +1,45 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf enable { config =
with cfg;
lib.mkIf enable {
security.polkit.enable = true; security.polkit.enable = true;
networking.firewall.enable = lib.mkIf network true; networking.firewall.enable = lib.mkIf network true;
security.rtkit.enable = true; security.rtkit.enable = true;
security.doas.enable = true; security.doas.enable = true;
security.sudo.enable = false; security.sudo.enable = false;
security.doas.extraRules = [{ security.doas.extraRules = [
{
users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users); users = lib.attrNames (lib.filterAttrs (n: v: v.isNormalUser) config.users.users);
keepEnv = true; keepEnv = true;
persist = true; persist = true;
}]; }
];
environment.systemPackages = with pkgs; [ environment.systemPackages =
with pkgs;
[
mkpasswd mkpasswd
gnupg gnupg
libsecret libsecret
vulnix vulnix
doas-sudo-shim # muscle memory doas-sudo-shim # muscle memory
agenix agenix
] ++ lib.optionals (tooling.enable && tooling.pass) [ ]
++ lib.optionals (tooling.enable && tooling.pass) [
pass pass
(writeShellScriptBin "passw" "pass $@") (writeShellScriptBin "passw" "pass $@")
] ++ lib.optional graphical lxqt.lxqt-policykit; ]
++ lib.optional graphical lxqt.lxqt-policykit;
services.passSecretService.enable = lib.mkIf (tooling.enable && tooling.pass) true; services.passSecretService.enable = lib.mkIf (tooling.enable && tooling.pass) true;
programs.gnupg.agent = { programs.gnupg.agent = {

View File

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
browsers = [ browsers = [
@ -15,12 +20,8 @@ let
"org.kde.krita.desktop" "org.kde.krita.desktop"
"draw.desktop" "draw.desktop"
]; ];
audio_players = [ audio_players = [ "vlc.desktop" ];
"vlc.desktop" video_viewers = [ "vlc.desktop" ];
];
video_viewers = [
"vlc.desktop"
];
document_viewers = [ document_viewers = [
"org.pwmt.zathura-pdf-mupdf.desktop" "org.pwmt.zathura-pdf-mupdf.desktop"
"com.github.jeromerobert.pdfarranger.desktop" "com.github.jeromerobert.pdfarranger.desktop"
@ -34,7 +35,9 @@ let
tex_editors = [ ] ++ text_editors; tex_editors = [ ] ++ text_editors;
in in
{ {
config = with cfg; lib.mkIf (enable && portals && graphical) { config =
with cfg;
lib.mkIf (enable && portals && graphical) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
deskwhich deskwhich
@ -63,7 +66,10 @@ in
xdg.terminal-exec = { xdg.terminal-exec = {
enable = true; enable = true;
settings = { settings = {
default = [ "Alacritty.desktop" "kitty.desktop" ]; default = [
"Alacritty.desktop"
"kitty.desktop"
];
}; };
}; };
@ -73,9 +79,7 @@ in
"idea-community.desktop" "idea-community.desktop"
"imhex.desktop" "imhex.desktop"
]; ];
"application/json" = text_editors ++ [ "application/json" = text_editors ++ [ "firefox-beta.desktop" ];
"firefox-beta.desktop"
];
"application/mp4" = video_viewers; "application/mp4" = video_viewers;
"application/ogg" = audio_players; "application/ogg" = audio_players;
"application/octet-stream" = "imhex.desktop"; "application/octet-stream" = "imhex.desktop";

View File

@ -1,9 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
in in
{ {
config = with cfg; lib.mkIf (enable && portals) { config =
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;
@ -17,23 +24,24 @@ in
]; ];
wlr.enable = true; wlr.enable = true;
wlr.settings = with lib; mapAttrs' wlr.settings =
(name: value: nameValuePair ("screencast_" + name) { with lib;
mapAttrs' (
name: value:
nameValuePair ("screencast_" + name) {
output_name = value.id; output_name = value.id;
max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps); max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps);
chooser_type = "simple"; chooser_type = "simple";
chooser_cmd = "${getExe pkgs.slurp} -f %o -or"; chooser_cmd = "${getExe pkgs.slurp} -f %o -or";
}) }
cfg.screens; ) cfg.screens;
}; };
environment.sessionVariables = { environment.sessionVariables = {
XDG_CONFIG_HOME = "$HOME/.config"; XDG_CONFIG_HOME = "$HOME/.config";
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ xwaylandvideobridge ];
xwaylandvideobridge
];
}; };
options.grimmShared.portals = lib.mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts"; options.grimmShared.portals = lib.mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts";

View File

@ -1,7 +1,6 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = imports = [
[
./overlays ./overlays
./common ./common
./fake_flake.nix ./fake_flake.nix

View File

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

View File

@ -1,4 +1,10 @@
{ pkgs, lib, config, system, ... }: {
pkgs,
lib,
config,
system,
...
}:
let let
nivSources = import ./nix/sources.nix; nivSources = import ./nix/sources.nix;
asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}"; asGithubRef = src: "github:${src.owner}/${src.repo}/${src.rev}";
@ -32,12 +38,13 @@ in
nixpkgs.pkgs = nixpkgs.pkgs =
let let
src = nivSources.nixpkgs; src = nivSources.nixpkgs;
config = { allowUnfree = true; }; config = {
allowUnfree = true;
};
unpatched = import src { inherit config system; }; unpatched = import src { inherit config system; };
inherit (unpatched) applyPatches fetchpatch; inherit (unpatched) applyPatches fetchpatch;
in in
import import (applyPatches {
(applyPatches {
name = "nixpkgs-patched"; name = "nixpkgs-patched";
inherit src; inherit src;
patches = map fetchpatch nixpkgs_patches; patches = map fetchpatch nixpkgs_patches;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,16 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
searchclip = let inherit (lib) getExe; in with pkgs; writeShellScriptBin "searchclip" '' searchclip =
let
inherit (lib) getExe;
in
with pkgs;
writeShellScriptBin "searchclip" ''
xdg-open https://www.google.com/search?q=$(wl-paste -p | ${getExe urlencode}) xdg-open https://www.google.com/search?q=$(wl-paste -p | ${getExe urlencode})
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//") browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
sleep .1 sleep .1
@ -8,9 +18,7 @@ let
''; '';
in in
{ {
imports = [ imports = [ ./bar ];
./bar
];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
rmenu rmenu
@ -28,7 +36,9 @@ in
grimmShared.sway = { grimmShared.sway = {
enable = true; enable = true;
config = with pkgs; let config =
with pkgs;
let
inherit (lib) getExe; inherit (lib) getExe;
in in
{ {
@ -237,4 +247,3 @@ in
}; };
}; };
} }

4
treefmt.toml Normal file
View File

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