Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hostName option and fix docker #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/initrd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ nglib.makeSystem {
};
users.users.root.hashedPassword = "$5$Ws9piKbYzt9S6p1R$X4L6xn5UNQnufJUc/K5sKRE.0GuMR.8vp2BwIiglVYB"; # toor

networking.hostName = "initrd";

services.getty."ttyS0" = {
port = "ttyS0";
baudrate = "115200,38400,9600";
Expand Down
1 change: 1 addition & 0 deletions modules/list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

./misc/iana.nix

./networking.nix
./environment.nix
./users.nix
./ids.nix
Expand Down
26 changes: 26 additions & 0 deletions modules/networking.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2023 Richard Brežák and NixNG contributors
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

{ nglib, lib, config, ... }:
{
options.networking = {
hostName = lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.strMatching
"^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$");
description = ''
The hostname of the system. Notice that in many container engines
the hostname cannot be altered.
'';
};
};

config.system.activation.hostname = nglib.dag.dagEntryAnywhere (lib.optionalString (config.networking.hostName != null) ''
echo "${config.networking.hostName}" > /proc/sys/kernel/hostname
'');
}
10 changes: 5 additions & 5 deletions modules/system/oci-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ with lib;
config = {
system.build.ociImage =
let
config = {
name = cfg.name;
cfg = {
inherit (config.system) name;
tag = "latest";
maxLayers = 125;

config = {
StopSignal = "SIGCONT";
Entrypoint =
[
"${configFinal.system.build.toplevel}/init"
"${config.system.build.toplevel}/init"
];
};
};
in
with pkgs; {
build = dockerTools.buildLayeredImage config;
stream = dockerTools.streamLayeredImage config;
build = dockerTools.buildLayeredImage cfg;
stream = dockerTools.streamLayeredImage cfg;
};
};
}