From 8023a1e3b0fe1b574651180f35ff1a8c84fe7099 Mon Sep 17 00:00:00 2001 From: "Simon W. Jackson" Date: Mon, 20 May 2024 14:59:07 -0500 Subject: [PATCH] chore: add default nixos module --- modules/nixos/default/default.nix | 67 ++----------------------------- modules/nixos/tmesh/default.nix | 64 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 63 deletions(-) create mode 100644 modules/nixos/tmesh/default.nix diff --git a/modules/nixos/default/default.nix b/modules/nixos/default/default.nix index a4b7fef..fd3f4d6 100644 --- a/modules/nixos/default/default.nix +++ b/modules/nixos/default/default.nix @@ -1,64 +1,5 @@ -{ - config, - inputs, - lib, - pkgs, - ... -}: let - inherit (pkgs.stdenv.hostPlatform) system; - pname = "tmesh"; - - package = inputs.self.packages.${system}.${pname}; - cfg = config.programs.${pname}; - jsonConfig = builtins.toJSON cfg.settings; - jsonConfigFile = pkgs.writeText "config.json" jsonConfig; -in { - options.programs.${pname} = { - enable = lib.mkEnableOption "${pname}"; - - settings = lib.mkOption { - type = lib.types.attrs; - default = {}; - description = "Configuration settings."; - }; - - package = lib.mkOption { - type = lib.types.package; - default = package; - description = "The package to use for ${pname}."; - }; - - tmeshServerTmuxConfig = lib.mkOption { - type = lib.types.lines; - default = ""; - description = "Tmux configuration for tmesh server."; - }; - - tmeshTmuxConfig = lib.mkOption { - type = lib.types.lines; - default = ""; - description = "Tmux configuration for tmesh."; - }; - }; - - config = lib.mkIf cfg.enable { - environment.etc."${pname}/config.json".source = jsonConfigFile; - - environment.etc."${pname}/tmesh-server.tmux.conf" = { - text = cfg.tmeshServerTmuxConfig; - mode = "0644"; - }; - - environment.etc."${pname}/tmesh.tmux.conf" = { - text = cfg.tmeshTmuxConfig; - mode = "0644"; - }; - - environment.systemPackages = [ - (pkgs.writeScriptBin "${pname}" '' - #!${pkgs.stdenv.shell} - exec ${pkgs.lib.meta.getExe cfg.package} --config ${jsonConfigFile} "$@" - '') - ]; - }; +{...}: { + import = [ + ../tmesh + ]; } diff --git a/modules/nixos/tmesh/default.nix b/modules/nixos/tmesh/default.nix new file mode 100644 index 0000000..a4b7fef --- /dev/null +++ b/modules/nixos/tmesh/default.nix @@ -0,0 +1,64 @@ +{ + config, + inputs, + lib, + pkgs, + ... +}: let + inherit (pkgs.stdenv.hostPlatform) system; + pname = "tmesh"; + + package = inputs.self.packages.${system}.${pname}; + cfg = config.programs.${pname}; + jsonConfig = builtins.toJSON cfg.settings; + jsonConfigFile = pkgs.writeText "config.json" jsonConfig; +in { + options.programs.${pname} = { + enable = lib.mkEnableOption "${pname}"; + + settings = lib.mkOption { + type = lib.types.attrs; + default = {}; + description = "Configuration settings."; + }; + + package = lib.mkOption { + type = lib.types.package; + default = package; + description = "The package to use for ${pname}."; + }; + + tmeshServerTmuxConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Tmux configuration for tmesh server."; + }; + + tmeshTmuxConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Tmux configuration for tmesh."; + }; + }; + + config = lib.mkIf cfg.enable { + environment.etc."${pname}/config.json".source = jsonConfigFile; + + environment.etc."${pname}/tmesh-server.tmux.conf" = { + text = cfg.tmeshServerTmuxConfig; + mode = "0644"; + }; + + environment.etc."${pname}/tmesh.tmux.conf" = { + text = cfg.tmeshTmuxConfig; + mode = "0644"; + }; + + environment.systemPackages = [ + (pkgs.writeScriptBin "${pname}" '' + #!${pkgs.stdenv.shell} + exec ${pkgs.lib.meta.getExe cfg.package} --config ${jsonConfigFile} "$@" + '') + ]; + }; +}