From 22196a41564676e34beaf837b1875c91b77d809e Mon Sep 17 00:00:00 2001 From: Andre Date: Sun, 16 Jun 2024 14:53:33 -0400 Subject: [PATCH] feat(system): add Flatpak support chore(system): replace test data with abort messages --- system/flake.nix | 3 +- system/host/configuration.nix | 8 +++ system/host/hardware-configuration.nix | 64 +------------------ system/modules/ui/desktops/kde.nix | 9 +++ system/modules/ui/flatpak.nix | 85 ++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 65 deletions(-) create mode 100644 system/modules/ui/flatpak.nix diff --git a/system/flake.nix b/system/flake.nix index 6d8c6ad..230da04 100644 --- a/system/flake.nix +++ b/system/flake.nix @@ -37,8 +37,7 @@ }: let ###*** IMPORTANT: Please set your system's hostname here ***### - #hostName = builtins.abort "Please set the 'hostName' variable in flake.nix"; - hostName = "myHost"; + hostName = builtins.abort "Please set the 'hostName' variable in flake.nix"; /* What kind of system are you running NixOS on? diff --git a/system/host/configuration.nix b/system/host/configuration.nix index 945e215..78ad617 100644 --- a/system/host/configuration.nix +++ b/system/host/configuration.nix @@ -57,6 +57,14 @@ in # Change the default text editor. Options are "emacs", "nano", or "vim". editor = "nano"; + ui.flatpak = { + # Enable Flatpak support. + enable = false; + + # Define Flatpak packages to install. + packages = [ ]; + }; + # Additional system packages to install. packages = [ ]; diff --git a/system/host/hardware-configuration.nix b/system/host/hardware-configuration.nix index 1d02b53..2a352bd 100644 --- a/system/host/hardware-configuration.nix +++ b/system/host/hardware-configuration.nix @@ -1,63 +1 @@ -#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..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; -} +builtins.abort "Please run 'nixos-generate-config --show-hardware-config' and copy the output into hardware-configuration.nix" \ No newline at end of file diff --git a/system/modules/ui/desktops/kde.nix b/system/modules/ui/desktops/kde.nix index c1b7d35..d5b6f32 100644 --- a/system/modules/ui/desktops/kde.nix +++ b/system/modules/ui/desktops/kde.nix @@ -20,6 +20,15 @@ in config = lib.mkIf cfg.enable { 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 = { displayManager.sddm.enable = true; desktopManager.plasma6.enable = true; diff --git a/system/modules/ui/flatpak.nix b/system/modules/ui/flatpak.nix new file mode 100644 index 0000000..0474338 --- /dev/null +++ b/system/modules/ui/flatpak.nix @@ -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"; + }; + }; +}