fist commit - images lib in a working condition for debian
This commit is contained in:
commit
ad2092531c
12 changed files with 308 additions and 0 deletions
59
lib/images/commons/scripts-n-files.nix
Normal file
59
lib/images/commons/scripts-n-files.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# minimal set of scripts and services by various images
|
||||
{ pkgs, lib, ... }: {
|
||||
# bring back simple interface names like eth0 eth1 etc
|
||||
grub-ifnames-0 = pkgs.writeText "grub-ifnames-0" ''
|
||||
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 $GRUB_CMDLINE_LINUX"
|
||||
'';
|
||||
|
||||
# no need for CPU microcode updating in VMs
|
||||
grub-disable-microcode = pkgs.writeText "grub-disable-microcode" ''
|
||||
GRUB_CMDLINE_LINUX="dis_ucode_ldr $GRUB_CMDLINE_LINUX"
|
||||
'';
|
||||
|
||||
# dhcp for eth0
|
||||
eth0-dhcp-network = pkgs.writeText "eth0-network" ''
|
||||
[Match]
|
||||
Name=eth0
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
'';
|
||||
|
||||
# generate ssh host keys before starting sshd
|
||||
ssh-service-override-conf-create = pkgs.writeScript "ssh-override-conf-create.sh" ''
|
||||
mkdir -p /etc/systemd/system/ssh.service.d
|
||||
|
||||
cat > /etc/systemd/system/ssh.service.d/override.conf << EOF
|
||||
[Service]
|
||||
ExecStartPre=
|
||||
ExecStartPre=`which ssh-keygen` -A
|
||||
ExecStartPre=`which sshd` -t
|
||||
|
||||
EOF
|
||||
'';
|
||||
|
||||
# script to grow root partition
|
||||
grow-root-sh = pkgs.writeScript "grow-root-sh" ''
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
command -v growpart >/dev/null || { >&2 echo "growpart not found. Install package cloud-guest-utils or cloud-utils."; exit 1; }
|
||||
|
||||
ROOTPART=$(findmnt / -o source -n)
|
||||
DISK=''${ROOTPART%[0-9]*}
|
||||
PARTNUM=''${ROOTPART##*[!0-9]}
|
||||
|
||||
# resize and grow if possible
|
||||
growpart "$DISK" "$PARTNUM" && resize2fs "$ROOTPART" || true
|
||||
'';
|
||||
|
||||
# service to grow root partition on boot
|
||||
grow-root-service = pkgs.writeText "grow-root-service" ''
|
||||
[Service]
|
||||
Type = oneshot
|
||||
ExecStart = /usr/local/sbin/grow-root.sh
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue