dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit 8ac4afccfbea180dae9527c3f3f9b74095df7e77 parent a0ac270d13e0d47a4ab0158bc2f3887882128657 Author: V7 <maydayv7@gmail.com> Date: Sun, 29 Jan 2023 21:08:09 +0530 feat: Declaratively Configure Flatpak applications Also add `apply --activate` in the `nixos` Script
Diffstat:
| M | README.md | | | 10 | ++++++++++ |
| M | configuration.nix | | | 1 | + |
| M | devices/Vortex.nix | | | 2 | +- |
| M | files/default.nix | | | 9 | +++++++-- |
| A | files/flatpak/repos | | | 39 | +++++++++++++++++++++++++++++++++++++++ |
| M | flake.lock | | | 22 | ++++++++++++++++++++++ |
| M | flake.nix | | | 6 | ++++++ |
| M | modules/README.md | | | 8 | +++++++- |
| A | modules/apps/flatpak.nix | | | 113 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | modules/gui/gnome.nix | | | 45 | +++++++++++++++++++++++++++++++++++++++++++-- |
| M | scripts/nixos.nix | | | 5 | +++++ |
11 files changed, 254 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md @@ -37,6 +37,7 @@ This [repository](https://github.com/maydayv7/dotfiles) contains the configurati - Advanced Configuration [Checks](./modules/nix/checks.nix) using [`pre-commit-hooks.nix`](https://github.com/cachix/pre-commit-hooks.nix) - Support for `source` Filters with [`nix-filter`](https://github.com/numtide/nix-filter) and [`gitignore.nix`](https://github.com/hercules-ci/gitignore.nix) - Wrapped `wine` [Applications](./packages/wine) using Emmanuel's [Wrapper](https://github.com/emmanuelrosa/erosanix/tree/0dabea58d483e13d2de141517cb4ff1cb230b2aa/pkgs/mkwindowsapp) +- Declaratively Configured [Flatpak](./modules/apps/flatpak.nix) applications using [`declarative-nix-flatpak`](https://github.com/yawnt/declarative-nix-flatpak) - Declaratively Configured [Windows VM](./modules/hardware/virtualisation/windows.nix) using the [WFVM](https://git.m-labs.hk/M-Labs/wfvm) Module ## Programs @@ -424,6 +425,7 @@ You can navigate to the `README`'s present in the various directories to know mo - Drop `cod`, `nix-linter` and `mutter-rounded` - Fix GNOME Extensions - Improve XFCE Configuration Handling +- Declaratively Configure Flatpak applications using [`declarative-nix-flatpak`](https://github.com/yawnt/declarative-nix-flatpak) ### 22.11 (v11) @@ -600,6 +602,14 @@ You can navigate to the `README`'s present in the various directories to know mo - It is a hard requirement to clone the repository to `/etc/nixos` in order to use it as intended - Need to completely transition to Wayland +## Manually Packaged Apps + +- **GNOME Extensions**: + - Fly Pie + - Top Bar Organizer +- [Wine](./packages/wine) Applications +- [Flatpak](./modules/apps/flatpak.nix) Applications + </details> > Last Updated: **July** 2022 diff --git a/configuration.nix b/configuration.nix @@ -14,6 +14,7 @@ with inputs; let inherit (lib.util) build map pack; lib = library.lib.extend (final: prev: { + inherit (flatpak.lib) flatpak; deploy = deploy.lib; filters = ignore.lib // {inherit (filter.lib) filter matchExt;}; hooks = hooks.lib; diff --git a/devices/Vortex.nix b/devices/Vortex.nix @@ -21,7 +21,7 @@ gui.desktop = "gnome"; shell.utilities = true; - apps.list = ["discord" "firefox" "git" "office" "vscode" "wine"]; + apps.list = ["discord" "firefox" "flatpak" "git" "office" "vscode" "wine"]; # User V7 user = { diff --git a/files/default.nix b/files/default.nix @@ -27,6 +27,9 @@ in rec { # Firefox Web Browser firefox.theme = readFile ./firefox/userContent.css; + # Flatpak Apps + flatpak.repos = readFile ./flatpak/repos; + # Custom Fonts fonts = { path = ./fonts/proprietary; @@ -93,10 +96,12 @@ in rec { # XFCE Desktop xfce = { css = readFile ./xfce/gtk.css; + terminal = readFile ./xfce/terminalrc; settings = map.files ./xfce/settings - (file: replaceStrings ["@system" "@desktop"] ["/etc/nixos" "${pkgs.xfce.xfdesktop.outPath}"] (readFile file)) ".xml"; - terminal = readFile ./xfce/terminalrc; + (file: + replaceStrings ["@system" "@desktop"] + [path.system pkgs.xfce.xfdesktop.outPath] (readFile file)) ".xml"; }; # My Personal Website diff --git a/files/flatpak/repos b/files/flatpak/repos @@ -0,0 +1,39 @@ +[core] +repo_version=1 +mode=bare-user-only +min-free-space-size=500MB + +[remote "flathub"] +url=https://dl.flathub.org/repo/ +xa.title=Flathub +gpg-verify=false +gpg-verify-summary=false +xa.comment=Central repository of Flatpak applications +xa.description=Central repository of Flatpak applications +xa.icon=https://dl.flathub.org/repo/logo.svg +xa.homepage=https://flathub.org/ + +[remote "flathub-beta"] +url=https://dl.flathub.org/beta-repo/ +xa.title=Flathub beta +gpg-verify=false +gpg-verify-summary=false +xa.comment=Beta builds of Flatpak applications +xa.description=Beta builds of Flatpak applications +xa.icon=https://dl.flathub.org/repo/logo.svg +xa.homepage=https://flathub.org/ + +[remote "gnome-nightly"] +url=https://nightly.gnome.org/repo/ +xa.title=GNOME Nightly +gpg-verify=false +gpg-verify-summary=false +xa.description=The latest GNOME flatpak runtimes/apps directly from the gitlab CI. This is highly unstable stuff aimed at GNOME developers/designers to test +xa.homepage=https://gnome.org/ + +[remote "kdeapps"] +url=http://distribute.kde.org/flatpak-apps-testing/ +xa.title=KDE Testing Applications +gpg-verify=false +gpg-verify-summary=false +xa.icon=https://distribute.kde.org/flatpak-apps-testing/kdeapp.svg diff --git a/flake.lock b/flake.lock @@ -73,6 +73,27 @@ "type": "github" } }, + "flatpak": { + "inputs": { + "nixpkgs": [ + "stable" + ] + }, + "locked": { + "lastModified": 1673290874, + "narHash": "sha256-3+1bSZduJNuRimgs4H33XgptxrRE9p0oriR9YtyuMRM=", + "owner": "yawnt", + "repo": "declarative-nix-flatpak", + "rev": "4a84fbf8f9935aa9e1c7262d48077198157fa5ff", + "type": "github" + }, + "original": { + "owner": "yawnt", + "ref": "simple", + "repo": "declarative-nix-flatpak", + "type": "github" + } + }, "gaming": { "inputs": { "nixpkgs": [ @@ -277,6 +298,7 @@ "compatibility": "compatibility", "deploy": "deploy", "filter": "filter", + "flatpak": "flatpak", "gaming": "gaming", "generators": "generators", "hardware": "hardware", diff --git a/flake.nix b/flake.nix @@ -147,6 +147,12 @@ inputs.flake-compat.follows = "compatibility"; }; + # Declarative Flatpak Wrapper + flatpak = { + url = "github:yawnt/declarative-nix-flatpak/simple"; + inputs.nixpkgs.follows = "stable"; + }; + # VS Code Server Support vscode = { url = "github:msteen/nixos-vscode-server"; diff --git a/modules/README.md b/modules/README.md @@ -6,7 +6,13 @@ The `modules` directory contains custom-made pure Flakes-compatible configuratio - [`apps`](./apps): Module that configures various apps and/or environments - - - `list`: List of all enabled applications - `[ "discord" "firefox" "git" "office" "wine" ]` + - `list`: List of all enabled applications - `[ "discord" "firefox" "flatpak" "git" "office" "wine" ]` + - `flatpak` - + - `runtimes`: Declaratively configured Flatpak Runtimes + - `programs`: Declaratively managed Flatpak Applications - + - `name`, `description` + - `exec`: Application Executable command/path + - `install`: Application Derivation created using `lib.flatpak` - `git` - - `hosting` - - `enable`: Enable Gitea Code Hosting - `true / false` diff --git a/modules/apps/flatpak.nix b/modules/apps/flatpak.nix @@ -0,0 +1,113 @@ +{ + config, + lib, + pkgs, + files, + ... +}: let + cfg = config.apps.flatpak; + enable = builtins.elem "flatpak" config.apps.list; + inherit (flatpak) fetchAppFromFlatHub fetchRuntimeFromFlatHub; + inherit (lib) flatpak mapAttrs' mapAttrsToList mkIf mkOption nameValuePair types; +in { + ## Flatpak Configuration ## + options.apps.flatpak = { + # Program Declaration + programs = mkOption { + type = with types; + attrsOf (submodule ({options, ...}: { + options = { + name = mkOption { + description = "Application Long Name"; + type = nonEmptyStr; + }; + description = mkOption { + description = "Application Description"; + type = str; + }; + exec = mkOption { + description = "Application Executable Command/Path"; + type = nonEmptyStr; + }; + install = mkOption { + description = "Application Derivation"; + apply = url: fetchAppFromFlatHub url; + }; + }; + })); + }; + + # Runtime Declaration + runtimes = mkOption { + type = with types; + attrsOf (attrsOf package); + }; + }; + + config = mkIf enable { + services.flatpak.enable = true; + xdg.portal.enable = true; + + ## Default Runtimes + # Use `flatpak remote-info --log` to find commit revisions + apps.flatpak.runtimes = rec { + freedesktop = { + locale = fetchRuntimeFromFlatHub { + name = "org.freedesktop.Platform.Locale"; + branch = "22.08"; + commit = "3031f965fff14350b47aa5f26e17d79d52843d72afd81f59e77634a8a0d9b923"; + sha256 = "sha256-BQN/7S3pOyUA06HAH7lRYhXdCzDBcipC7fvac8TYoEc="; + }; + h264 = fetchRuntimeFromFlatHub { + name = "org.freedesktop.Platform.openh264"; + branch = "2.2.0"; + commit = "435b1135f46af01c742f7680e92a2ca2b63ef7f5cb6b75030caff3cdd80481a9"; + sha256 = "sha256-djUBvVehasXweG+DXgtoBpPb02OKLbx4stAnPGsopF4="; + }; + gl = fetchRuntimeFromFlatHub { + name = "org.freedesktop.Platform.GL.default"; + branch = "22.08"; + commit = "c1c025c27ef025aec874681c62ffe2939154fa032a7b12266b82e438946e9001"; + sha256 = "sha256-uNOg73pIQW5VAxscU1/1fz+eKl9qMXdkMXCG07CwVTs="; + }; + vaapi = fetchRuntimeFromFlatHub { + name = "org.freedesktop.Platform.VAAPI.Intel"; + branch = "22.08"; + commit = "31273448688ea085d7c88a8cf69127de931b952d6de9ca48704f6c5644012623"; + sha256 = "sha256-XE8IVtplLk7aVWdVxm8vrah/ZrPX+Om2M0YxfdyFHfU="; + }; + platform = fetchRuntimeFromFlatHub { + name = "org.freedesktop.Platform"; + branch = "22.08"; + runtime = with freedesktop; [gl locale h264 vaapi]; + commit = "2ce7932bdf087b4d9af01bfe47801aee69f23d64c1ea704621155a96e96fdbaf"; + sha256 = "sha256-7xWA8EujsYeARYk6svxT/YuY7LKhbsuiARIlgmABb8M="; + }; + }; + }; + + user = { + persist.dirs = [".cache/flatpak" ".local/share/flatpak"]; + home = { + # Repositories + home.file.".local/share/flatpak/repo/config".text = files.flatpak.repos; + + # Application Wrapper + home.packages = mapAttrsToList (_: name: name.install) cfg.programs; + xdg.desktopEntries = mapAttrs' (app: value: + with value; + nameValuePair app { + inherit name exec; + comment = mkIf (value ? description) description; + icon = + if (value ? icon) + then icon + else exec; + terminal = false; + type = "Application"; + }) + cfg.programs; + }; + }; + }; +} diff --git a/modules/gui/gnome.nix b/modules/gui/gnome.nix @@ -7,9 +7,10 @@ }: with files; let inherit (builtins) elem; - inherit (lib) mkIf mkForce mkMerge util; inherit (config.gui) desktop; apps = config.environment.systemPackages; + inherit (lib) mkIf mkForce mkMerge recursiveUpdate util; + flatpak = (mkIf (config ? apps) (recursiveUpdate config.apps.flatpak lib.flatpak)).content; in { ## GNOME Desktop Configuration ## config = mkIf (desktop == "gnome" || desktop == "gnome-minimal") (mkMerge [ @@ -59,6 +60,47 @@ in { }; }; + # Flatpak Apps + apps.flatpak = with flatpak; + mkIf (config ? apps) { + # Required Runtimes + runtimes.gnome = { + locale = fetchRuntimeFromFlatHub { + name = "org.gnome.Platform.Locale"; + branch = "43"; + commit = "4fbaaaa735433be40205ca5f79159b67e39ba61d8ab3383f08023eb6280c5c91"; + sha256 = "sha256-VGWxGFBK5b//6GEDog2A15BhewKcbIiSPQwc6l9DnIA="; + }; + platform = fetchRuntimeFromFlatHub { + name = "org.gnome.Platform"; + branch = "43"; + runtime = with runtimes; [freedesktop.platform gnome.locale]; + commit = "ff25bb0c5f8225e73b43cf40669f5935f68bbde67b00871e13f6c1261d6dc966"; + sha256 = "sha256-VOKendIOlCgkUtEMnsnD+DlIlYZ7ZoHKdj2V80l57JQ="; + }; + theme = fetchRuntimeFromFlatHub { + name = "org.gtk.Gtk3theme.adw-gtk3-dark"; + branch = "3.22"; + commit = "316ef706db3530374b4053cad491f80610094b8512d055bc9de7eb703f794cd9"; + sha256 = "sha256-9+RKdQZay+ILp33ddjTYZsTUdtyW0CIwDMRfvU0W5tM="; + }; + }; + + programs = with runtimes; { + flatseal = { + name = "Flatseal"; + exec = "com.github.tchx84.Flatseal"; + description = "Manage Flatpak Permissions"; + install = { + name = "com.github.tchx84.Flatseal"; + runtime = [freedesktop.platform gnome.platform gnome.theme]; + commit = "7e76ba71421b243359a3bf168a8d5a1010575c7041ff135c163e73d7d50f0a96"; + sha256 = "sha256-Vx4joOwGJM5Jkpo/rmKlJ/4BvcxugvpOCwTMf/p3gMc="; + }; + }; + }; + }; + # User Configuration user.home = { # Dconf Keys @@ -227,7 +269,6 @@ in { ".local/share/clipboard" ".local/share/epiphany" ".local/share/evolution" - ".local/share/flatpak" ".local/share/geary" ".local/share/gnome-boxes" ".local/share/gnome-builder" diff --git a/scripts/nixos.nix b/scripts/nixos.nix @@ -43,6 +43,7 @@ with files; let apply = '' # Usage # + --activate - Activates Current Configuration --boot - Applies Configuration on boot --check - Checks Configuration Build --deploy [ 'device' ] - Automatically Deploy via SSH @@ -115,6 +116,10 @@ in echo "Applying Configuration..." sudo nixos-rebuild switch --flake ${path.system}# ;; + "--activate") + echo "Activating Configuration..." + sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch + ;; "--boot") echo "Applying Configuration..." sudo nixos-rebuild boot --flake ${path.system}#