Skip to content

Commit

Permalink
container: proper rename and option update
Browse files Browse the repository at this point in the history
  • Loading branch information
fufexan committed Aug 3, 2023
1 parent 00dd0ce commit 88e2aee
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 120 deletions.
35 changes: 0 additions & 35 deletions configuration.nix

This file was deleted.

77 changes: 77 additions & 0 deletions container-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
pkgs,
inputs,
...
}: let
get-host-ip = "$(ip route | grep default | cut -d' ' -f3)";
in {
boot.isContainer = true;

environment = {
shellInit = "export DISPLAY=${get-host-ip}:0";
systemPackages = builtins.concatLists (builtins.attrValues (import ./packages.nix {inherit pkgs inputs;}));
};

networking = {
nat = {
enable = true;
internalInterfaces = ["ve-rednix"];
externalInterface = "eth0";
};
useDHCP = false;
hostName = "RedNix";
firewall = {
enable = true;
allowPing = true;
allowedTCPPorts = [];
};
};

# nix config
nix = {
package = pkgs.nixUnstable;
settings.extra-experimental-features = [
"nix-command"
"flakes"
];
};

# nixpkgs config
nixpkgs.config = {
allowUnfree = true;
allowInsecurePredicate = p: true;
};

# services
services = {
getty.autologinUser = "rednix";

openssh = {
enable = true;
settings.X11Forwarding = true;
};

avahi = {
enable = true;
browseDomains = [];
wideArea = false;
nssmdns = true;
};

unbound = {
enable = true;
settings.server = {};
};
};

system.stateVersion = "23.11";

# users
users.users.rednix = {
isNormalUser = true;
uid = 1000;
description = "RedNix container user";
password = "rednix";
extraGroups = ["wheel"];
};
}
106 changes: 23 additions & 83 deletions container.nix
Original file line number Diff line number Diff line change
@@ -1,87 +1,27 @@
{
config,
pkgs,
lib,
inputs,
...
}: let
get-host-ip = "$(ip route | grep default | cut -d' ' -f3)";
in {
boot = {
isContainer = true;
};

environment = {
shellInit = "export DISPLAY=${get-host-ip}:0";
};

environment.systemPackages = builtins.concatLists (builtins.attrValues (import ./packages.nix { inherit pkgs inputs; }));

networking = {
nat = {
enable = true;
internalInterfaces = ["ve-rednix"];
externalInterface = "eth0";
};
useDHCP = false;
hostName = "RedNix";
firewall = {
enable = true;
allowPing = true;
allowedTCPPorts = [];
args: {
containers.rednix = {
privateNetwork = true;
hostAddress = "192.168.100.2";
localAddress = "192.168.100.11";

forwardPorts = [
{
containerPort = 22;
hostPort = 2222;
protocol = "tcp";
}
{
containerPort = 80;
hostPort = 8080;
protocol = "tcp";
}
];

bindMounts."/" = {
hostPath = "/mnt/rednix";
isReadOnly = false;
};
};

# nix config
nix = {
package = pkgs.nixUnstable;
settings = {
extra-experimental-features = [
"nix-command"
"flakes"
];
};
};

# nixpkgs config
nixpkgs.config = {
allowUnfree = true;
allowBroken = true;
allowInsecurePredicate = p: true;
};

# services
services = {
getty.autologinUser = "rednix";

openssh = {
enable = true;
forwardX11 = true;
};

avahi = {
enable = true;
browseDomains = [];
wideArea = false;
nssmdns = true;
};

unbound = {
enable = true;
settings.server = {};
};
};

# users
users = {
users = {
rednix = {
isNormalUser = true;
uid = 1000;
description = "RedNix container user";
password = "rednix";
extraGroups = ["wheel"];
};
};
config = import ./container-config.nix args;
};
}
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
nixosConfigurations = genSystems (system:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules = [./container.nix];
specialArgs = {inherit inputs;};
modules = [./container-config.nix];
});

# import into your config for declarative containers
Expand Down

0 comments on commit 88e2aee

Please sign in to comment.