code-remote
This commit is contained in:
parent
18488deb72
commit
a44486650a
|
@ -1,25 +1,29 @@
|
|||
{ config, pkgs, lib, inputs, ... }:
|
||||
|
||||
# TODO:
|
||||
# * [x] generate a ssh key if not existing
|
||||
# * [ ] automatically pull the repo on boot, do i need keys for that?
|
||||
# * [x] ~~generate a ssh key if not existing~~
|
||||
# * [ ] prompt to make a token using 'gh'?
|
||||
# * [ ] possibly store some key using nix-sops
|
||||
# * [ ] automatically pull the repo on first boot
|
||||
# * [ ] customize the shit out of vscode
|
||||
# * [ ] don't ignore PDFs
|
||||
# * [ ] fix the taskrunner
|
||||
# * [ ] fix the markdown preview not opening when prompted
|
||||
# * [ ] run the whole thing in a xvfb? should enable drawio and curv
|
||||
# * [ ] switch to openvscode-server? https://sourcegraph.com/github.com/bendlas/nixos-config/-/blob/code-server.container.nix?L39%3A26=
|
||||
|
||||
# https://github.com/coder/code-server/discussions/4267
|
||||
|
||||
let
|
||||
domain = "${config.networking.hostName}.${config.networking.domain}";
|
||||
mkDomain = subname: "${subname}.${domain}";
|
||||
hostName = config.networking.hostName;
|
||||
subdomain = "code-server.${config.networking.fqdn}";
|
||||
container-name = "code-server-pandoc-papers";
|
||||
container = config.containers.${container-name}.config;
|
||||
in {
|
||||
networking.nat = {
|
||||
enable = true;
|
||||
internalInterfaces = ["ve-+"];
|
||||
externalInterface = "eno1"; # TODO: can i make this automatic?
|
||||
#enableIPv6 = true;
|
||||
};
|
||||
networking.nat.enable = true;
|
||||
networking.nat.internalInterfaces = ["ve-+"];
|
||||
networking.nat.externalInterface = "eno1"; # TODO: can i make this automatic?
|
||||
#networking.nat.enableIPv6 = true;
|
||||
|
||||
#imports = [
|
||||
# "/home/pbsds/repos/nixpkgs-trees/containers-mkdir/nixos/modules/virtualisation/nixos-containers.nix"
|
||||
|
@ -37,30 +41,21 @@ in {
|
|||
hostAddress = "10.240.100.2";
|
||||
localAddress = "10.240.100.3";
|
||||
|
||||
#forwardPorts = [
|
||||
# {
|
||||
# #hostAddress = "127.0.0.1"; # does not exist
|
||||
# hostPort = 53754;
|
||||
# containerPort = 53754;
|
||||
# protocol = "tcp";
|
||||
# }
|
||||
#];
|
||||
|
||||
#bindMounts."/home" = {
|
||||
# hostPath = "/var/lib/code-server";
|
||||
# isReadOnly = false;
|
||||
#};
|
||||
config = { config, pkgs, lib, ... }: {
|
||||
system.stateVersion = "22.11";
|
||||
|
||||
#imports = [ <home-manager/nixos> ];
|
||||
#home-manager.useGlobalPkgs = true; # brrr
|
||||
#home-manager.useUserPackages = true; # requiredm installs user packages to /etc instead of ~/.nix-profile
|
||||
#home-manager.users.${config.services.code-server.user} = { pkgs, config, ... }: {
|
||||
# programs.git.enable = true;
|
||||
# programs.git.userName = "Noximilien code-server";
|
||||
# programs.git.userEmail = "theotheo@ntnu.no";
|
||||
#};
|
||||
imports = [ inputs.home-manager.nixosModule ];
|
||||
home-manager.useGlobalPkgs = true; # brrr
|
||||
home-manager.useUserPackages = true; # required, installs user packages to /etc instead of ~/.nix-profile
|
||||
home-manager.users.${config.services.code-server.user} = { pkgs, config, ... }: {
|
||||
home.stateVersion = "22.11";
|
||||
programs.git.enable = true;
|
||||
programs.git.userName = "code-server";
|
||||
programs.git.userEmail = "pbsds@hotmail.com";
|
||||
#programs.vscode.extensions
|
||||
#programs.vscode.bindings
|
||||
#programs.vscode.userSettings
|
||||
};
|
||||
|
||||
systemd.services.initial-setup = {
|
||||
enable = true;
|
||||
|
@ -86,10 +81,16 @@ in {
|
|||
test -d "$HOME/repo" || (
|
||||
set -x
|
||||
cp -a ${inputs.pbsds-papers.outPath} "$HOME/repo"
|
||||
chmod -R a+w "$HOME/repo"
|
||||
chmod -R +w "$HOME/repo"
|
||||
)
|
||||
test -e "$HOME/repo/neural-intersection-fields/.vscode" || (
|
||||
cd "$HOME/repo/neural-intersection-fields"
|
||||
ln -s ../.vscode .
|
||||
)
|
||||
|
||||
if test -d "$HOME/repo/.git"; then
|
||||
( cd $HOME/repo; git pull --rebase --autostash ) # TODO: somehow rollback if failed
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -114,11 +115,11 @@ in {
|
|||
passthru.executableName = "code-server";
|
||||
passthru.longName = "Visual Studio Code Server";
|
||||
});
|
||||
#vscodeExtensions = with (import <nixos-unstable> {}).vscode-extensions; [
|
||||
#vscodeExtensions = with pkgs.unstable.vscode-extensions; [
|
||||
vscodeExtensions = with pkgs.vscode-extensions; [
|
||||
shd101wyy.markdown-preview-enhanced
|
||||
sanaajani.taskrunnercode
|
||||
tomoki1207.pdf
|
||||
sanaajani.taskrunnercode # doesn't work?
|
||||
tomoki1207.pdf # no firefox?
|
||||
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
|
||||
{
|
||||
name = "new-railscasts";
|
||||
|
@ -164,25 +165,28 @@ in {
|
|||
}
|
||||
];
|
||||
};
|
||||
extraPackages = let
|
||||
shellnix = import "${inputs.pbsds-papers}/shell.nix" { inherit pkgs; };
|
||||
in (with pkgs; [ imagemagick ]) # for some reason it isn't passed from shell.nix
|
||||
++ shellnix.buildInputs
|
||||
++ shellnix.nativeBuildInputs
|
||||
++ shellnix.propagatedBuildInputs
|
||||
++ shellnix.propagatedNativeBuildInputs;
|
||||
extraPackages = (with pkgs; [
|
||||
git gh hub
|
||||
micro
|
||||
]) ++ (let
|
||||
shell = import "${inputs.pbsds-papers}/shell.nix" { inherit pkgs; };
|
||||
in
|
||||
(with pkgs; [ imagemagick librsvg ]) # for some reason it isn't picked up from from shell.nix?
|
||||
++ shell.buildInputs
|
||||
++ shell.nativeBuildInputs
|
||||
++ shell.propagatedBuildInputs
|
||||
++ shell.propagatedNativeBuildInputs
|
||||
);
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
networking.firewall.enable = true;
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
config.services.code-server.port
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts.${mkDomain "code-server"} = {
|
||||
services.nginx.virtualHosts.${subdomain} = {
|
||||
forceSSL = true; # addSSL = true;
|
||||
enableACME = true; #useACMEHost = acmeDomain;
|
||||
locations."/" = {
|
||||
|
|
Loading…
Reference in New Issue