Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc3741fca | ||
| 88b6f01a35 | |||
| cc48ba10d6 | |||
| d1959792d2 |
71
flake.nix
71
flake.nix
@@ -6,22 +6,15 @@
|
||||
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
|
||||
nixosSystem = inputs.nixpkgs.lib.nixosSystem;
|
||||
|
||||
# Define the base modules list once
|
||||
baseLxcModules = [
|
||||
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
||||
inputs.vscode-server.nixosModules.default
|
||||
({ pkgs, ... }: {
|
||||
system.stateVersion = "24.11";
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
@@ -31,6 +24,56 @@
|
||||
];
|
||||
})
|
||||
];
|
||||
|
||||
# Function to create LXC systems with custom modules
|
||||
mkLxcSystem = { system ? "x86_64-linux", extraModules ? [], extraPackages ? [] }: nixosSystem {
|
||||
inherit system;
|
||||
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 = {
|
||||
# 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 { };
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user