started lxc nixos module
This commit is contained in:
@@ -33,7 +33,6 @@ This uses `inputs.flake-parts.lib.mkFlake` to create the flake.
|
||||
|
||||
The modules are automatically imported from the `./modules` using [import-tree](https://import-tree.oeiuwq.com/).
|
||||
|
||||
|
||||
### [Home Manager](https://flake.parts/options/home-manager.html)
|
||||
|
||||
Uses the home-manager module of flake-parts, which is imported in `modules/home-manager/flake-parts.nix`
|
||||
@@ -48,3 +47,9 @@ Show exported home configurations:
|
||||
```shell
|
||||
nix eval --apply builtins.attrNames .#homeConfigurations
|
||||
```
|
||||
|
||||
### Remote Deploy
|
||||
|
||||
```shell
|
||||
nixos-rebuild switch --flake .#lxc --target-host root@fded:fb16:653e:25da:be24:11ff:fea0:753f
|
||||
```
|
||||
|
||||
69
flake.lock
generated
69
flake.lock
generated
@@ -53,6 +53,24 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"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"
|
||||
@@ -136,6 +154,20 @@
|
||||
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1682134069,
|
||||
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-file": "flake-file",
|
||||
@@ -147,7 +179,8 @@
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"sops-nix": "sops-nix"
|
||||
"sops-nix": "sops-nix",
|
||||
"vscode-server": "vscode-server"
|
||||
}
|
||||
},
|
||||
"sops-nix": {
|
||||
@@ -184,6 +217,40 @@
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"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_2",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1770124655,
|
||||
"narHash": "sha256-yHmd2B13EtBUPLJ+x0EaBwNkQr9LTne1arLVxT6hSnY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-vscode-server",
|
||||
"rev": "92ce71c3ba5a94f854e02d57b14af4997ab54ef0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixos-vscode-server",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
@@ -1,73 +1,19 @@
|
||||
{ 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, ... }: {
|
||||
flake.modules.nixos.lxc = { pkgs, lib, ...}: {
|
||||
imports = [
|
||||
inputs.vscode-server.nixosModules.default
|
||||
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
||||
({ modulesPath, ... }: { imports = [ "${modulesPath}/virtualisation/proxmox-lxc.nix" ]; })
|
||||
];
|
||||
system.stateVersion = "24.11";
|
||||
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
|
||||
system.stateVersion = "25.11";
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
services.vscode-server.enable = true;
|
||||
environment.systemPackages = with pkgs; [ git ];
|
||||
environment.systemPackages = with pkgs; [ git zsh ];
|
||||
};
|
||||
|
||||
# Generic bootstrapping lxc, use a specific host file for more
|
||||
flake.nixosConfigurations.lxc = inputs.nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
inputs.self.modules.nixos.lxc
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user