This commit is contained in:
commit
95a533c876
451 changed files with 18255 additions and 0 deletions
70
templates/container/README.md
Normal file
70
templates/container/README.md
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# NixOS Container
|
||||
|
||||
Imperative container NixOS configuration.
|
||||
|
||||
## References:
|
||||
|
||||
- [NixOS Manual](https://nixos.org/manual/nixos/stable/#sec-imperative-containers)
|
||||
- [NixOS Wiki](https://wiki.nixos.org/wiki/NixOS_Containers#Define_and_create_nixos-container_from_a_Flake_file)
|
||||
|
||||
## Setup
|
||||
|
||||
In your host configuration, set:
|
||||
|
||||
```nix
|
||||
boot.enableContainers = true;
|
||||
```
|
||||
|
||||
Create a new directory and initialize the template inside of it:
|
||||
|
||||
> `nxc` is an arbitrary name
|
||||
|
||||
```bash
|
||||
mkdir -p nxc
|
||||
cd nxc
|
||||
nix flake init -t git+https://git.sid.ovh/sid/synix#container
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create the container:
|
||||
|
||||
```bash
|
||||
sudo nixos-container create nxc --flake .
|
||||
```
|
||||
|
||||
Start the container:
|
||||
|
||||
```bash
|
||||
sudo nixos-container start nxc
|
||||
```
|
||||
|
||||
Rebuild the container:
|
||||
|
||||
```bash
|
||||
sudo nixos-container update nxc --flake .
|
||||
```
|
||||
|
||||
Log in as root:
|
||||
|
||||
```bash
|
||||
sudo nixos-container root-login nxc
|
||||
```
|
||||
|
||||
Stop the container:
|
||||
|
||||
```bash
|
||||
sudo nixos-container stop nxc
|
||||
```
|
||||
|
||||
Destroy the container:
|
||||
|
||||
```bash
|
||||
sudo nixos-container destroy nxc
|
||||
```
|
||||
|
||||
For more, see the help page:
|
||||
|
||||
```bash
|
||||
nixos-container --help
|
||||
```
|
||||
32
templates/container/config/base.nix
Normal file
32
templates/container/config/base.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Edit this only if you know what you're doing.
|
||||
{ outputs, ... }:
|
||||
|
||||
{
|
||||
boot = {
|
||||
isContainer = true;
|
||||
isNspawnContainer = true;
|
||||
};
|
||||
|
||||
nix = {
|
||||
channel.enable = false;
|
||||
settings = {
|
||||
experimental-features = "nix-command flakes";
|
||||
builders-use-substitutes = true;
|
||||
substituters = [
|
||||
"https://cache.nixos.org"
|
||||
"https://nix-community.cachix.org"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
outputs.overlays.synix-packages
|
||||
outputs.overlays.local-packages
|
||||
];
|
||||
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
5
templates/container/config/configuration.nix
Normal file
5
templates/container/config/configuration.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
networking.hostName = "nxc";
|
||||
|
||||
# Add the rest of your configuration here
|
||||
}
|
||||
6
templates/container/config/default.nix
Normal file
6
templates/container/config/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./base.nix
|
||||
./configuration.nix
|
||||
];
|
||||
}
|
||||
58
templates/container/flake.nix
Normal file
58
templates/container/flake.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
description = "Container NixOS configurations";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
||||
synix.url = "git+https://git.sid.ovh/sid/synix.git?ref=release-25.11";
|
||||
synix.imputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
...
|
||||
}@inputs:
|
||||
let
|
||||
inherit (self) outputs;
|
||||
|
||||
system = "x86_64-linux";
|
||||
|
||||
lib = nixpkgs.lib.extend (final: prev: inputs.synix.lib or { });
|
||||
in
|
||||
{
|
||||
packages =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
import ./pkgs { inherit pkgs; };
|
||||
|
||||
overlays = import ./overlays { inherit (self) inputs; };
|
||||
|
||||
devShells =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nixos-container
|
||||
tmux
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
nixosModules = import ./modules;
|
||||
|
||||
nixosConfigurations = {
|
||||
container = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [ ./config ];
|
||||
specialArgs = {
|
||||
inherit inputs outputs lib;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
templates/container/modules/default.nix
Normal file
3
templates/container/modules/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
# example = import ./example;
|
||||
}
|
||||
7
templates/container/overlays/default.nix
Normal file
7
templates/container/overlays/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{ inputs, ... }:
|
||||
|
||||
{
|
||||
synix-packages = final: prev: { synix = inputs.synix.overlays.additions final prev; };
|
||||
|
||||
local-packages = final: prev: { local = import ../pkgs { pkgs = final; }; };
|
||||
}
|
||||
5
templates/container/pkgs/default.nix
Normal file
5
templates/container/pkgs/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# example = pkgs.callPackage ./example { };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue