started exports

This commit is contained in:
2025-07-03 02:28:27 +00:00
parent 7ecb6a67fb
commit d1959792d2

View File

@@ -6,31 +6,86 @@
vscode-server.url = "github:nix-community/nixos-vscode-server"; vscode-server.url = "github:nix-community/nixos-vscode-server";
}; };
outputs = { self, ... }@args: outputs = { self, ... }@inputs:
let let
inherit (self) outputs; inherit (self) outputs;
nixosSystem = args.nixpkgs.lib.nixosSystem; nixosSystem = inputs.nixpkgs.lib.nixosSystem;
pkgs = args.nixpkgs.legacyPackages.x86_64-linux; pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
in
{ # Base LXC module that can be reused
nixosConfigurations.lxc = nixosSystem { baseLxcModule = { pkgs, ... }: {
system = "x86_64-linux";
specialArgs = {
inherit pkgs;
};
modules = [
(args.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
args.vscode-server.nixosModules.default
# ./configuration.nix
({ pkgs, ... }: {
system.stateVersion = "24.11"; system.stateVersion = "24.11";
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];
services.vscode-server.enable = true; services.vscode-server.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git git
]; ];
};
# Function to create LXC systems with custom modules
mkLxcSystem = { system ? "x86_64-linux", extraModules ? [], extraPackages ? [] }: nixosSystem {
inherit system;
specialArgs = {
inherit pkgs;
};
modules = [
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
inputs.vscode-server.nixosModules.default
baseLxcModule
# Add extra packages to the base configuration
({ pkgs, ... }: {
environment.systemPackages = extraPackages;
}) })
] ++ extraModules;
};
in
{
# Export the function and modules for reuse
lib = {
inherit mkLxcSystem baseLxcModule;
# Helper to get the base modules list
baseLxcModules = [
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
inputs.vscode-server.nixosModules.default
baseLxcModule
]; ];
}; };
# Re-export inputs for downstream flakes
inherit (inputs) inputs;
# Export nixosModules for use in other flakes
nixosModules = {
lxc-base = baseLxcModule;
# Alternative module with more options
lxc-configurable = { 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;
};
};
};
nixosConfigurations.lxc = mkLxcSystem { };
}; };
} }