From 54cc3eb0491544e08bf3e631c93ef095581f1fa0 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Tue, 14 Dec 2021 00:24:26 -0500 Subject: [PATCH] Added flags to all applications --- modules/applications/default.nix | 9 +- modules/applications/emacs.nix | 6 +- modules/applications/firefox.nix | 112 +++++++++++++---------- modules/applications/nextcloud.nix | 51 +++++++---- modules/applications/sway/default.nix | 1 + modules/applications/{ => sway}/mako.nix | 6 +- modules/applications/{ => sway}/sway.nix | 6 +- modules/applications/sway/waybar.nix | 20 ++++ modules/applications/waybar.nix | 3 - modules/boot.nix | 2 +- modules/default.nix | 12 ++- modules/profiles/graphical.nix | 7 +- 12 files changed, 148 insertions(+), 87 deletions(-) create mode 100644 modules/applications/sway/default.nix rename modules/applications/{ => sway}/mako.nix (94%) rename modules/applications/{ => sway}/sway.nix (95%) create mode 100644 modules/applications/sway/waybar.nix delete mode 100644 modules/applications/waybar.nix diff --git a/modules/applications/default.nix b/modules/applications/default.nix index 718b453..3859100 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -1,10 +1,3 @@ { config, pkgs, ... }: { - imports = [ - ./firefox.nix - ./mako.nix - ./nextcloud.nix - ./waybar.nix - ./emacs.nix - ./sway.nix - ]; + imports = [ ./sway ./emacs.nix ./firefox.nix ./nextcloud.nix ]; } diff --git a/modules/applications/emacs.nix b/modules/applications/emacs.nix index c3c4b10..5319b6c 100644 --- a/modules/applications/emacs.nix +++ b/modules/applications/emacs.nix @@ -1,12 +1,14 @@ { inputs, config, lib, pkgs, ... }: # TODO Still need the following dependecies # - Language tools (grammer) -let cfg = config.application.emacs; +let + cfg = config.application.emacs; + graphical = config.graphical; in with lib; { options = { application.emacs = { enable = mkOption { - default = true; + default = graphical.enable; type = with types; bool; description = "Insert joke about emacs is an operating system."; }; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 4fda7d4..977679f 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -1,61 +1,73 @@ -{ config, pkgs, ... }: { - - home-manager.users.james = { - - # Enable touch controls. - home.sessionVariables = { MOZ_USE_XINPUT2 = 1; }; - - programs.firefox = { - enable = true; - - package = pkgs.firefox.override { - cfg = { - enableTridactylNative = true; - # TODO make this general based on the whether sway is being used. - forceWayland = true; - }; +{ config, pkgs, lib, ... }: +let + cfg = config.application.firefox; + graphical = config.graphical; + sway_cfg = config.applications.sway; +in with lib; { + options = { + application.firefox = { + enable = mkOption { + default = graphical.enable; + type = with types; bool; + description = ""; }; + }; + }; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - onepassword-password-manager - https-everywhere - ublock-origin - tridactyl - ]; + config = mkIf cfg.enable { + home-manager.users.james = { + # Enable touch controls. + home.sessionVariables = { MOZ_USE_XINPUT2 = 1; }; - profiles = { - default = { - name = "primary"; - id = 0; + programs.firefox = { + enable = true; + package = pkgs.firefox.override { + cfg = { + enableTridactylNative = true; + forceWayland = sway_cfg.enable; + }; + }; - settings = { - "browser.download.useDownloadDir" = - false; # Ask for download location - "browser.in-content.dark-mode" = true; # Dark mode - "browser.newtabpage.activity-stream.feeds.section.topstories" = - false; # Disable top stories - "browser.newtabpage.activity-stream.feeds.sections" = false; - "browser.newtabpage.activity-stream.feeds.system.topstories" = - false; # Disable top stories - "browser.newtabpage.activity-stream.section.highlights.includePocket" = - false; # Disable pocket - "media.eme.enabled" = true; # Enable DRM - "media.gmp-widevinecdm.visible" = true; # Enable DRM - "media.gmp-widevinecdm.enabled" = true; # Enable DRM - "signon.autofillForms" = false; # Disable built-in form-filling - "signon.rememberSignons" = - false; # Disable built-in password manager - "ui.systemUsesDarkTheme" = true; # Dark mode + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + onepassword-password-manager + https-everywhere + ublock-origin + tridactyl + ]; + + profiles = { + default = { + name = "primary"; + id = 0; + settings = { + "browser.download.useDownloadDir" = + false; # Ask for download location + "browser.in-content.dark-mode" = true; # Dark mode + "browser.newtabpage.activity-stream.feeds.section.topstories" = + false; # Disable top stories + "browser.newtabpage.activity-stream.feeds.sections" = false; + "browser.newtabpage.activity-stream.feeds.system.topstories" = + false; # Disable top stories + "browser.newtabpage.activity-stream.section.highlights.includePocket" = + false; # Disable pocket + "media.eme.enabled" = true; # Enable DRM + "media.gmp-widevinecdm.visible" = true; # Enable DRM + "media.gmp-widevinecdm.enabled" = true; # Enable DRM + "signon.autofillForms" = false; # Disable built-in form-filling + "signon.rememberSignons" = + false; # Disable built-in password manager + "ui.systemUsesDarkTheme" = true; # Dark mode + }; }; }; }; - }; - # This is a bit silly as this is currently managed by my make dot config. - xdg.configFile."tridactyl/tridactylrc".source = pkgs.fetchurl { - url = - "https://git.jpatrick.io/james/dotfiles/raw/branch/master/tridactyl/tridactylrc"; - sha256 = "sha256-iOBd/yEvQP/Gn3+lS2Ztu9oslllZU4G7VnM4pTck+Tg="; + # This is a bit silly as this is currently managed by my make dot config. + xdg.configFile."tridactyl/tridactylrc".source = pkgs.fetchurl { + url = + "https://git.jpatrick.io/james/dotfiles/raw/branch/master/tridactyl/tridactylrc"; + sha256 = "sha256-iOBd/yEvQP/Gn3+lS2Ztu9oslllZU4G7VnM4pTck+Tg="; + }; }; }; } diff --git a/modules/applications/nextcloud.nix b/modules/applications/nextcloud.nix index 573cc26..8f43226 100644 --- a/modules/applications/nextcloud.nix +++ b/modules/applications/nextcloud.nix @@ -1,21 +1,38 @@ -{ config, lib, pkgs, ... }: { - home-manager.users.james = { - home.packages = with pkgs; [ nextcloud-client ]; +{ config, lib, pkgs, ... }: +let + cfg = config.application.nextcloud; + graphical = config.graphical; +in with lib; { + options = { + application.nextcloud = { + enable = mkOption { + default = graphical.enable; + type = with types; bool; + description = "Dropbox for people who don't like dropbox"; + }; + }; + }; - systemd.user.services = { - nextcloud = { - Unit = { - Description = "Nextcloud - A slighly more GNU friendly dropbox"; - BindsTo = [ "graphical-session.target" ]; - Wants = [ "graphical-session-pre.target" ]; - After = [ "graphical-session-pre.target" ]; - }; - Service = { - Type = "simple"; - ExecStart = "${pkgs.nextcloud-client}/bin/nextclient --background"; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; + config = mkIf cfg.enable { + home-manager.users.james = { + home.packages = with pkgs; [ nextcloud-client ]; + + systemd.user.services = { + nextcloud = { + Unit = { + Description = "Nextcloud - A slighly more GNU friendly dropbox"; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.nextcloud-client}/bin/nextclient --background"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; }; }; }; diff --git a/modules/applications/sway/default.nix b/modules/applications/sway/default.nix new file mode 100644 index 0000000..d07721e --- /dev/null +++ b/modules/applications/sway/default.nix @@ -0,0 +1 @@ +{ config, pkgs, ... }: { imports = [ ./sway.nix ./mako.nix ./waybar.nix ]; } diff --git a/modules/applications/mako.nix b/modules/applications/sway/mako.nix similarity index 94% rename from modules/applications/mako.nix rename to modules/applications/sway/mako.nix index 7909e66..cce1f02 100644 --- a/modules/applications/mako.nix +++ b/modules/applications/sway/mako.nix @@ -1,11 +1,13 @@ { options, config, lib, pkgs, ... }: -let cfg = config.application.mako; +let + cfg = config.application.mako; + sway = config.application.sway; in with lib; { options = { application.mako = { enable = mkOption { # TODO track based on sway default - default = false; + default = sway.enable; type = with types; bool; description = "testing one two three"; }; diff --git a/modules/applications/sway.nix b/modules/applications/sway/sway.nix similarity index 95% rename from modules/applications/sway.nix rename to modules/applications/sway/sway.nix index 704b772..416c320 100644 --- a/modules/applications/sway.nix +++ b/modules/applications/sway/sway.nix @@ -1,11 +1,13 @@ { config, lib, pkgs, ... }: -let cfg = config.application.sway; +let + cfg = config.application.sway; + graphical = config.graphical; in with lib; { options = { application.sway = { enable = mkOption { # TODO base on graphical - default = true; + default = graphical.enable; type = with types; bool; description = "testing one two three"; }; diff --git a/modules/applications/sway/waybar.nix b/modules/applications/sway/waybar.nix new file mode 100644 index 0000000..e3e0dd4 --- /dev/null +++ b/modules/applications/sway/waybar.nix @@ -0,0 +1,20 @@ +{ options, config, lib, pkgs, ... }: +let + cfg = config.application.waybar; + sway_cfg = config.application.sway; +in with lib; { + options = { + application.waybar = { + enable = mkOption { + # TODO track based on sway default + default = sway_cfg.enable; + type = with types; bool; + description = "testing one two three"; + }; + }; + }; + + config = mkIf cfg.enable { + home-manager.users.james = { home.packages = with pkgs; [ waybar ]; }; + }; +} diff --git a/modules/applications/waybar.nix b/modules/applications/waybar.nix deleted file mode 100644 index 9b05363..0000000 --- a/modules/applications/waybar.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ config, pkgs, ... }: { - home-manager.users.james = { home.packages = with pkgs; [ waybar ]; }; -} diff --git a/modules/boot.nix b/modules/boot.nix index 8f3c609..354607f 100644 --- a/modules/boot.nix +++ b/modules/boot.nix @@ -1,6 +1,6 @@ { config, lib, ... }: { - # Enable bootloader & clear /tmp on boot. boot = { + # Enable bootloader & clear /tmp on boot. cleanTmpDir = true; loader = { systemd-boot.enable = true; diff --git a/modules/default.nix b/modules/default.nix index 916afcf..ea175cf 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,14 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { + options = { + graphical = { + enable = lib.mkOption { + default = false; + type = with lib.types; bool; + description = "Does this actually need X/Wayland"; + }; + }; + }; + imports = [ ./system ./applications diff --git a/modules/profiles/graphical.nix b/modules/profiles/graphical.nix index db6bd68..fd50e17 100644 --- a/modules/profiles/graphical.nix +++ b/modules/profiles/graphical.nix @@ -1,4 +1,7 @@ -{ config, lib, pkgs, ... }: { +{ config, lib, pkgs, ... }: + +let grpahical = config.graphical; +in { imports = [ ../applications/firefox.nix ../applications/nextcloud.nix @@ -9,6 +12,8 @@ ./minimal.nix ]; + graphical.enable = true; + # Enable sound. sound.enable = true; hardware.pulseaudio.enable = true;