diff --git a/lib/module/default.nix b/lib/module/default.nix index 4afb956..e32da5b 100644 --- a/lib/module/default.nix +++ b/lib/module/default.nix @@ -122,6 +122,10 @@ rec { port = mkOpt types.int 80 "Port for ${name} redis to be hosted on"; }; + hashedPassword = mkOpt (types.nullOr types.str) "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06" "Hashed password for code-server authentication"; + + extraEnvironment = mkOpt (types.attrsOf types.str) { } "Extra environment variables for code-server"; + reverseProxy = mkReverseProxyOpt; } // options; diff --git a/modules/nixos/services/code-server/default.nix b/modules/nixos/services/code-server/default.nix index 3a3a3cc..f82702b 100644 --- a/modules/nixos/services/code-server/default.nix +++ b/modules/nixos/services/code-server/default.nix @@ -6,32 +6,32 @@ }: with lib; let - cfg = config.${namespace}.services.code-server; -in -{ - imports = [ ./options.nix ]; + name = "code-server"; + cfg = config.${namespace}.services.${name}; - config = mkIf cfg.enable { - # Configure the standard NixOS code-server service - services.code-server = { - enable = true; - port = cfg.port; - user = cfg.user; - group = cfg.group; - host = cfg.host; - auth = cfg.auth; - disableTelemetry = cfg.disableTelemetry; - disableUpdateCheck = cfg.disableUpdateCheck; - extraEnvironment = cfg.extraEnvironment; - } - // optionalAttrs (cfg.hashedPassword != null) { - hashedPassword = cfg.hashedPassword; - }; - - # Open firewall for code-server if enabled - networking.firewall = mkIf cfg.openFirewall { - allowedTCPPorts = [ cfg.port ]; - allowedUDPPorts = [ cfg.port ]; + codeServerConfig = lib.${namespace}.mkModule { + inherit config name; + description = "vscode server"; + options = { }; + moduleConfig = { + # Configure the standard NixOS code-server service + services.code-server = { + enable = true; + port = cfg.port; + user = "nix-apps"; + group = "jallen-nas"; + host = cfg.listenAddress; + auth = "none"; # "password" + disableTelemetry = true; + disableUpdateCheck = true; + extraEnvironment = cfg.extraEnvironment; + } + // optionalAttrs (cfg.hashedPassword != null) { + hashedPassword = cfg.hashedPassword; + }; }; }; +in +{ + imports = [ codeServerConfig ]; } diff --git a/modules/nixos/services/code-server/options.nix b/modules/nixos/services/code-server/options.nix deleted file mode 100644 index 507136b..0000000 --- a/modules/nixos/services/code-server/options.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ lib, namespace, ... }: -with lib; -{ - options.${namespace}.services.code-server = { - enable = mkEnableOption "code-server with enhanced configuration"; - - port = mkOption { - type = types.port; - default = 4444; - description = "Port for code-server"; - }; - - openFirewall = mkOption { - type = types.bool; - default = true; - description = "Whether to open firewall for code-server"; - }; - - user = mkOption { - type = types.str; - default = "admin"; - description = "User to run code-server as"; - }; - - group = mkOption { - type = types.str; - default = "users"; - description = "Group to run code-server as"; - }; - - host = mkOption { - type = types.str; - default = "0.0.0.0"; - description = "Host to bind code-server to"; - }; - - auth = mkOption { - type = types.enum [ - "none" - "password" - ]; - default = "none"; - description = "Authentication method for code-server"; - }; - - hashedPassword = mkOption { - type = types.nullOr types.str; - default = null; - description = "Hashed password for code-server authentication"; - }; - - extraEnvironment = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Extra environment variables for code-server"; - }; - - disableTelemetry = mkOption { - type = types.bool; - default = true; - description = "Whether to disable telemetry"; - }; - - disableUpdateCheck = mkOption { - type = types.bool; - default = true; - description = "Whether to disable update checks"; - }; - }; -} diff --git a/systems/x86_64-linux/jallen-nas/apps.nix b/systems/x86_64-linux/jallen-nas/apps.nix index 48acb1e..14f0729 100755 --- a/systems/x86_64-linux/jallen-nas/apps.nix +++ b/systems/x86_64-linux/jallen-nas/apps.nix @@ -52,11 +52,6 @@ in code-server = { enable = true; port = 4444; - user = "admin"; - group = "jallen-nas"; - host = "0.0.0.0"; - auth = "none"; - hashedPassword = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; extraEnvironment = { PROXY_DOMAIN = "code.mjallen.dev"; };