Skip to content

Commit

Permalink
nixos/configurations/adrastea/code-server: the web version of vscode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc authored Dec 27, 2024
1 parent 1701e22 commit e7ffffb
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 4 deletions.
3 changes: 3 additions & 0 deletions nixos/configurations/adrastea/code-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code server

This submodule declares using vscodium web services.
55 changes: 55 additions & 0 deletions nixos/configurations/adrastea/code-server/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
pkgs,
lib,
config,
...
}:
let
mkUser =
{ user, port }:
let
secretName = "code/adrastea/${user}";
in
{
sops.secrets.${secretName} = {
owner = user;
};
systemd.user.services."code-server-fhs-${user}" = {
description = "Code Server with FHS";
wantedBy = [ "multi-user.target" ];

serviceConfig = {
ExecStart = "${pkgs.writeScript "start-code-server" ''
#!${lib.getExe pkgs.linux-fhs-python}
${builtins.readFile ./start-code-server.py}
''}";
Environment = [
"WebHost=${pkgs.vscodium-web-host}"
"Port=${port}"
"ConnectionTokenFile=${config.sops.secrets.${secretName}.path}"
];
};
};

services.caddy = {
enable = true;
virtualHosts = {
"${user}.adrastea.code.inclyc.cn" = {
extraConfig = "
reverse_proxy http://127.0.0.1:${port}
";
};
};
};
};
in
lib.mkMerge [
(mkUser {
user = "lyc";
port = "63300";
})
(mkUser {
user = "zxy";
port = "63301";
})
]
15 changes: 15 additions & 0 deletions nixos/configurations/adrastea/code-server/start-code-server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import subprocess
import os
import os.path

subprocess.run(
[
f"{os.environ["WebHost"]}/bin/codium-server",
"--host",
"127.0.0.1",
"--port",
os.environ["Port"],
"--connection-token-file",
os.environ["ConnectionTokenFile"],
]
)
4 changes: 3 additions & 1 deletion nixos/configurations/adrastea/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
};

imports = [
# Include the results of the hardware scan.
# Codium server, for easy FHS access.
./code-server
./game.nix
./gitea.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
./networking.nix
./vm
Expand Down
10 changes: 7 additions & 3 deletions secrets/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ gitea:
runners:
simd: ENC[AES256_GCM,data:qicPRCb6kw4a62H99XYS/vZUx/oc0hERtXm8iOHxs3LWEL8PQ8ZWvOoXxYON1BE=,iv:UyIJvLkwSUYuuKEbolAClV/FfFnCKTexEYH0wkJrqLk=,tag:PNECKkvc+LkOugxau1wkMA==,type:str]
fuse-feature: ENC[AES256_GCM,data:pOulePuS9AbEcl3EM6LSOzvWmpVxKs3YcMsfofdlYOI1GOSE/oIjI1gpvssA59U=,iv:BmWCKURIfQSXJ5ryBzfIOeIISlrF43Nir9wOgzZjMGs=,tag:O2Wc/c/DtXvzOfG/TF/6UQ==,type:str]
code:
adrastea:
lyc: ENC[AES256_GCM,data:5qHFyJP7JTA0jCWVhssoylt4lKh+YzsIFiMi4WpY1lkMdbGu,iv:ZT9dHzS6vstDkPHkVatooZNzLALiTNc+f/CmNtYj5pc=,tag:NKhu61Ut5rutGrifiFW78g==,type:str]
zxy: ENC[AES256_GCM,data:U8vIiard9j/jgBJ+4n3q0VO6DLpT+PEg7EYWxojty3t6eLD3,iv:dB1mTLkVr3OPNiqSYoE+WHY6pZtdoJIJpc9r3EiETvs=,tag:xsXH/RwmVOdp6MiYvAmOUw==,type:str]
sops:
kms: []
gcp_kms: []
Expand Down Expand Up @@ -63,8 +67,8 @@ sops:
ZDg0T2hqR2tROVI1T1BLeFNnaGVYY1EKOnOp5ZPo48XIB7d9PnG2sKvsoLX32XEm
Pqf4UTOmT47SSKsvu5xgxPXJrhBySkspn97gtpl9bYG4n8HYCSw+hg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-11-27T17:03:22Z"
mac: ENC[AES256_GCM,data:aA3nNctclT040XLk46Lon7LaxqmK5xPB1Qxrvm2Sfc1jEo/0q4Sx008o1euSX1zhPDyHftJco40uUyGvRo1mOH4XCFTzTxHvMWCJUUsTEkrl7bLgK63pEohCUAoeVWnVKMeHGuthPqb94PbpKFpzf46o7DihJ7fTwDMU4QUduk4=,iv:dUymSvKQhZbesmlhlYJCO7xjIybXPltG57Er0+oHRpU=,tag:WxLxh2JhK5keXdEhXkaF2A==,type:str]
lastmodified: "2024-12-26T08:35:58Z"
mac: ENC[AES256_GCM,data:zSn2R/cz1cR0brEBm8u8YqXDc4JLfPOMdorDQDvzMq8+o228EOHPLgRVIGXsZeLgX/5ye2LN+mfCNnBHc4Vv2vPSD0Bk0t40C6KDdw8AGG5npsz0imYHb7T9YW0dXHQbgbWEEKUahnfVPNHbemq4E/GqfyqZff4qu12XNvyzV0g=,iv:J6NlKrXKQm8EhLc3BLYU3q5MLlGLblPvhrLn0ETdNP0=,tag:CVy3GrNdC6r8u+KHN4AfJQ==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.9.1
version: 3.9.2

0 comments on commit e7ffffb

Please sign in to comment.