Reshuffling stuff

This commit is contained in:
2026-03-18 18:55:27 +00:00
parent 9fcb5c8c08
commit 5774e064dc
2 changed files with 122 additions and 116 deletions
+61 -58
View File
@@ -826,22 +826,24 @@ in
** =generated/modules/apps/flatpaks.nix=
This will import all packages listed in ./assets/system/apps/flatpaks.conf
#+BEGIN_SRC nix :tangle generated/modules/apps/flatpaks.nix :noweb tangle :mkdirp yes :eval never-html
{ lib, config, pkgs, flakeRoot, ... }:
{ lib, ... }:
let
moduleName = "install-flatpaks";
flatpakConfPath = "${flakeRoot}/assets/system/apps/flatpaks.conf";
# Lees en split het bestand
# --- Relatief pad binnen deze module (geen flakeRoot) ---
flatpakConfPath = ./assets/system/apps/flatpaks.conf;
# --- Lees en split het bestand ---
raw = builtins.readFile flatpakConfPath;
rawLines = lib.splitString "\n" raw;
# Guard: check dat we niet per karakter hebben gesplit
# --- Guard: check dat we niet per karakter hebben gesplit ---
_guard =
assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw);
true;
# Cleanup per regel: CR verwijderen, commentaar weghalen, trim
# --- Cleanup per regel ---
cleanLine = line:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
@@ -849,10 +851,9 @@ let
in
lib.strings.trim noInlineComment;
# Filter lege regels
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
# Validatie: check reverse-DNS stijl (min 2 dots)
# --- Validatie: min 2 dots (reverse-DNS stijl) ---
dotCount = s: builtins.length (lib.splitString "." s) - 1;
isValidId = s: (dotCount s) >= 2;
@@ -870,68 +871,70 @@ let
) entries
);
# Gebruik de gevalideerde lijst
flatpakApps = builtins.seq _validate entries;
# Maak systemd script
syncFlatpaks = pkgs.writeShellScript "sync-flatpaks" ''
set -euo pipefail
CONF="/etc/flatpak/flatpaks.conf"
if [[ -f "$CONF" ]]; then
echo "flatpak-sync: using $CONF"
else
echo "flatpak-sync: WARNING: $CONF not found, using embedded list"
fi
if ! flatpak remotes --system --columns=name | grep -qx flathub; then
flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
fi
desired_apps=(
${lib.concatStringsSep " " (map (a: ''"${a}"'') flatpakApps)}
)
for app in $desired_apps; do
if ! flatpak info --system "$app" >/dev/null 2>&1; then
flatpak install --system -y --noninteractive flathub "$app"
fi
done
'';
in
{
options.mySystem.system.flatpak.enable = lib.mkEnableOption "Enable automatic Flatpak installation";
# --- Export as NixOS module via flake.nixosModules ---
flake.nixosModules.flatpaks = { config, pkgs, lib, ... }:
config = lib.mkIf (config.mySystem.system.flatpak.enable or false) {
let
syncFlatpaks = pkgs.writeShellScript "sync-flatpaks" ''
set -euo pipefail
# Flatpak service zelf
services.flatpak.enable = true;
CONF="/etc/flatpak/flatpaks.conf"
if [[ -f "$CONF" ]]; then
echo "flatpak-sync: using $CONF"
else
echo "flatpak-sync: WARNING: $CONF not found, using embedded list"
fi
xdg.portal.enable = true;
if ! flatpak remotes --system --columns=name | grep -qx flathub; then
flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
fi
# Deploy config voor runtime/debug
environment.etc."flatpak/flatpaks.conf".source = lib.mkForce flatpakConfPath;
desired_apps=(
${lib.concatStringsSep " " (map (a: ''"${a}"'') flatpakApps)}
)
# systemd service
systemd.services.flatpak-sync = {
description = "Install Flatpak apps listed in flatpaks.conf";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
for app in $desired_apps; do
if ! flatpak info --system "$app" >/dev/null 2>&1; then
flatpak install --system -y --noninteractive flathub "$app"
fi
done
'';
in
{
options.mySystem.system.flatpaks.enable = lib.mkEnableOption "Enable automatic Flatpak installation";
serviceConfig = {
Type = "oneshot";
ExecStart = syncFlatpaks;
config = lib.mkIf (config.mySystem.system.flatpaks.enable or false) {
services.flatpak.enable = true;
xdg.portal.enable = true;
# Deploy de conf voor runtime/debug
environment.etc."flatpak/flatpaks.conf".source = lib.mkForce flatpakConfPath;
# Systemd service voor automatische installatie
systemd.services.flatpak-sync = {
description = "Install Flatpak apps listed in flatpaks.conf";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = syncFlatpaks;
};
restartTriggers = [ flatpakConfPath ];
path = [
pkgs.flatpak
pkgs.coreutils
pkgs.gnugrep
pkgs.gnused
];
};
restartTriggers = [ flatpakConfPath ];
path = [
pkgs.flatpak
pkgs.coreutils
pkgs.gnugrep
pkgs.gnused
];
};
};
}
+61 -58
View File
@@ -1,19 +1,21 @@
{ lib, config, pkgs, flakeRoot, ... }:
{ lib, ... }:
let
moduleName = "install-flatpaks";
flatpakConfPath = "${flakeRoot}/assets/system/apps/flatpaks.conf";
# Lees en split het bestand
# --- Relatief pad binnen deze module (geen flakeRoot) ---
flatpakConfPath = ./assets/system/apps/flatpaks.conf;
# --- Lees en split het bestand ---
raw = builtins.readFile flatpakConfPath;
rawLines = lib.splitString "\n" raw;
# Guard: check dat we niet per karakter hebben gesplit
# --- Guard: check dat we niet per karakter hebben gesplit ---
_guard =
assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw);
true;
# Cleanup per regel: CR verwijderen, commentaar weghalen, trim
# --- Cleanup per regel ---
cleanLine = line:
let
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
@@ -21,10 +23,9 @@ let
in
lib.strings.trim noInlineComment;
# Filter lege regels
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
# Validatie: check reverse-DNS stijl (min 2 dots)
# --- Validatie: min 2 dots (reverse-DNS stijl) ---
dotCount = s: builtins.length (lib.splitString "." s) - 1;
isValidId = s: (dotCount s) >= 2;
@@ -42,68 +43,70 @@ let
) entries
);
# Gebruik de gevalideerde lijst
flatpakApps = builtins.seq _validate entries;
# Maak systemd script
syncFlatpaks = pkgs.writeShellScript "sync-flatpaks" ''
set -euo pipefail
CONF="/etc/flatpak/flatpaks.conf"
if [[ -f "$CONF" ]]; then
echo "flatpak-sync: using $CONF"
else
echo "flatpak-sync: WARNING: $CONF not found, using embedded list"
fi
if ! flatpak remotes --system --columns=name | grep -qx flathub; then
flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
fi
desired_apps=(
${lib.concatStringsSep " " (map (a: ''"${a}"'') flatpakApps)}
)
for app in $desired_apps; do
if ! flatpak info --system "$app" >/dev/null 2>&1; then
flatpak install --system -y --noninteractive flathub "$app"
fi
done
'';
in
{
options.mySystem.system.flatpak.enable = lib.mkEnableOption "Enable automatic Flatpak installation";
# --- Export as NixOS module via flake.nixosModules ---
flake.nixosModules.flatpaks = { config, pkgs, lib, ... }:
config = lib.mkIf (config.mySystem.system.flatpak.enable or false) {
let
syncFlatpaks = pkgs.writeShellScript "sync-flatpaks" ''
set -euo pipefail
# Flatpak service zelf
services.flatpak.enable = true;
CONF="/etc/flatpak/flatpaks.conf"
if [[ -f "$CONF" ]]; then
echo "flatpak-sync: using $CONF"
else
echo "flatpak-sync: WARNING: $CONF not found, using embedded list"
fi
xdg.portal.enable = true;
if ! flatpak remotes --system --columns=name | grep -qx flathub; then
flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
fi
# Deploy config voor runtime/debug
environment.etc."flatpak/flatpaks.conf".source = lib.mkForce flatpakConfPath;
desired_apps=(
${lib.concatStringsSep " " (map (a: ''"${a}"'') flatpakApps)}
)
# systemd service
systemd.services.flatpak-sync = {
description = "Install Flatpak apps listed in flatpaks.conf";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
for app in $desired_apps; do
if ! flatpak info --system "$app" >/dev/null 2>&1; then
flatpak install --system -y --noninteractive flathub "$app"
fi
done
'';
in
{
options.mySystem.system.flatpaks.enable = lib.mkEnableOption "Enable automatic Flatpak installation";
serviceConfig = {
Type = "oneshot";
ExecStart = syncFlatpaks;
config = lib.mkIf (config.mySystem.system.flatpaks.enable or false) {
services.flatpak.enable = true;
xdg.portal.enable = true;
# Deploy de conf voor runtime/debug
environment.etc."flatpak/flatpaks.conf".source = lib.mkForce flatpakConfPath;
# Systemd service voor automatische installatie
systemd.services.flatpak-sync = {
description = "Install Flatpak apps listed in flatpaks.conf";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = syncFlatpaks;
};
restartTriggers = [ flatpakConfPath ];
path = [
pkgs.flatpak
pkgs.coreutils
pkgs.gnugrep
pkgs.gnused
];
};
restartTriggers = [ flatpakConfPath ];
path = [
pkgs.flatpak
pkgs.coreutils
pkgs.gnugrep
pkgs.gnused
];
};
};
}