started lxc

This commit is contained in:
John Lancaster
2026-03-08 21:55:01 -05:00
parent 7d28205371
commit 8039d84347
2 changed files with 74 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
inputs.nixpkgs.follows = "nixpkgs";
url = "github:Mic92/sops-nix";
};
vscode-server.url = "github:nix-community/nixos-vscode-server";
};
}

73
modules/nixos/lxc.nix Normal file
View File

@@ -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 ];
};
}