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/).
|
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)
|
### [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`
|
Uses the home-manager module of flake-parts, which is imported in `modules/home-manager/flake-parts.nix`
|
||||||
@@ -47,4 +46,10 @@ Show exported home configurations:
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix eval --apply builtins.attrNames .#homeConfigurations
|
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"
|
"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": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
@@ -136,6 +154,20 @@
|
|||||||
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
|
"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": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-file": "flake-file",
|
"flake-file": "flake-file",
|
||||||
@@ -147,7 +179,8 @@
|
|||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"sops-nix": "sops-nix"
|
"sops-nix": "sops-nix",
|
||||||
|
"vscode-server": "vscode-server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
"sops-nix": {
|
||||||
@@ -184,6 +217,40 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"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",
|
"root": "root",
|
||||||
|
|||||||
@@ -1,73 +1,19 @@
|
|||||||
{ inputs, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
flake-file.inputs = {
|
flake.modules.nixos.lxc = { pkgs, lib, ...}: {
|
||||||
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
imports = [
|
||||||
|
({ modulesPath, ... }: { imports = [ "${modulesPath}/virtualisation/proxmox-lxc.nix" ]; })
|
||||||
|
];
|
||||||
|
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
|
||||||
|
system.stateVersion = "25.11";
|
||||||
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
environment.systemPackages = with pkgs; [ git zsh ];
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.lib.lxc =
|
# Generic bootstrapping lxc, use a specific host file for more
|
||||||
let
|
flake.nixosConfigurations.lxc = inputs.nixpkgs.lib.nixosSystem {
|
||||||
inherit (inputs) nixpkgs vscode-server;
|
modules = [
|
||||||
|
inputs.self.modules.nixos.lxc
|
||||||
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, ... }: {
|
|
||||||
imports = [
|
|
||||||
inputs.vscode-server.nixosModules.default
|
|
||||||
(inputs.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
|
||||||
];
|
];
|
||||||
system.stateVersion = "24.11";
|
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
||||||
services.vscode-server.enable = true;
|
|
||||||
environment.systemPackages = with pkgs; [ git ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user