mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
237 lines
6.8 KiB
Nix
237 lines
6.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.openvscode-server;
|
|
defaultUser = "openvscode-server";
|
|
defaultGroup = defaultUser;
|
|
in
|
|
{
|
|
options = {
|
|
services.openvscode-server = {
|
|
enable = lib.mkEnableOption "openvscode-server";
|
|
|
|
package = lib.mkPackageOption pkgs "openvscode-server" { };
|
|
|
|
extraPackages = lib.mkOption {
|
|
default = [ ];
|
|
description = ''
|
|
Additional packages to add to the openvscode-server {env}`PATH`.
|
|
'';
|
|
example = lib.literalExpression "[ pkgs.go ]";
|
|
type = lib.types.listOf lib.types.package;
|
|
};
|
|
|
|
extraEnvironment = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.str;
|
|
description = ''
|
|
Additional environment variables to pass to openvscode-server.
|
|
'';
|
|
default = { };
|
|
example = {
|
|
PKG_CONFIG_PATH = "/run/current-system/sw/lib/pkgconfig";
|
|
};
|
|
};
|
|
|
|
extraArguments = lib.mkOption {
|
|
default = [ ];
|
|
description = ''
|
|
Additional arguments to pass to openvscode-server.
|
|
'';
|
|
example = lib.literalExpression ''[ "--log=info" ]'';
|
|
type = lib.types.listOf lib.types.str;
|
|
};
|
|
|
|
host = lib.mkOption {
|
|
default = "localhost";
|
|
description = ''
|
|
The host name or IP address the server should listen to.
|
|
'';
|
|
type = lib.types.str;
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
default = 3000;
|
|
description = ''
|
|
The port the server should listen to. If 0 is passed a random free port is picked. If a range in the format num-num is passed, a free port from the range (end inclusive) is selected.
|
|
'';
|
|
type = lib.types.port;
|
|
};
|
|
|
|
user = lib.mkOption {
|
|
default = defaultUser;
|
|
example = "yourUser";
|
|
description = ''
|
|
The user to run openvscode-server as.
|
|
By default, a user named `${defaultUser}` will be created.
|
|
'';
|
|
type = lib.types.str;
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
default = defaultGroup;
|
|
example = "yourGroup";
|
|
description = ''
|
|
The group to run openvscode-server under.
|
|
By default, a group named `${defaultGroup}` will be created.
|
|
'';
|
|
type = lib.types.str;
|
|
};
|
|
|
|
extraGroups = lib.mkOption {
|
|
default = [ ];
|
|
description = ''
|
|
An array of additional groups for the `${defaultUser}` user.
|
|
'';
|
|
example = [ "docker" ];
|
|
type = lib.types.listOf lib.types.str;
|
|
};
|
|
|
|
withoutConnectionToken = lib.mkOption {
|
|
default = false;
|
|
description = ''
|
|
Run without a connection token. Only use this if the connection is secured by other means.
|
|
'';
|
|
example = true;
|
|
type = lib.types.bool;
|
|
};
|
|
|
|
socketPath = lib.mkOption {
|
|
default = null;
|
|
example = "/run/openvscode/socket";
|
|
description = ''
|
|
The path to a socket file for the server to listen to.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
userDataDir = lib.mkOption {
|
|
default = null;
|
|
description = ''
|
|
Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
serverDataDir = lib.mkOption {
|
|
default = null;
|
|
description = ''
|
|
Specifies the directory that server data is kept in.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
extensionsDir = lib.mkOption {
|
|
default = null;
|
|
description = ''
|
|
Set the root path for extensions.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
telemetryLevel = lib.mkOption {
|
|
default = null;
|
|
example = "crash";
|
|
description = ''
|
|
Sets the initial telemetry level. Valid levels are: 'off', 'crash', 'error' and 'all'.
|
|
'';
|
|
type = lib.types.nullOr (
|
|
lib.types.enum [
|
|
"off"
|
|
"crash"
|
|
"error"
|
|
"all"
|
|
]
|
|
);
|
|
};
|
|
|
|
connectionToken = lib.mkOption {
|
|
default = null;
|
|
example = "secret-token";
|
|
description = ''
|
|
A secret that must be included with all requests.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
connectionTokenFile = lib.mkOption {
|
|
default = null;
|
|
description = ''
|
|
Path to a file that contains the connection token.
|
|
'';
|
|
type = lib.types.nullOr lib.types.str;
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.openvscode-server = {
|
|
description = "OpenVSCode server";
|
|
wantedBy = [ "multi-user.target" ];
|
|
wants = [ "network-online.target" ];
|
|
after = [ "network-online.target" ];
|
|
path = cfg.extraPackages;
|
|
environment = cfg.extraEnvironment;
|
|
serviceConfig = {
|
|
ExecStart =
|
|
''
|
|
${lib.getExe cfg.package} \
|
|
--accept-server-license-terms \
|
|
--host=${cfg.host} \
|
|
--port=${toString cfg.port} \
|
|
''
|
|
+ lib.optionalString (cfg.telemetryLevel != null) ''
|
|
--telemetry-level=${cfg.telemetryLevel} \
|
|
''
|
|
+ lib.optionalString (cfg.withoutConnectionToken) ''
|
|
--without-connection-token \
|
|
''
|
|
+ lib.optionalString (cfg.socketPath != null) ''
|
|
--socket-path=${cfg.socketPath} \
|
|
''
|
|
+ lib.optionalString (cfg.userDataDir != null) ''
|
|
--user-data-dir=${cfg.userDataDir} \
|
|
''
|
|
+ lib.optionalString (cfg.serverDataDir != null) ''
|
|
--server-data-dir=${cfg.serverDataDir} \
|
|
''
|
|
+ lib.optionalString (cfg.extensionsDir != null) ''
|
|
--extensions-dir=${cfg.extensionsDir} \
|
|
''
|
|
+ lib.optionalString (cfg.connectionToken != null) ''
|
|
--connection-token=${cfg.connectionToken} \
|
|
''
|
|
+ lib.optionalString (cfg.connectionTokenFile != null) ''
|
|
--connection-token-file=${cfg.connectionTokenFile} \
|
|
''
|
|
+ lib.escapeShellArgs cfg.extraArguments;
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
RuntimeDirectory = cfg.user;
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
|
|
users.users."${cfg.user}" = lib.mkMerge [
|
|
(lib.mkIf (cfg.user == defaultUser) {
|
|
isNormalUser = true;
|
|
description = "openvscode-server user";
|
|
inherit (cfg) group;
|
|
})
|
|
{
|
|
packages = cfg.extraPackages;
|
|
inherit (cfg) extraGroups;
|
|
}
|
|
];
|
|
|
|
users.groups."${defaultGroup}" = lib.mkIf (cfg.group == defaultGroup) { };
|
|
};
|
|
|
|
meta.maintainers = [ lib.maintainers.drupol ];
|
|
}
|