Compare commits

..

2 Commits

Author SHA1 Message Date
cc48ba10d6 broke out basemodules 2025-07-03 02:34:29 +00:00
d1959792d2 started exports 2025-07-03 02:28:27 +00:00

View File

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