feat(ci): shell-customization #32
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