nixos-conf/misc/custom-iso-base.nix

91 lines
2.4 KiB
Nix
Raw Normal View History

{ pkgs, ... }:
let
2024-08-28 13:00:05 +03:00
create-partitions = pkgs.writeScriptBin "create-partitions" ''
if [[ $# -ne 3 ]]
then
echo "Usage: create-partitions <device prefix> <BOOT suffix> <root suffix>"
exit
fi
read -p "Erasing disk $1 -- Creating partition $1$2 as BOOT -- Creating partition $1$3 as root -- Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
parted $1 -- mklabel gpt
parted $1 -- mkpart ESP fat32 1MB 512MB
2024-08-28 13:00:05 +03:00
parted $1 -- set 1 esp on
parted $1 -- mkpart root ext4 512MB 100%
fi
2024-08-28 13:00:05 +03:00
read -p "Setup root partition encryption?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
2024-08-28 13:18:09 +03:00
cryptsetup luksFormat $1$3
if cryptsetup open $1$3 nixos
then
echo "Encrypted device accessible via /dev/mapper/nixos"
fi
fi
'';
2024-08-28 13:18:09 +03:00
create-filesystems = pkgs.writeScriptBin "create-filesystems" ''
2024-08-28 13:00:05 +03:00
if [[ $# -ne 2 ]]
then
2024-08-28 13:37:01 +03:00
echo "Usage: create-filesystems <BOOT partition> <root partition>"
2024-08-28 13:00:05 +03:00
exit
fi
mkfs.fat -F 32 -n BOOT $1
mkfs.ext4 -L nixos $2
'';
prep-install = pkgs.writeScriptBin "prep-install" ''
mkdir /mnt
mount /dev/disk/by-label/nixos /mnt
mkdir /mnt/boot
mount -o umask=077 /dev/disk/by-label/BOOT /mnt/boot
2024-08-07 16:59:23 +03:00
nixos-generate-config --root /mnt
mv /mnt/etc/nixos/configuration.nix configuration.nix.old
curl https://raw.githubusercontent.com/VSinerva/nixos-conf/main/misc/template-configuration.nix -o /mnt/etc/nixos/configuration.nix
'';
in
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
../base.nix
];
2024-10-11 12:53:45 +03:00
environment.systemPackages =
(with pkgs; [
2024-10-15 19:49:04 +03:00
(onlykey.override (prev: {
node_webkit = prev.node_webkit.overrideAttrs {
2024-10-15 20:11:43 +03:00
src = fetchurl {
url = "https://dl.nwjs.io/v0.71.1/nwjs-v0.71.1-linux-x64.tar.gz";
hash = "sha256-bnObpwfJ6SNJdOvzWTnh515JMcadH1+fxx5W9e4gl/4=";
};
2024-10-15 19:49:04 +03:00
};
}))
2024-10-11 12:53:45 +03:00
cryptsetup
onlykey-cli
onlykey-agent
])
++ [
create-partitions
create-filesystems
prep-install
];
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-curses;
};
2024-10-15 20:31:40 +03:00
hardware.onlykey.enable = true;
2024-08-28 13:00:05 +03:00
isoImage.squashfsCompression = "gzip -Xcompression-level 1";
#Many installs will need this, and it won't hurt either way
services.qemuGuest.enable = true;
}