From 6e3aa008df30caf6c00f0a39f33e26833988ab89 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 27 Feb 2024 10:11:44 -0600 Subject: [PATCH] namespace options under oizys --- hosts/algiz/default.nix | 1 - hosts/mannaz/default.nix | 2 +- hosts/othalan/default.nix | 23 ++++++++++++----------- modules/common.nix | 9 ++------- modules/desktop/fonts.nix | 2 +- modules/desktop/gui.nix | 2 +- modules/development/cli.nix | 11 ++++++++--- modules/editors/vscode.nix | 2 +- modules/langs/misc.nix | 17 ----------------- modules/langs/tex.nix | 16 ---------------- modules/languages/default.nix | 24 ++++++++++++++++++++++++ modules/languages/misc.nix | 16 ++++++++++++++++ modules/{langs => languages}/nim.nix | 7 +++---- modules/{langs => languages}/node.nix | 7 +++---- modules/{langs => languages}/python.nix | 7 +++---- modules/languages/tex.nix | 16 ++++++++++++++++ modules/networking/vpn.nix | 6 +++--- 17 files changed, 94 insertions(+), 74 deletions(-) delete mode 100644 modules/langs/misc.nix delete mode 100644 modules/langs/tex.nix create mode 100644 modules/languages/default.nix create mode 100644 modules/languages/misc.nix rename modules/{langs => languages}/nim.nix (53%) rename modules/{langs => languages}/node.nix (50%) rename modules/{langs => languages}/python.nix (83%) create mode 100644 modules/languages/tex.nix diff --git a/hosts/algiz/default.nix b/hosts/algiz/default.nix index 5d733f4..c98298d 100644 --- a/hosts/algiz/default.nix +++ b/hosts/algiz/default.nix @@ -12,7 +12,6 @@ nim = true; python = true; }; - cli.enable = true; environment.systemPackages = with pkgs; [ rclone diff --git a/hosts/mannaz/default.nix b/hosts/mannaz/default.nix index ce62397..e8e0114 100644 --- a/hosts/mannaz/default.nix +++ b/hosts/mannaz/default.nix @@ -3,7 +3,7 @@ nix-ld ]; - desktop.enable = true; + oizys.desktop.enable = true; cli.enable = true; # Enable the X11 windowing system. services.xserver = { diff --git a/hosts/othalan/default.nix b/hosts/othalan/default.nix index 7d25624..53556b2 100644 --- a/hosts/othalan/default.nix +++ b/hosts/othalan/default.nix @@ -10,17 +10,20 @@ docker ]; - cli.enable = true; - desktop.enable = true; + oizys = { + desktop.enable = true; + vpn.enable = true; + languages = [ + "misc" + "python" + "nim" + "tex" + "node" + ]; + }; vivaldi.enable = true; - languages = { - misc = true; - python = true; - nim = true; - tex = true; - node = true; - }; + environment.systemPackages = with pkgs; [ zk @@ -30,8 +33,6 @@ programs.hyprland.enable = true; - services.vpn.enable = true; - services.restic.backups.gdrive = { user = "daylin"; repository = "rclone:g:archives/othalan"; diff --git a/modules/common.nix b/modules/common.nix index 6c195b8..e20e388 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -21,17 +21,12 @@ gui - # langs - python - misc - node - tex - nim + languages # programs vivaldi vscode ]; - options.desktop.enable = lib.mkEnableOption "is desktop"; + options.oizys.desktop.enable = lib.mkEnableOption "is desktop"; } diff --git a/modules/desktop/fonts.nix b/modules/desktop/fonts.nix index d95632a..0922e00 100644 --- a/modules/desktop/fonts.nix +++ b/modules/desktop/fonts.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib) mkIf; - cfg = config.desktop; + cfg = config.oizys.desktop; in { config = mkIf cfg.enable { fonts.fontconfig.enable = true; diff --git a/modules/desktop/gui.nix b/modules/desktop/gui.nix index 0753030..6677bdc 100644 --- a/modules/desktop/gui.nix +++ b/modules/desktop/gui.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib) mkIf; - cfg = config.desktop; + cfg = config.oizys.desktop; in { config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/development/cli.nix b/modules/development/cli.nix index 153ad14..330f3be 100644 --- a/modules/development/cli.nix +++ b/modules/development/cli.nix @@ -4,10 +4,15 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; - cfg = config.cli; + inherit (lib) mkOption mkIf types; + cfg = config.oizys.cli; in { - options.cli.enable = mkEnableOption "cli"; + options.oizys.cli.enable = mkOption { + default = true; + description = "Whether to enable cli."; + type = types.bool; + }; + config = mkIf cfg.enable { programs.direnv.enable = true; environment.sessionVariables = { diff --git a/modules/editors/vscode.nix b/modules/editors/vscode.nix index 6fa19ab..6102c4c 100644 --- a/modules/editors/vscode.nix +++ b/modules/editors/vscode.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib) mkIf; - cfg = config.desktop; + cfg = config.oizys.desktop; in { config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/langs/misc.nix b/modules/langs/misc.nix deleted file mode 100644 index 3326cbd..0000000 --- a/modules/langs/misc.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib) mkEnableOption mkIf; - cfg = config.languages; -in { - options.languages.misc = mkEnableOption "go + rustup"; - config = mkIf cfg.misc { - environment.systemPackages = with pkgs; [ - go - rustup - ]; - }; -} diff --git a/modules/langs/tex.nix b/modules/langs/tex.nix deleted file mode 100644 index 1127a32..0000000 --- a/modules/langs/tex.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib) mkEnableOption mkIf; - cfg = config.languages; -in { - options.languages.tex = mkEnableOption "tex"; - config = mkIf cfg.tex { - environment.systemPackages = with pkgs; [ - texlive.combined.scheme-full - ]; - }; -} diff --git a/modules/languages/default.nix b/modules/languages/default.nix new file mode 100644 index 0000000..43e95f1 --- /dev/null +++ b/modules/languages/default.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkOption types literalExpression mdDoc; + cfg = config.oizys.languages; +in { + imports = [./nim.nix ./tex.nix ./misc.nix ./node.nix ./python.nix]; + options.oizys.languages = mkOption { + type = with types; nullOr (listOf str); + description = lib.mdDoc '' + List of programming languages to enable. + ''; + default = null; + example = literalExpression '' + [ + "python" + "nim" + ] + ''; + }; +} diff --git a/modules/languages/misc.nix b/modules/languages/misc.nix new file mode 100644 index 0000000..3472f93 --- /dev/null +++ b/modules/languages/misc.nix @@ -0,0 +1,16 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkIf; + cfg = config.oizys.languages; +in { + config = mkIf (builtins.elem "misc" cfg) { + environment.systemPackages = with pkgs; [ + go + rustup + ]; + }; +} diff --git a/modules/langs/nim.nix b/modules/languages/nim.nix similarity index 53% rename from modules/langs/nim.nix rename to modules/languages/nim.nix index 541eda2..f4844d6 100644 --- a/modules/langs/nim.nix +++ b/modules/languages/nim.nix @@ -4,11 +4,10 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; - cfg = config.languages; + inherit (lib) mkIf; + cfg = config.oizys.languages; in { - options.languages.nim = mkEnableOption "nim"; - config = mkIf cfg.nim { + config = mkIf (builtins.elem "nim" cfg) { environment.systemPackages = with pkgs; [ nim diff --git a/modules/langs/node.nix b/modules/languages/node.nix similarity index 50% rename from modules/langs/node.nix rename to modules/languages/node.nix index d11fac9..d1c2f1b 100644 --- a/modules/langs/node.nix +++ b/modules/languages/node.nix @@ -4,11 +4,10 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; - cfg = config.languages; + inherit (lib) mkIf; + cfg = config.oizys.languages; in { - options.languages.node = mkEnableOption "node"; - config = mkIf cfg.node { + config = mkIf (builtins.elem "node" cfg) { environment.systemPackages = with pkgs; [ nodejs nodePackages.pnpm diff --git a/modules/langs/python.nix b/modules/languages/python.nix similarity index 83% rename from modules/langs/python.nix rename to modules/languages/python.nix index 3b8583f..d15a626 100644 --- a/modules/langs/python.nix +++ b/modules/languages/python.nix @@ -4,11 +4,10 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; - cfg = config.languages; + inherit (lib) mkIf; + cfg = config.oizys.languages; in { - options.languages.python = mkEnableOption "python"; - config = mkIf cfg.python { + config = mkIf (builtins.elem "python" cfg) { environment.systemPackages = let python = pkgs.python3.withPackages (ps: with ps; [pip]); in diff --git a/modules/languages/tex.nix b/modules/languages/tex.nix new file mode 100644 index 0000000..3bf95a5 --- /dev/null +++ b/modules/languages/tex.nix @@ -0,0 +1,16 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkIf; + # cfg = config.oizys.languages; + langEnabled = name: builtins.elem name config.oizys.languages; +in { + config = mkIf (langEnabled "tex") { + environment.systemPackages = with pkgs; [ + texlive.combined.scheme-full + ]; + }; +} diff --git a/modules/networking/vpn.nix b/modules/networking/vpn.nix index 328738b..685c847 100644 --- a/modules/networking/vpn.nix +++ b/modules/networking/vpn.nix @@ -5,10 +5,10 @@ ... }: let inherit (lib) mkEnableOption mkIf; - cfg = config.services.vpn; + cfg = config.oizys.vpn; in { - options.services.vpn.enable = mkEnableOption '' - use openconnect vpn + options.oizys.vpn.enable = mkEnableOption '' + Whether to enable openconnect for vpn connection. ''; config = mkIf cfg.enable {