feat: Add Flatpak support
Some checks failed
Code Check / Run nixfmt and statix (push) Waiting to run
Code Check / Run nixfmt and statix (pull_request) Has been cancelled

chore: Prep for PR
This commit is contained in:
Andre 2024-06-16 14:53:33 -04:00
parent 249b7d7bc0
commit 9557d65423
5 changed files with 104 additions and 65 deletions

View file

@ -37,8 +37,7 @@
}: }:
let let
###*** IMPORTANT: Please set your system's hostname here ***### ###*** IMPORTANT: Please set your system's hostname here ***###
#hostName = builtins.abort "Please set the 'hostName' variable in flake.nix"; hostName = builtins.abort "Please set the 'hostName' variable in flake.nix";
hostName = "myHost";
/* /*
What kind of system are you running NixOS on? What kind of system are you running NixOS on?

View file

@ -57,6 +57,14 @@ in
# Change the default text editor. Options are "emacs", "nano", or "vim". # Change the default text editor. Options are "emacs", "nano", or "vim".
editor = "nano"; editor = "nano";
ui.flatpak = {
# Enable Flatpak support.
enable = false;
# Define Flatpak packages to install.
packages = [ ];
};
# Additional system packages to install. # Additional system packages to install.
packages = [ ]; packages = [ ];

View file

@ -1,63 +1 @@
#builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix" builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix"
# Surface Laptop Go 1st gen
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
availableKernelModules = [
"xhci_pci"
"nvme"
"usb_storage"
"usbhid"
"sd_mod"
];
kernelModules = [ ];
luks.devices."luks-5a91100b-8ed9-4090-b1d8-d8291000fe38".device = "/dev/disk/by-uuid/5a91100b-8ed9-4090-b1d8-d8291000fe38";
};
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/76d67291-5aed-4f2a-b71f-1c2871cefe24";
fsType = "btrfs";
options = [ "subvol=@,compress=zstd,discard" ];
};
"/boot" = {
device = "/dev/disk/by-uuid/0C53-A645";
fsType = "vfat";
};
};
swapDevices = [
{
device = "/swapfile";
size = 4096;
}
];
networking = {
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
# Set the hostname.
#hostName = "Dimaga";
};
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -20,6 +20,15 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
aux.system.ui.desktops.enable = true; aux.system.ui.desktops.enable = true;
programs.dconf.enable = true;
# Fix blank messages in KMail. See https://nixos.wiki/wiki/KDE#KMail_Renders_Blank_Messages
environment.sessionVariables = {
NIX_PROFILES = "${pkgs.lib.concatStringsSep " " (
pkgs.lib.reverseList config.environment.profiles
)}";
};
services = { services = {
displayManager.sddm.enable = true; displayManager.sddm.enable = true;
desktopManager.plasma6.enable = true; desktopManager.plasma6.enable = true;

View file

@ -0,0 +1,85 @@
# Enable support for Flatpak applications
{
nix-flatpak,
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.ui.flatpak;
in
with lib;
{
options = {
aux.system.ui.flatpak = {
enable = mkEnableOption (mdDoc "Enables Flatpak support.");
packages = lib.mkOption {
description = "Flatpak packages to install.";
type = lib.types.listOf lib.types.str;
default = [ ];
example = lib.literalExpression "[ \"com.valvesoftware.Steam\" ]";
};
};
};
config = mkIf cfg.enable {
# Enable Flatpak
services.flatpak = {
enable = true;
# Manage all Flatpak packages and remotes
uninstallUnmanaged = true;
# Enable automatic updates alongside nixos-rebuild
update.onActivation = true;
# Add remote(s)
remotes = [
{
name = "flathub";
location = "https://dl.flathub.org/repo/flathub.flatpakrepo";
}
];
# Install base Flatpaks. For details, see https://github.com/gmodena/nix-flatpak
packages = cfg.packages;
};
# Workaround for getting Flatpak apps to use system fonts, icons, and cursors
# For details (and source), see https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1767513263
# NOTE: If fonts in Flatpaks appear incorrect (like squares), run this command to regenerate the font cache:
# flatpak list --columns=application | xargs -I %s -- flatpak run --command=fc-cache %s -f -v
system.fsPackages = [ pkgs.bindfs ];
fileSystems =
let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [
"ro"
"resolve-symlinks"
"x-gvfs-hide"
];
};
aggregatedIcons = pkgs.buildEnv {
name = "system-icons";
paths = with pkgs; [
(lib.mkIf config.aux.system.ui.gnome.enable gnome.gnome-themes-extra)
(lib.mkIf config.aux.system.ui.kde.enable kdePackages.breeze-icons)
];
pathsToLink = [ "/share/icons" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.packages;
pathsToLink = [ "/share/fonts" ];
};
in
{
"/usr/share/icons" = mkRoSymBind "${aggregatedIcons}/share/icons";
"/usr/local/share/fonts" = mkRoSymBind "${aggregatedFonts}/share/fonts";
};
};
}