From 94613c579e92ac34ede918a3d09e0fcc5b74194e Mon Sep 17 00:00:00 2001 From: James Patrick Date: Thu, 24 Mar 2022 00:00:26 -0400 Subject: [PATCH] Refactor --- modules/applications/emacs.nix | 9 ++-- modules/applications/firefox.nix | 10 ++-- modules/applications/kitty.nix | 8 ++-- modules/applications/nextcloud.nix | 9 ++-- modules/applications/sway/dunst.nix | 8 ++-- modules/applications/sway/gammastep.nix | 8 ++-- modules/applications/sway/mako.nix | 26 ++-------- modules/applications/sway/sway.nix | 63 ++++++++++++------------- modules/applications/sway/waybar.nix | 10 ++-- modules/default.nix | 13 ++--- modules/lang/bash.nix | 8 ++-- modules/lang/golang.nix | 8 ++-- modules/lang/javascript.nix | 8 ++-- modules/system/boot.nix | 10 ++-- modules/system/displaymanager.nix | 8 ++-- modules/system/flatpak.nix | 9 ++-- modules/system/xdg.nix | 3 -- modules/system/zfs.nix | 8 +--- 18 files changed, 84 insertions(+), 142 deletions(-) diff --git a/modules/applications/emacs.nix b/modules/applications/emacs.nix index e926435..90bd566 100644 --- a/modules/applications/emacs.nix +++ b/modules/applications/emacs.nix @@ -6,12 +6,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.application.emacs = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - description = "Insert joke about emacs is an operating system."; - }; + this.application.emacs.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 31a2623..12c69d8 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -5,12 +5,10 @@ let sway_cfg = config.this.application.sway; in with lib; { options = { - this.application.firefox = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - description = ""; - }; + this.application.firefox.enable = mkOption { + default = graphical.enable; + type = with types; bool; + description = ""; }; }; diff --git a/modules/applications/kitty.nix b/modules/applications/kitty.nix index c34ca20..579cd06 100644 --- a/modules/applications/kitty.nix +++ b/modules/applications/kitty.nix @@ -4,11 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.application.kitty = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + this.application.kitty.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/applications/nextcloud.nix b/modules/applications/nextcloud.nix index 99bf1d5..3d511c1 100644 --- a/modules/applications/nextcloud.nix +++ b/modules/applications/nextcloud.nix @@ -4,12 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.application.nextcloud = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - description = "Dropbox for people who don't like dropbox"; - }; + this.application.nextcloud.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/applications/sway/dunst.nix b/modules/applications/sway/dunst.nix index c49264f..2504581 100644 --- a/modules/applications/sway/dunst.nix +++ b/modules/applications/sway/dunst.nix @@ -4,11 +4,9 @@ let sway = config.this.application.sway; in with lib; { options = { - this.application.dunst = { - enable = mkOption { - default = sway.enable; - type = with types; bool; - }; + this.application.dunst.enable = mkOption { + default = sway.enable; + type = with types; bool; }; }; diff --git a/modules/applications/sway/gammastep.nix b/modules/applications/sway/gammastep.nix index 3c5117b..0bb3adc 100644 --- a/modules/applications/sway/gammastep.nix +++ b/modules/applications/sway/gammastep.nix @@ -4,11 +4,9 @@ let sway = config.this.application.sway; in with lib; { options = { - this.application.gammastep = { - enable = mkOption { - default = sway.enable; - type = with types; bool; - }; + this.application.gammastep.enable = mkOption { + default = sway.enable; + type = with types; bool; }; }; diff --git a/modules/applications/sway/mako.nix b/modules/applications/sway/mako.nix index 64bc332..4c8250f 100644 --- a/modules/applications/sway/mako.nix +++ b/modules/applications/sway/mako.nix @@ -4,12 +4,10 @@ let sway = config.this.application.sway; in with lib; { options = { - this.application.mako = { - enable = mkOption { - default = false; - type = with types; bool; - description = "testing one two three"; - }; + this.application.mako.enable = mkOption { + default = false; + type = with types; bool; + description = "testing one two three"; }; }; @@ -63,21 +61,5 @@ in with lib; { Restart = "always"; }; }; - - # systemd.user.services.mako = { - # enable = true; - # description = "Mako - Notificaitons for Wayland"; - # documentation = [ "man:mako(5)" ]; - # partOf = [ "sway-session.target" ]; - # bindsTo = [ "sway-session.target" ]; - # environment.PATH = lib.mkForce null; - # serviceConfig = { - # ExecStart = "${pkgs.mako}/bin/mako"; - # Restart = "on-failure"; - # RestartSec = 1; - # TimeoutStopSec = 10; - # Type = "simple"; - # }; - # }; }; } diff --git a/modules/applications/sway/sway.nix b/modules/applications/sway/sway.nix index dfac3b2..9d5d664 100644 --- a/modules/applications/sway/sway.nix +++ b/modules/applications/sway/sway.nix @@ -15,16 +15,13 @@ let scripts = [ brightness-sh sway-entry volume-sh ]; in with lib; { options = { - this.application.sway = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + this.application.sway.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; config = mkIf cfg.enable { - this.graphical.protocol = "Wayland"; home-manager.users.james = { @@ -139,33 +136,33 @@ in with lib; { wrapperFeatures.gtk = true; }; - systemd.user.targets.sway-session = { - description = "Sway compositor session"; - documentation = [ "man:systemd.special(7)" ]; - bindsTo = [ "graphical-session.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - }; - systemd.user.services.sway = { - enable = true; - description = "Sway - Wayland window manager"; - documentation = [ "man:sway(5)" ]; - bindsTo = [ "default.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - # We explicitly unset PATH here, as we want it to be set by - # systemctl --user import-environment in startsway - environment.PATH = lib.mkForce null; - serviceConfig = { - Type = "simple"; - ExecStart = - "${pkgs.dbus}/bin/dbus-run-session ${pkgs.sway}/bin/sway --debug"; - ExecStopPost = - "/usr/bin/env systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY"; - NotifyAccess = "all"; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; + systemd.user = { + targets.sway-session = { + description = "Sway compositor session"; + documentation = [ "man:systemd.special(7)" ]; + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + }; + services.sway = { + enable = true; + description = "Sway - Wayland window manager"; + documentation = [ "man:sway(5)" ]; + bindsTo = [ "default.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + environment.PATH = lib.mkForce null; + serviceConfig = { + Type = "simple"; + ExecStart = + "${pkgs.dbus}/bin/dbus-run-session ${pkgs.sway}/bin/sway --debug"; + ExecStopPost = + "/usr/bin/env systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY"; + NotifyAccess = "all"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; }; }; diff --git a/modules/applications/sway/waybar.nix b/modules/applications/sway/waybar.nix index c3a83d3..5ab28c3 100644 --- a/modules/applications/sway/waybar.nix +++ b/modules/applications/sway/waybar.nix @@ -4,12 +4,10 @@ let sway_cfg = config.this.application.sway; in with lib; { options = { - this.application.waybar = { - enable = mkOption { - default = sway_cfg.enable; - type = with types; bool; - description = "testing one two three"; - }; + this.application.waybar.enable = mkOption { + default = sway_cfg.enable; + type = with types; bool; + description = "testing one two three"; }; }; diff --git a/modules/default.nix b/modules/default.nix index 817496b..80e3cdb 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,9 +1,10 @@ -{ config, pkgs, lib, ... }: { - options.this.graphical.enable = lib.mkOption { - default = false; - type = with lib.types; bool; - description = "Does this actually need X/Wayland"; - }; +{ config, pkgs, lib, ... }: +with lib; +let +in { + + options.this.graphical.enable = + mkEnableOption "Does this actually need X/Wayland"; options.this.graphical.protocol = mkOption { type = types.enum [ "X11" "Wayland" ]; diff --git a/modules/lang/bash.nix b/modules/lang/bash.nix index d717e20..442a908 100644 --- a/modules/lang/bash.nix +++ b/modules/lang/bash.nix @@ -4,11 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.lang.bash = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + this.lang.bash.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/lang/golang.nix b/modules/lang/golang.nix index 9971428..d231adf 100644 --- a/modules/lang/golang.nix +++ b/modules/lang/golang.nix @@ -4,11 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.lang.golang = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + this.lang.golang.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/lang/javascript.nix b/modules/lang/javascript.nix index 7ba6586..825c217 100644 --- a/modules/lang/javascript.nix +++ b/modules/lang/javascript.nix @@ -4,11 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - this.lang.javascript = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + this.lang.javascript.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/system/boot.nix b/modules/system/boot.nix index 19f4ae6..9bd3c30 100644 --- a/modules/system/boot.nix +++ b/modules/system/boot.nix @@ -1,12 +1,10 @@ { config, lib, pkgs, ... }: let cfg = config.this.systems.boot; in with lib; { - options.this.systems.boot = { - enable = mkOption { - default = true; - type = with types; bool; - description = "Is there a physical power button?"; - }; + options.this.systems.boot.enable = mkOption { + default = true; + type = with types; bool; + description = "Is there a physical power button?"; }; config = mkIf cfg.enable { diff --git a/modules/system/displaymanager.nix b/modules/system/displaymanager.nix index 95b79d5..3213060 100644 --- a/modules/system/displaymanager.nix +++ b/modules/system/displaymanager.nix @@ -4,11 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - systems.displaymanager = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - }; + systems.displaymanager.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/system/flatpak.nix b/modules/system/flatpak.nix index e1c34d2..f65c7c1 100644 --- a/modules/system/flatpak.nix +++ b/modules/system/flatpak.nix @@ -4,12 +4,9 @@ let graphical = config.this.graphical; in with lib; { options = { - systems.flatpak = { - enable = mkOption { - default = graphical.enable; - type = with types; bool; - description = "When they tried to do docker for GUIs"; - }; + systems.flatpak.enable = mkOption { + default = graphical.enable; + type = with types; bool; }; }; diff --git a/modules/system/xdg.nix b/modules/system/xdg.nix index 1e13e34..ea04369 100644 --- a/modules/system/xdg.nix +++ b/modules/system/xdg.nix @@ -1,6 +1,3 @@ -# This was cribed from Hlisser's dotfiles see here -# https://github.com/hlissner/dotfiles/blob/8fe1fbb6e7fc0d2f95fe75cdb9df7eb0595a0047/modules/xdg.nix - { config, pkgs, ... }: { home-manager.users.james = { home.packages = with pkgs; [ xdg-utils xdg-launch ]; diff --git a/modules/system/zfs.nix b/modules/system/zfs.nix index 6258210..7ddf8a6 100644 --- a/modules/system/zfs.nix +++ b/modules/system/zfs.nix @@ -1,13 +1,7 @@ { config, lib, pkgs, ... }: let cfg = config.this.systems.zfs; in with lib; { - options.this.systems.zfs = { - enable = mkOption { - default = false; - type = with types; bool; - description = "enable zfs"; - }; - }; + options.this.systems.zfs.enable = mkEnableOption "zfs"; config = mkIf cfg.enable { boot = {