mkModule code-server
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 ];
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user