From 0cedd85f4fa4bc41f5bfcfdb39911f3ee6322eac Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 23 Jan 2024 15:36:52 -0600 Subject: [PATCH] use options for langs --- hosts/othalan/default.nix | 15 +++++++++------ lib/default.nix | 1 + modules/langs/misc.nix | 14 ++++++++------ modules/langs/nim.nix | 12 ++++++++---- modules/langs/node.nix | 12 ++++++++++-- modules/langs/python.nix | 12 +++++++++++- modules/langs/tex.nix | 12 ++++++++---- modules/roles/common.nix | 4 ++++ modules/roles/desktop.nix | 2 -- 9 files changed, 59 insertions(+), 25 deletions(-) diff --git a/hosts/othalan/default.nix b/hosts/othalan/default.nix index 2ae977c..e8f4fdb 100644 --- a/hosts/othalan/default.nix +++ b/hosts/othalan/default.nix @@ -12,15 +12,18 @@ virtualization restic - - # langs - misc - nim - node - tex ]; + services.vpn.enable = true; + languages = { + misc.enable = true; + python.enable = true; + nim.enable = true; + tex.enable = true; + node.enable = true; + }; + services.restic.backups.gdrive = { user = "daylin"; diff --git a/lib/default.nix b/lib/default.nix index 8c33717..9b06872 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -13,6 +13,7 @@ in rec { nixosSystem { system = "x86_64-linux"; modules = + [ ../modules/roles/common.nix ] ++ builtins.filter isNixFile (listFilesRecursive (../. + "/hosts/${hostname}")); specialArgs = {inherit inputs;}; }; diff --git a/modules/langs/misc.nix b/modules/langs/misc.nix index 03c2e96..9366a0f 100644 --- a/modules/langs/misc.nix +++ b/modules/langs/misc.nix @@ -1,12 +1,14 @@ +{config, lib,pkgs,...}: +let + inherit (lib) mkEnableOption mkIf; + cfg = config.languages.misc; +in { - inputs, - pkgs, - ... -}: { + options.languages.misc.enable = mkEnableOption "go + rustup"; + config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ - # language supports - nodejs go rustup ]; +}; } diff --git a/modules/langs/nim.nix b/modules/langs/nim.nix index 7d1b693..f1cffae 100644 --- a/modules/langs/nim.nix +++ b/modules/langs/nim.nix @@ -1,8 +1,11 @@ +{nixpkgs,config, lib,pkgs,...}: +let + inherit (lib) mkEnableOption mkIf; + cfg = config.languages.nim; +in { - pkgs, - nixpkgs, - ... -}: { + options.languages.nim.enable = mkEnableOption "nim"; + config = mkIf cfg.enable { nixpkgs.overlays = [ # (import ../../overlays/nim {}) (import ../../overlays/nimlsp {}) @@ -16,4 +19,5 @@ nimble nimlsp ]; +}; } diff --git a/modules/langs/node.nix b/modules/langs/node.nix index 30a14fb..61b9043 100644 --- a/modules/langs/node.nix +++ b/modules/langs/node.nix @@ -1,6 +1,14 @@ -{pkgs, ...}: { +{config, lib,pkgs,...}: +let + inherit (lib) mkEnableOption mkIf; + cfg = config.languages.node; +in +{ + options.languages.node.enable = mkEnableOption "node"; + config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ - nodejs + nodejs nodePackages.pnpm ]; +}; } diff --git a/modules/langs/python.nix b/modules/langs/python.nix index 148c42f..01c82a6 100644 --- a/modules/langs/python.nix +++ b/modules/langs/python.nix @@ -1,4 +1,12 @@ -{pkgs, ...}: { +{config, lib,pkgs,...}: +let + inherit (lib) mkEnableOption mkIf; + cfg = config.languages.python; +in +{ + options.languages.python.enable = mkEnableOption "python"; + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ # https://github.com/Mic92/nix-ld?tab=readme-ov-file#my-pythonnodejsrubyinterpreter-libraries-do-not-find-the-libraries-configured-by-nix-ld (pkgs.writeShellScriptBin "python" '' @@ -14,4 +22,6 @@ (python3.withPackages (ps: with ps; [pip])) micromamba ]; + +}; } diff --git a/modules/langs/tex.nix b/modules/langs/tex.nix index 9559aa5..d16b499 100644 --- a/modules/langs/tex.nix +++ b/modules/langs/tex.nix @@ -1,9 +1,13 @@ +{config, lib,pkgs,...}: +let + inherit (lib) mkEnableOption mkIf; + cfg = config.languages.tex; +in { - inputs, - pkgs, - ... -}: { + options.languages.tex.enable = mkEnableOption "tex"; + config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ texlive.combined.scheme-full ]; +}; } diff --git a/modules/roles/common.nix b/modules/roles/common.nix index 036e776..bcc6c3d 100644 --- a/modules/roles/common.nix +++ b/modules/roles/common.nix @@ -7,5 +7,9 @@ # langs python + misc + node + tex + nim ]; } diff --git a/modules/roles/desktop.nix b/modules/roles/desktop.nix index 3276918..bf185a2 100644 --- a/modules/roles/desktop.nix +++ b/modules/roles/desktop.nix @@ -5,10 +5,8 @@ ... }: { imports = with inputs.self.nixosModules; [ - common gui vscode vpn - # qtile ]; }