Regenerated
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
|
||||
let
|
||||
# Module name
|
||||
moduleName = "flatpaks";
|
||||
|
||||
# Top-level toggle for this module
|
||||
enableProgram = config.enableFlatpaks or false;
|
||||
|
||||
# Path to your Flatpak list
|
||||
assetPath = ../../../assets/system/apps/flatpaks.conf;
|
||||
|
||||
# Resolve user safely
|
||||
username = config.defaultUser or "henrov";
|
||||
in
|
||||
{
|
||||
# --- Top-level toggle option ---
|
||||
options.enableFlatpaks = lib.mkEnableOption "Enable automatic Flatpak installation";
|
||||
|
||||
# --- Config only applied if enabled ---
|
||||
config = lib.mkIf enableProgram {
|
||||
|
||||
# Deploy the Flatpak conf file
|
||||
environment.etc."flatpak/flatpaks.conf".source = assetPath;
|
||||
|
||||
# Enable system Flatpak service
|
||||
services.flatpak.enable = true;
|
||||
xdg.portal.enable = true;
|
||||
|
||||
# Systemd service to install Flatpaks from the list
|
||||
systemd.services."${moduleName}-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 = ''
|
||||
set -euo pipefail
|
||||
CONF="${assetPath}"
|
||||
|
||||
# Add Flathub if not present
|
||||
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
|
||||
|
||||
# Install every Flatpak listed in the conf file
|
||||
while IFS= read -r app || [ -n "$app" ]; do
|
||||
app=$(echo "$app" | sed 's/#.*//;s/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
if [ -n "$app" ]; then
|
||||
if ! flatpak info --system "$app" >/dev/null 2>&1; then
|
||||
flatpak install --system -y --noninteractive flathub "$app"
|
||||
fi
|
||||
fi
|
||||
done < "$CONF"
|
||||
'';
|
||||
};
|
||||
|
||||
restartTriggers = [ assetPath ];
|
||||
|
||||
# Include only the packages needed for this service
|
||||
path = [ pkgs.flatpak pkgs.coreutils pkgs.gnugrep pkgs.gnused ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{ config, lib, pkgs, flakeRoot, ... }:
|
||||
|
||||
let
|
||||
packagesConfPath = "${flakeRoot}/assets/system/apps/packages.conf";
|
||||
raw = builtins.readFile packagesConfPath;
|
||||
|
||||
# Split lines safely, keep guard against splitting into characters
|
||||
rawLines = lib.splitString "\n" raw;
|
||||
_guard =
|
||||
assert !(builtins.stringLength raw > 1 && builtins.length rawLines == builtins.stringLength raw);
|
||||
true;
|
||||
|
||||
# Clean each line: remove CRs, remove comments, trim
|
||||
cleanLine = line:
|
||||
let
|
||||
noCR = lib.replaceStrings [ "\r" ] [ "" ] line;
|
||||
noInlineComment = lib.head (lib.splitString "#" noCR);
|
||||
in
|
||||
lib.strings.trim noInlineComment;
|
||||
|
||||
# Filter out empty lines
|
||||
entries = builtins.filter (l: l != "") (map cleanLine rawLines);
|
||||
|
||||
# Resolve attribute path in pkgs
|
||||
resolvePkg = name:
|
||||
let
|
||||
parts = lib.splitString "." name;
|
||||
found = lib.attrByPath parts null pkgs;
|
||||
in
|
||||
if found == null then
|
||||
throw ''
|
||||
packages.nix: package not found in pkgs
|
||||
Token : ${builtins.toJSON name}
|
||||
packages.conf : ${packagesConfPath}
|
||||
Hint : check the attribute name on search.nixos.org/packages
|
||||
''
|
||||
else
|
||||
found;
|
||||
|
||||
# Final system-wide package list
|
||||
packages = builtins.seq _guard (map resolvePkg entries);
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
nixpkgs.config = { allowUnfree = true; };
|
||||
environment.systemPackages = packages;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
# Assets (optional, empty if no config)
|
||||
assetPath =
|
||||
if builtins.pathExists ../../../assets/system/conf/${programName}
|
||||
then ../../../assets/system/conf/${programName}
|
||||
else null;
|
||||
|
||||
programFiles =
|
||||
if assetPath != null then builtins.readDir assetPath else {};
|
||||
|
||||
files = lib.genAttrs (builtins.attrNames programFiles) (name: {
|
||||
src = "${assetPath}/${name}";
|
||||
});
|
||||
|
||||
# Default user fallback
|
||||
username = config.defaultUser or "henrov";
|
||||
in
|
||||
{
|
||||
# --- Option ---
|
||||
options.enableZenBrowser = lib.mkEnableOption "Install Zen Browser";
|
||||
|
||||
# --- Config ---
|
||||
config = lib.mkIf enableProgram {
|
||||
|
||||
# --- Deploy assets (if any) ---
|
||||
environment.etc."${programName}".source = assetPath;
|
||||
|
||||
# --- System packages ---
|
||||
environment.systemPackages = [ pkgs.zen-browser ];
|
||||
|
||||
# --- Example systemd service to sync assets ---
|
||||
systemd.services."${programName}-sync" = {
|
||||
description = "Sync ${programName} configuration files";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = ''
|
||||
set -euo pipefail
|
||||
if [ -d "${assetPath}" ]; then
|
||||
for f in ${lib.concatStringsSep " " (builtins.attrNames files)}; do
|
||||
cp -u "${assetPath}/$f" "/home/${username}/.config/${programName}/$f"
|
||||
done
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
restartTriggers = [ assetPath ];
|
||||
path = [];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user