Recursive update

This commit is contained in:
Filippo Berto 2022-06-29 09:34:43 +02:00
parent 8592e99bf3
commit c741cd7201
4 changed files with 51 additions and 46 deletions

View file

@ -1,4 +1,5 @@
{ config, pkgs, ... }: { config, pkgs, lib, ... }:
with lib;
let let
inherit (pkgs.rice) colorPalette opacity; inherit (pkgs.rice) colorPalette opacity;
grep = "${pkgs.gnugrep}/bin/grep"; grep = "${pkgs.gnugrep}/bin/grep";
@ -110,7 +111,7 @@ in
screenchange-reload = false; screenchange-reload = false;
}; };
"bar/primary" = commonBar // { "bar/primary" = recursiveUpdate commonBar {
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = "player pulseaudio temperature cpu memory battery date powermenu"; modules-right = "player pulseaudio temperature cpu memory battery date powermenu";
@ -121,7 +122,7 @@ in
}; };
}; };
"bar/secondary" = commonBar // { "bar/secondary" = recursiveUpdate commonBar {
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = "player pulseaudio temperature cpu memory battery date powermenu"; modules-right = "player pulseaudio temperature cpu memory battery date powermenu";
@ -147,9 +148,9 @@ in
}; };
format = { format = {
charging = colors.selected // { text = "<animation-charging> <label-charging>"; }; charging = recursiveUpdate colors.selected { text = "<animation-charging> <label-charging>"; };
discharging = colors.active // { text = "<animation-discharging> <label-discharging>"; }; discharging = recursiveUpdate colors.active { text = "<animation-discharging> <label-discharging>"; };
full = colors.normal // { text = " <label-full>"; }; full = recursiveUpdate colors.normal { text = " <label-full>"; };
}; };
label.text = "%percentage%%"; label.text = "%percentage%%";
@ -173,18 +174,16 @@ in
}; };
in in
{ {
focused = colors.selected // common; focused = recursiveUpdate colors.selected common;
occupied = colors.active // common; occupied = recursiveUpdate colors.active common;
urgent = colors.active // common // { background = colors.alert; }; urgent = recursiveUpdate (recursiveUpdate colors.active common) { background = colors.alert; };
empty = colors.normal // common // { text = "󰧟"; padding = 0; }; empty = recursiveUpdate (recursiveUpdate colors.normal common) { text = "󰧟"; padding = 0; };
}; };
}; };
"module/cpu" = { "module/cpu" = {
type = "internal/cpu"; type = "internal/cpu";
format = colors.normal // { format = recursiveUpdate colors.normal { text = " <label>"; };
text = " <label>";
};
interval = 2; interval = 2;
label = "%percentage-sum%%"; label = "%percentage-sum%%";
ramp-load = ramp; ramp-load = ramp;
@ -207,9 +206,7 @@ in
"module/memory" = { "module/memory" = {
type = "internal/memory"; type = "internal/memory";
format = colors.normal // { format = recursiveUpdate colors.normal { text = " <label>"; };
text = " <label>";
};
interval = 2; interval = 2;
label = "%percentage_used%%"; label = "%percentage_used%%";
ramp-used = ramp; ramp-used = ramp;
@ -237,7 +234,7 @@ in
format = { format = {
padding = 1; padding = 1;
muted = colors.active; muted = colors.active;
volume = colors.normal // { text = "<ramp-volume> <label-volume>"; }; volume = recursiveUpdate colors.normal { text = "<ramp-volume> <label-volume>"; };
}; };
label.muted.text = " muted"; label.muted.text = " muted";
label.volume.text = "%percentage%%"; label.volume.text = "%percentage%%";
@ -246,7 +243,7 @@ in
}; };
"module/temperature" = { "module/temperature" = {
format = colors.normal // { format = recursiveUpdate colors.normal {
text = "<ramp> <label>"; text = "<ramp> <label>";
warn = { warn = {
text = "<ramp> <label-warn>"; text = "<ramp> <label-warn>";
@ -272,8 +269,8 @@ in
suffix = " "; suffix = " ";
}; };
label = { label = {
open = colors.normal // { text = " "; }; open = recursiveUpdate colors.normal { text = " "; };
close = colors.normal // { text = "Cancel"; }; close = recursiveUpdate colors.normal { text = "Cancel"; };
separator = { text = "|"; }; separator = { text = "|"; };
}; };
menu = [ menu = [
@ -300,7 +297,7 @@ in
"module/player" = { "module/player" = {
type = "custom/script"; type = "custom/script";
format = colors.normal // { padding = 0; }; format = recursiveUpdate colors.normal { padding = 0; };
exec = playerStatus; exec = playerStatus;
click.left = "${playerCtl} play-pause"; click.left = "${playerCtl} play-pause";
scroll = { scroll = {

View file

@ -1,5 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
boot = { boot = {
binfmt.emulatedSystems = [ "armv7l-linux" "aarch64-linux" ]; binfmt.emulatedSystems = [ "armv7l-linux" "aarch64-linux" ];
@ -78,7 +78,7 @@
dbus.packages = with pkgs; [ dconf ]; dbus.packages = with pkgs; [ dconf ];
fail2ban = { enable = true; bantime-increment.enable = true; }; fail2ban = { enable = true; bantime-increment.enable = true; };
gnome.gnome-keyring.enable = true; gnome.gnome-keyring.enable = true;
gvfs = { enable = true; package = lib.mkForce pkgs.gnome3.gvfs; }; gvfs = { enable = true; package = mkForce pkgs.gnome3.gvfs; };
jackett = { enable = true; openFirewall = true; group = "users"; }; jackett = { enable = true; openFirewall = true; group = "users"; };
jellyfin = { enable = true; openFirewall = true; group = "users"; }; jellyfin = { enable = true; openFirewall = true; group = "users"; };
logind.lidSwitch = "ignore"; logind.lidSwitch = "ignore";
@ -109,19 +109,19 @@
"force group" = "users"; "force group" = "users";
}; in }; in
{ {
bertof = common // { bertof = recursiveUpdate common {
path = "/mnt/raid0/bertof"; path = "/mnt/raid0/bertof";
comment = "Bertof samba share"; comment = "Bertof samba share";
"force user" = "bertof"; "force user" = "bertof";
"valid users" = "bertof"; "valid users" = "bertof";
}; };
tiziano = common // { tiziano = recursiveUpdate common {
path = "/mnt/raid0/tiziano"; path = "/mnt/raid0/tiziano";
comment = "Tiziano samba share"; comment = "Tiziano samba share";
"force user" = "tiziano"; "force user" = "tiziano";
"valid users" = "tiziano"; "valid users" = "tiziano";
}; };
condiviso = common // { condiviso = recursiveUpdate common {
path = "/mnt/raid0/condiviso"; path = "/mnt/raid0/condiviso";
comment = "Samba share condiviso"; comment = "Samba share condiviso";
"valid users" = "bertof tiziano"; "valid users" = "bertof tiziano";
@ -130,19 +130,19 @@
"force create mode" = "0660"; "force create mode" = "0660";
"force directory mode" = "2770"; "force directory mode" = "2770";
}; };
bertof_safe = common // { bertof_safe = recursiveUpdate common {
path = "/mnt/raid1/bertof"; path = "/mnt/raid1/bertof";
comment = "Bertof samba share"; comment = "Bertof samba share";
"force user" = "bertof"; "force user" = "bertof";
"valid users" = "bertof"; "valid users" = "bertof";
}; };
tiziano_safe = common // { tiziano_safe = recursiveUpdate common {
path = "/mnt/raid1/tiziano"; path = "/mnt/raid1/tiziano";
comment = "Tiziano samba share"; comment = "Tiziano samba share";
"force user" = "tiziano"; "force user" = "tiziano";
"valid users" = "tiziano"; "valid users" = "tiziano";
}; };
condiviso_safe = common // { condiviso_safe = recursiveUpdate common {
path = "/mnt/raid1/condiviso"; path = "/mnt/raid1/condiviso";
comment = "Samba share condiviso"; comment = "Samba share condiviso";
"valid users" = "bertof tiziano"; "valid users" = "bertof tiziano";
@ -239,13 +239,18 @@
systemd.packages = with pkgs; [ syncthing ]; systemd.packages = with pkgs; [ syncthing ];
systemd.services = let common = { systemd.services = let common = {
documentation = [ "man:syncthing(1)" ];
startLimitIntervalSec = 60;
startLimitBurst = 4;
after = [ "network.target" ]; after = [ "network.target" ];
environment = { STNORESTART = "yes"; STNOUPGRADE = "yes"; }; environment = { STNORESTART = "yes"; STNOUPGRADE = "yes"; };
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
serviceConfig = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";
SuccessExitStatus = "2 3 4"; RestartSec = 1;
SuccessExitStatus = "3 4";
RestartForceExitStatus = "3 4"; RestartForceExitStatus = "3 4";
Group = config.ids.gids.users; Group = config.ids.gids.users;
MemoryDenyWriteExecute = true; MemoryDenyWriteExecute = true;
NoNewPrivileges = true; NoNewPrivileges = true;
@ -264,13 +269,13 @@
}; };
}; in }; in
{ {
syncthing-bertof = common // { syncthing-bertof = recursiveUpdate common {
description = "Syncthing service bertof"; description = "Syncthing service bertof";
serviceConfig = common.serviceConfig // { User = "bertof"; ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -home=/mnt/raid0/bertof/Syncthing/.config"; }; serviceConfig = { User = "bertof"; ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -gui-address=0.0.0.0:8384 -home=/mnt/raid0/bertof/Syncthing/.config"; };
}; };
syncthing-tiziano = common // { syncthing-tiziano = recursiveUpdate common {
description = "Syncthing service tiziano"; description = "Syncthing service tiziano";
serviceConfig = common.serviceConfig // { User = "tiziano"; ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -gui-address=0.0.0.0:8385 -home=/mnt/raid0/tiziano/Syncthing/.config"; }; serviceConfig = { User = "tiziano"; ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -gui-address=0.0.0.0:8385 -home=/mnt/raid0/tiziano/Syncthing/.config"; };
}; };
}; };
@ -324,7 +329,7 @@
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
extraOptions = lib.optionalString (config.nix.package == pkgs.nixFlakes) extraOptions = optionalString (config.nix.package == pkgs.nixFlakes)
"experimental-features = nix-command flakes"; "experimental-features = nix-command flakes";
gc.automatic = true; gc.automatic = true;
}; };

View file

@ -1,4 +1,6 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }:
with lib;
{
# Use the systemd-boot EFI boot loader. # Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
@ -150,15 +152,15 @@
common = { extraConfig = bertofExtraConfig; }; common = { extraConfig = bertofExtraConfig; };
in in
{ {
bertof_home = common // { subvolume = "/home/bertof"; }; bertof_home = recursiveUpdate common { subvolume = "/home/bertof"; };
bertof_music = common // { subvolume = "/home/bertof/Musica"; }; bertof_music = recursiveUpdate common { subvolume = "/home/bertof/Musica"; };
bertof_downloads = common // { subvolume = "/home/bertof/Scaricati"; }; bertof_downloads = recursiveUpdate common { subvolume = "/home/bertof/Scaricati"; };
bertof_images = common // { subvolume = "/home/bertof/Immagini"; }; bertof_images = recursiveUpdate common { subvolume = "/home/bertof/Immagini"; };
bertof_videos = common // { subvolume = "/home/bertof/Video"; }; bertof_videos = recursiveUpdate common { subvolume = "/home/bertof/Video"; };
bertof_documents = common // { subvolume = "/home/bertof/Documenti"; }; bertof_documents = recursiveUpdate common { subvolume = "/home/bertof/Documenti"; };
bertof_games_ssd = common // { subvolume = "/home/bertof/Giochi/SSD"; }; bertof_games_ssd = recursiveUpdate common { subvolume = "/home/bertof/Giochi/SSD"; };
# bertof_games_hdd = common // { subvolume = "/home/bertof/Giochi/HDD"; }; # bertof_games_hdd = recursiveUpdate common { subvolume = "/home/bertof/Giochi/HDD"; };
bertof_git = common // { subvolume = "/home/bertof/Documenti/Git"; }; bertof_git = recursiveUpdate common { subvolume = "/home/bertof/Documenti/Git"; };
}; };
}; };

View file

@ -1,4 +1,5 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
with lib;
{ {
boot = { boot = {
binfmt.emulatedSystems = [ "armv7l-linux" "aarch64-linux" ]; binfmt.emulatedSystems = [ "armv7l-linux" "aarch64-linux" ];
@ -110,7 +111,7 @@
}; };
in in
{ {
bertof_home = common // { subvolume = "/home/bertof"; }; bertof_home = recursiveUpdate common { subvolume = "/home/bertof"; };
}; };
}; };
thermald.enable = true; thermald.enable = true;