From 8039d843472c06094efbb80e30419dc63f457d50 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 8 Mar 2026 21:55:01 -0500 Subject: [PATCH] started lxc --- flake.nix | 1 + modules/nixos/lxc.nix | 73 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 modules/nixos/lxc.nix diff --git a/flake.nix b/flake.nix index 2454605..ec58b81 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,7 @@ inputs.nixpkgs.follows = "nixpkgs"; url = "github:Mic92/sops-nix"; }; + vscode-server.url = "github:nix-community/nixos-vscode-server"; }; } diff --git a/modules/nixos/lxc.nix b/modules/nixos/lxc.nix new file mode 100644 index 0000000..3ac4fb6 --- /dev/null +++ b/modules/nixos/lxc.nix @@ -0,0 +1,73 @@ +{ inputs, ... }: +{ + flake-file.inputs = { + vscode-server.url = "github:nix-community/nixos-vscode-server"; + }; + + flake.lib.lxc = + let + inherit (inputs) nixpkgs vscode-server; + + baseLxcModules = [ + (nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix") + vscode-server.nixosModules.default + ({ pkgs, ... }: { + system.stateVersion = "24.11"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + services.vscode-server.enable = true; + environment.systemPackages = with pkgs; [ git ]; + }) + ]; + + mkLxcSystem = { system ? "x86_64-linux", extraModules ? [], extraPackages ? [] }: + nixpkgs.lib.nixosSystem { + inherit system; + modules = baseLxcModules ++ extraModules ++ [ + ({ pkgs, ... }: { + environment.systemPackages = extraPackages; + }) + ]; + }; + in + { inherit baseLxcModules mkLxcSystem; }; + + flake.nixosModules.lxc-bootstrap = { config, lib, pkgs, ... }: + with lib; + let + cfg = config.services.lxc-bootstrap; + in { + options.services.lxc-bootstrap = { + enable = mkEnableOption "LXC bootstrap configuration"; + + extraPackages = mkOption { + type = types.listOf types.package; + default = []; + description = "Extra packages to install"; + }; + + enableVscodeServer = mkOption { + type = types.bool; + default = true; + description = "Whether to enable VSCode server"; + }; + }; + + config = mkIf cfg.enable { + system.stateVersion = "24.11"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + services.vscode-server.enable = cfg.enableVscodeServer; + environment.systemPackages = with pkgs; [ git ] ++ cfg.extraPackages; + }; + }; + + flake.modules.nixos.lxc-base = { pkgs, ... }: { + imports = [ + inputs.vscode-server.nixosModules.default + (inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix") + ]; + system.stateVersion = "24.11"; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + services.vscode-server.enable = true; + environment.systemPackages = with pkgs; [ git ]; + }; +}