Compare commits
2 Commits
git
...
cc48ba10d6
| Author | SHA1 | Date | |
|---|---|---|---|
| cc48ba10d6 | |||
| d1959792d2 |
158
flake.lock
generated
158
flake.lock
generated
@@ -1,158 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681202837,
|
|
||||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750798083,
|
|
||||||
"narHash": "sha256-DTCCcp6WCFaYXWKFRA6fiI2zlvOLCf5Vwx8+/0R8Wc4=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "home-manager",
|
|
||||||
"rev": "ff31a4677c1a8ae506aa7e003a3dba08cb203f82",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "home-manager",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager_2": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nix-home",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750033262,
|
|
||||||
"narHash": "sha256-TcFN78w6kPspxpbPsxW/8vQ1GAtY8Y3mjBaC+oB8jo4=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "home-manager",
|
|
||||||
"rev": "66523b0efe93ce5b0ba96dcddcda15d36673c1f0",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "home-manager",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nix-home": {
|
|
||||||
"inputs": {
|
|
||||||
"home-manager": "home-manager_2",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750825763,
|
|
||||||
"narHash": "sha256-gUtcO/8Bcw4YerJpSIRu+Q2MYKxWrtT+8Bp3Mh1Qfmw=",
|
|
||||||
"ref": "refs/heads/main",
|
|
||||||
"rev": "1ab1e4b9e610dcd40a3d728f377b6ac8a302d977",
|
|
||||||
"revCount": 26,
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://gitea.john-stream.com/john/nix-home"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://gitea.john-stream.com/john/nix-home"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750506804,
|
|
||||||
"narHash": "sha256-VLFNc4egNjovYVxDGyBYTrvVCgDYgENp5bVi9fPTDYc=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "4206c4cb56751df534751b058295ea61357bbbaa",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1682134069,
|
|
||||||
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"home-manager": "home-manager",
|
|
||||||
"nix-home": "nix-home",
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"vscode-server": "vscode-server"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vscode-server": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750353031,
|
|
||||||
"narHash": "sha256-Bx7DOPLhkr8Z60U9Qw4l0OidzHoqLDKQH5rDV5ef59A=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nixos-vscode-server",
|
|
||||||
"rev": "4ec4859b12129c0436b0a471ed1ea6dd8a317993",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nixos-vscode-server",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
86
flake.nix
86
flake.nix
@@ -4,14 +4,6 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
||||||
home-manager = {
|
|
||||||
url = "github:nix-community/home-manager";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
nix-home = {
|
|
||||||
url = "git+https://gitea.john-stream.com/john/nix-home";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, ... }@inputs:
|
outputs = { self, ... }@inputs:
|
||||||
@@ -19,29 +11,77 @@
|
|||||||
inherit (self) outputs;
|
inherit (self) outputs;
|
||||||
nixosSystem = inputs.nixpkgs.lib.nixosSystem;
|
nixosSystem = inputs.nixpkgs.lib.nixosSystem;
|
||||||
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
||||||
in
|
|
||||||
{
|
# Base LXC module that can be reused
|
||||||
nixosConfigurations.appdaemon = nixosSystem {
|
baseLxcModule = { pkgs, ... }: {
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [
|
|
||||||
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
|
||||||
inputs.nix-home.nixosModules.default { user = "john"; }
|
|
||||||
inputs.vscode-server.nixosModules.default
|
|
||||||
({ 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;
|
||||||
virtualisation.docker.enable = true;
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
git
|
git
|
||||||
devenv
|
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# 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;
|
||||||
})
|
})
|
||||||
inputs.home-manager.nixosModules.home-manager {
|
|
||||||
home-manager.useGlobalPkgs = true;
|
|
||||||
home-manager.users.root.home.stateVersion = "24.11";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
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 { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user