forked from DGNum/liminix
fix: hostname at early boot
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 20s
build liminix / build_vm_qemu_mips (pull_request) Successful in 20s
build liminix / test_shell_customization (pull_request) Successful in 22s
build liminix / test_hostapd (pull_request) Successful in 22s
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 20s
build liminix / build_vm_qemu_mips (pull_request) Successful in 20s
build liminix / test_shell_customization (pull_request) Successful in 22s
build liminix / test_hostapd (pull_request) Successful in 22s
This commit is contained in:
parent
89d2d34ad7
commit
7eff028b02
3 changed files with 18 additions and 7 deletions
|
@ -1,7 +1,6 @@
|
|||
{ lib, pkgs, config, ...}:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs.liminix.services) oneshot;
|
||||
in {
|
||||
options = {
|
||||
hostname = mkOption {
|
||||
|
@ -12,12 +11,21 @@ in {
|
|||
default = "liminix";
|
||||
type = types.nonEmptyStr;
|
||||
};
|
||||
};
|
||||
config = {
|
||||
services.hostname = oneshot {
|
||||
name = "hostname-${builtins.substring 0 12 (builtins.hashString "sha256" config.hostname)}";
|
||||
up = "echo ${config.hostname} > /proc/sys/kernel/hostname";
|
||||
down = "true";
|
||||
hostname-script = mkOption {
|
||||
description = ''
|
||||
Script that outputs the system hostname on stdin.
|
||||
'';
|
||||
default = pkgs.writeScript "hostname-gen" ''
|
||||
#!/bin/sh
|
||||
echo ${config.hostname}
|
||||
'';
|
||||
defaultText = ''
|
||||
pkgs.writeScript "hostname-gen" '''
|
||||
#!/bin/sh
|
||||
echo ''${config.hostname}
|
||||
'''
|
||||
'';
|
||||
type = types.package;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ let
|
|||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -r $src $out/scripts
|
||||
substituteInPlace $out/scripts/rc.init \
|
||||
--replace-fail 'config.hostname' "${config.hostname-script}"
|
||||
chmod -R +w $out
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -36,6 +36,7 @@ fi
|
|||
### (replace /run/service with your scandir)
|
||||
s6-rc-init -d -c /etc/s6-rc/compiled /run/service
|
||||
|
||||
config.hostname > /proc/sys/kernel/hostname
|
||||
|
||||
### 2. Starting the wanted set of services
|
||||
### This is also called every time you change runlevels with telinit.
|
||||
|
|
Loading…
Reference in a new issue