Commit 72911a99 authored by Raito Bezarius's avatar Raito Bezarius
Browse files

code-server: drop

Depends on Node.js 16 and cannot be trivially upgraded to Node.js 18.
parent a2976db9
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1240,7 +1240,6 @@
  ./services/web-apps/changedetection-io.nix
  ./services/web-apps/chatgpt-retrieval-plugin.nix
  ./services/web-apps/cloudlog.nix
  ./services/web-apps/code-server.nix
  ./services/web-apps/convos.nix
  ./services/web-apps/dex.nix
  ./services/web-apps/discourse.nix
+0 −259
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:

let
  cfg = config.services.code-server;
  defaultUser = "code-server";
  defaultGroup = defaultUser;
in {
  options = {
    services.code-server = {
      enable = lib.mkEnableOption (lib.mdDoc "code-server");

      package = lib.mkPackageOptionMD pkgs "code-server" {
        example = ''
          pkgs.vscode-with-extensions.override {
            vscode = pkgs.code-server;
            vscodeExtensions = with pkgs.vscode-extensions; [
              bbenoist.nix
              dracula-theme.theme-dracula
            ];
          }
        '';
      };

      extraPackages = lib.mkOption {
        default = [ ];
        description = lib.mdDoc ''
          Additional packages to add to the code-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 = lib.mdDoc ''
          Additional environment variables to pass to code-server.
        '';
        default = { };
        example = { PKG_CONFIG_PATH = "/run/current-system/sw/lib/pkgconfig"; };
      };

      extraArguments = lib.mkOption {
        default = [ ];
        description = lib.mdDoc ''
          Additional arguments to pass to code-server.
        '';
        example = lib.literalExpression ''[ "--log=info" ]'';
        type = lib.types.listOf lib.types.str;
      };

      host = lib.mkOption {
        default = "localhost";
        description = lib.mdDoc ''
          The host name or IP address the server should listen to.
        '';
        type = lib.types.str;
      };

      port = lib.mkOption {
        default = 4444;
        description = lib.mdDoc ''
          The port the server should listen to.
        '';
        type = lib.types.port;
      };

      auth = lib.mkOption {
        default = "password";
        description = lib.mdDoc ''
          The type of authentication to use.
        '';
        type = lib.types.enum [ "none" "password" ];
      };

      hashedPassword = lib.mkOption {
        default = "";
        description = lib.mdDoc ''
          Create the password with: `echo -n 'thisismypassword' | npx argon2-cli -e`.
        '';
        type = lib.types.str;
      };

      user = lib.mkOption {
        default = defaultUser;
        example = "yourUser";
        description = lib.mdDoc ''
          The user to run code-server as.
          By default, a user named `${defaultUser}` will be created.
        '';
        type = lib.types.str;
      };

      group = lib.mkOption {
        default = defaultGroup;
        example = "yourGroup";
        description = lib.mdDoc ''
          The group to run code-server under.
          By default, a group named `${defaultGroup}` will be created.
        '';
        type = lib.types.str;
      };

      extraGroups = lib.mkOption {
        default = [ ];
        description = lib.mdDoc ''
          An array of additional groups for the `${defaultUser}` user.
        '';
        example = [ "docker" ];
        type = lib.types.listOf lib.types.str;
      };

      socket = lib.mkOption {
        default = null;
        example = "/run/code-server/socket";
        description = lib.mdDoc ''
          Path to a socket (bind-addr will be ignored).
        '';
        type = lib.types.nullOr lib.types.str;
      };

      socketMode = lib.mkOption {
        default = null;
        description = lib.mdDoc ''
           File mode of the socket.
        '';
        type = lib.types.nullOr lib.types.str;
      };

      userDataDir = lib.mkOption {
        default = null;
        description = lib.mdDoc ''
          Path to the user data directory.
        '';
        type = lib.types.nullOr lib.types.str;
      };

      extensionsDir = lib.mkOption {
        default = null;
        description = lib.mdDoc ''
          Path to the extensions directory.
        '';
        type = lib.types.nullOr lib.types.str;
      };

      proxyDomain = lib.mkOption {
        default = null;
        example = "code-server.lan";
        description = lib.mdDoc ''
          Domain used for proxying ports.
        '';
        type = lib.types.nullOr lib.types.str;
      };

      disableTelemetry = lib.mkOption {
        default = false;
        example = true;
        description = lib.mdDoc ''
          Disable telemetry.
        '';
        type = lib.types.bool;
      };

      disableUpdateCheck = lib.mkOption {
        default = false;
        example = true;
        description = lib.mdDoc ''
          Disable update check.
          Without this flag, code-server checks every 6 hours against the latest github release and
          then notifies you once every week that a new release is available.
        '';
        type = lib.types.bool;
      };

      disableFileDownloads = lib.mkOption {
        default = false;
        example = true;
        description = lib.mdDoc ''
          Disable file downloads from Code.
        '';
        type = lib.types.bool;
      };

      disableWorkspaceTrust = lib.mkOption {
        default = false;
        example = true;
        description = lib.mdDoc ''
          Disable Workspace Trust feature.
        '';
        type = lib.types.bool;
      };

      disableGettingStartedOverride = lib.mkOption {
        default = false;
        example = true;
        description = lib.mdDoc ''
          Disable the coder/coder override in the Help: Getting Started page.
        '';
        type = lib.types.bool;
      };

    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.code-server = {
      description = "Code server";
      wantedBy = [ "multi-user.target" ];
      after = [ "network-online.target" ];
      path = cfg.extraPackages;
      environment = {
        HASHED_PASSWORD = cfg.hashedPassword;
      } // cfg.extraEnvironment;
      serviceConfig = {
        ExecStart = ''
          ${lib.getExe cfg.package} \
            --auth=${cfg.auth} \
            --bind-addr=${cfg.host}:${toString cfg.port} \
          '' + lib.optionalString (cfg.socket != null) ''
            --socket=${cfg.socket} \
          '' + lib.optionalString (cfg.userDataDir != null) ''
            --user-data-dir=${cfg.userDataDir} \
          '' + lib.optionalString (cfg.extensionsDir != null) ''
            --extensions-dir=${cfg.extensionsDir} \
          '' + lib.optionalString (cfg.disableTelemetry == true) ''
            --disable-telemetry \
          '' + lib.optionalString (cfg.disableUpdateCheck == true) ''
            --disable-update-check \
          '' + lib.optionalString (cfg.disableFileDownloads == true) ''
            --disable-file-downloads \
          '' + lib.optionalString (cfg.disableWorkspaceTrust == true) ''
            --disable-workspace-trust \
          '' + lib.optionalString (cfg.disableGettingStartedOverride == true) ''
            --disable-getting-started-override \
          '' + 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 = "code-server user";
        inherit (cfg) group;
      })
      {
        packages = cfg.extraPackages;
        inherit (cfg) extraGroups;
      }
    ];

    users.groups."${defaultGroup}" = lib.mkIf (cfg.group == defaultGroup) { };
  };

  meta.maintainers = [ lib.maintainers.stackshadow ];
}
+0 −1
Original line number Diff line number Diff line
@@ -192,7 +192,6 @@ in {
  cntr = handleTestOn ["aarch64-linux" "x86_64-linux"] ./cntr.nix {};
  cockpit = handleTest ./cockpit.nix {};
  cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
  code-server = handleTest ./code-server.nix {};
  coder = handleTest ./coder.nix {};
  collectd = handleTest ./collectd.nix {};
  connman = handleTest ./connman.nix {};

nixos/tests/code-server.nix

deleted100644 → 0
+0 −22
Original line number Diff line number Diff line
import ./make-test-python.nix ({pkgs, lib, ...}:
{
  name = "code-server";

  nodes = {
    machine = {pkgs, ...}: {
      services.code-server = {
        enable = true;
        auth = "none";
      };
    };
  };

  testScript = ''
    start_all()
    machine.wait_for_unit("code-server.service")
    machine.wait_for_open_port(4444)
    machine.succeed("curl -k --fail http://localhost:4444", timeout=10)
  '';

  meta.maintainers = [ lib.maintainers.drupol ];
})
+0 −20
Original line number Diff line number Diff line
diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh
index a72549fb..3aed1ad5 100755
--- a/ci/build/build-vscode.sh
+++ b/ci/build/build-vscode.sh
@@ -58,7 +58,6 @@ main() {
   # telemetry available; telemetry can still be disabled by flag or setting).
   # This needs to be done before building as Code will read this file and embed
   # it into the client-side code.
-  git checkout product.json             # Reset in case the script exited early.
   cp product.json product.original.json # Since jq has no inline edit.
   jq --slurp '.[0] * .[1]' product.original.json <(
     cat << EOF
@@ -105,7 +104,6 @@ EOF
   # Reset so if you develop after building you will not be stuck with the wrong
   # commit (the dev client will use `oss-dev` but the dev server will still use
   # product.json which will have `stable-$commit`).
-  git checkout product.json
 
   popd
 
Loading