Regenerated
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
|
||||
let
|
||||
# Module name
|
||||
moduleName = "flatpaks";
|
||||
|
||||
# Path to your Flatpak list
|
||||
assetPath = ../../../assets/system/apps/flatpaks.conf;
|
||||
|
||||
# Resolve user safely
|
||||
username = config.defaultUser or "henrov";
|
||||
in
|
||||
{
|
||||
# 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 ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{ 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;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ config, pkgs, lib, inputs, ... }:
|
||||
|
||||
let
|
||||
# Grab the Zen Browser from the flake overlay for your system
|
||||
zenBrowser = inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
zenBrowser
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user