NixOS 23.11 and Flaking
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
#PROVIDER_PLACEHOLDER
|
#PROVIDER_PLACEHOLDER
|
||||||
];
|
];
|
||||||
|
|
||||||
|
system.stateVersion = "23.05";
|
||||||
|
|
||||||
# Packages installed on the whole system
|
# Packages installed on the whole system
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
curl
|
curl
|
||||||
@@ -54,5 +56,10 @@
|
|||||||
useXkbConfig = true;
|
useXkbConfig = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
system.stateVersion = "23.05";
|
nix = {
|
||||||
|
package = pkgs.nixFlakes;
|
||||||
|
settings = {
|
||||||
|
experimental-features = "nix-command flakes";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
description = "A basic NixOS Vagrant install";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixstable.url = "github:nixos/nixpkgs/nixos-23.05";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixstable, self, ... }@inputs:
|
||||||
|
{
|
||||||
|
nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [ ./configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -36,9 +36,10 @@ mount "${disk}1" /mnt
|
|||||||
# Bootstrap system
|
# Bootstrap system
|
||||||
nixos-generate-config --root /mnt
|
nixos-generate-config --root /mnt
|
||||||
curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix"
|
curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix"
|
||||||
|
curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix"
|
||||||
sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix
|
sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix
|
||||||
sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix
|
sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix
|
||||||
nixos-install --no-root-password
|
nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant"
|
||||||
|
|
||||||
# Run stuff in the chroot
|
# Run stuff in the chroot
|
||||||
curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh"
|
curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh"
|
||||||
|
|||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -exo pipefail
|
||||||
|
|
||||||
|
# Name of the file to write out
|
||||||
|
name="${0%.sh}"
|
||||||
|
|
||||||
|
version="23.11"
|
||||||
|
|
||||||
|
# Base URL
|
||||||
|
base="https://channels.nixos.org/nixos-${version}/latest-nixos-minimal-x86_64-linux.iso"
|
||||||
|
|
||||||
|
# Working directory
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
checksums="${tmp}/checksums"
|
||||||
|
|
||||||
|
# Read the SHA256 sum value
|
||||||
|
curl -L -o "${checksums}" "${base}.sha256"
|
||||||
|
until curl -f -L -o "${checksums}" "${base}.sha256"; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
sha="$(cat "${checksums}" | grep minimal | cut -d' ' -f 1)"
|
||||||
|
|
||||||
|
# Write out HCL file
|
||||||
|
cat << EOF > "${name}"
|
||||||
|
distro = "nixos"
|
||||||
|
version = "${version}"
|
||||||
|
iso = {
|
||||||
|
url = "${base}"
|
||||||
|
checksum = "${sha}"
|
||||||
|
}
|
||||||
|
boot_command = [
|
||||||
|
"<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>",
|
||||||
|
"<wait60>", # Wait for system to come up?
|
||||||
|
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
|
||||||
|
"<wait>",
|
||||||
|
"sudo bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}<enter>"
|
||||||
|
]
|
||||||
|
http_directory = "distros/nixos/23.05/http/"
|
||||||
|
boot_wait = "5s"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm -r "${tmp}"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{config, pkgs, lib, ...}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
#PROVIDER_PLACEHOLDER
|
||||||
|
];
|
||||||
|
|
||||||
|
system.stateVersion = "23.11";
|
||||||
|
|
||||||
|
# Packages installed on the whole system
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
curl
|
||||||
|
nano
|
||||||
|
python3
|
||||||
|
];
|
||||||
|
# Services that are running
|
||||||
|
services = {
|
||||||
|
openssh.enable = true;
|
||||||
|
#xserver.enable = true;
|
||||||
|
};
|
||||||
|
# User setup
|
||||||
|
users.groups.vagrant = {};
|
||||||
|
users.users.vagrant = {
|
||||||
|
isNormalUser = true;
|
||||||
|
group = "vagrant";
|
||||||
|
extraGroups = [ "wheel" ];
|
||||||
|
password = "vagrant";
|
||||||
|
};
|
||||||
|
security.sudo.extraRules = [
|
||||||
|
{
|
||||||
|
users = [ "vagrant" ];
|
||||||
|
groups = [ "vagrant" ];
|
||||||
|
commands = [
|
||||||
|
{ command = "ALL"; options = [ "NOPASSWD" ]; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.loader.grub = {
|
||||||
|
enable = true;
|
||||||
|
devices = [ "@BOOT_DEVICE@" ];
|
||||||
|
};
|
||||||
|
networking = {
|
||||||
|
hostName = "vagrant";
|
||||||
|
networkmanager.enable = true;
|
||||||
|
#proxy.default = "http://user:password@proxy:port/";
|
||||||
|
#proxy.noProxy = "127.0.0.1,localhost,internal.domain";
|
||||||
|
};
|
||||||
|
time.timeZone = "UTC";
|
||||||
|
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
console = {
|
||||||
|
font = "Lat2-Terminux16";
|
||||||
|
keyMap = lib.mkForce "us";
|
||||||
|
useXkbConfig = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nixFlakes;
|
||||||
|
settings = {
|
||||||
|
experimental-features = "nix-command flakes";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
description = "A basic NixOS Vagrant install";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixstable.url = "github:nixos/nixpkgs/nixos-23.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixstable, self, ... }@inputs:
|
||||||
|
{
|
||||||
|
nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [ ./configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# Set passwords
|
||||||
|
echo "vagrant:vagrant" | chpasswd
|
||||||
|
echo "root:vagrant" | chpasswd
|
||||||
|
|
||||||
|
# Set ownership of things vagrant should own
|
||||||
|
chown -R vagrant:vagrant ~vagrant/
|
||||||
|
chown -R vagrant:wheel /etc/nixos
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#vim: set ft=bash:
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
port="${1}" # HTTP port that packer is running on
|
||||||
|
host="${2}"
|
||||||
|
|
||||||
|
if [ -e /dev/vda ]; then
|
||||||
|
disk="/dev/vda"
|
||||||
|
elif [ -e /dev/sda ]; then
|
||||||
|
disk="/dev/sda"
|
||||||
|
else
|
||||||
|
exit 1 # Need to teach the script which device to use in this case
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The sed bit is just to strip out the extra fluff, like comments
|
||||||
|
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk}
|
||||||
|
o # create new DOS partition table
|
||||||
|
n # new
|
||||||
|
p # primary partition
|
||||||
|
1 # part number
|
||||||
|
# default start
|
||||||
|
# default to full disk
|
||||||
|
p # print, for debugging
|
||||||
|
w # write the partition table and exit
|
||||||
|
EOF
|
||||||
|
#t # set partition type
|
||||||
|
#1 # on partition 1
|
||||||
|
#4 # BIOS boot
|
||||||
|
|
||||||
|
# Format and mount partitions
|
||||||
|
mkfs.ext4 -L root "${disk}1"
|
||||||
|
|
||||||
|
mount "${disk}1" /mnt
|
||||||
|
|
||||||
|
# Bootstrap system
|
||||||
|
nixos-generate-config --root /mnt
|
||||||
|
curl -o /mnt/etc/nixos/configuration.nix "http://${host}:${port}/configuration.nix"
|
||||||
|
curl -o /mnt/etc/nixos/flake.nix "http://${host}:${port}/flake.nix"
|
||||||
|
sed -i -E -e "s,@BOOT_DEVICE@,${disk}," /mnt/etc/nixos/configuration.nix
|
||||||
|
sed -i -E -e 's,(.*device = "/dev/disk/).*(".*),\1by-label/root\2,' /mnt/etc/nixos/hardware-configuration.nix
|
||||||
|
nixos-install --no-root-password --flake "/mnt/etc/nixos/#vagrant"
|
||||||
|
|
||||||
|
# Run stuff in the chroot
|
||||||
|
curl -o /mnt/root/in-chroot.sh "http://${host}:${port}/in-chroot.sh"
|
||||||
|
nixos-enter --root /mnt -c 'bash /root/in-chroot.sh'
|
||||||
|
rm /mnt/root/in-chroot.sh
|
||||||
|
|
||||||
|
reboot
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
|
||||||
|
cat << EOF > /etc/nixos/guest-agent.nix
|
||||||
|
{...}:
|
||||||
|
{
|
||||||
|
services.qemuGuest.enable = true;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chown vagrant:vagrant /etc/nixos/guest-agent.nix
|
||||||
|
nixos-rebuild switch
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
|
||||||
|
cat << EOF > /etc/nixos/guest-agent.nix
|
||||||
|
{...}:
|
||||||
|
{
|
||||||
|
virtualisation.virtualbox.guest = {
|
||||||
|
enable = true;
|
||||||
|
x11 = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chown vagrant:vagrant /etc/nixos/guest-agent.nix
|
||||||
|
nixos-rebuild switch
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
sed -i -e 's,#PROVIDER_PLACEHOLDER,./guest-agent.nix,' /etc/nixos/configuration.nix
|
||||||
|
cat << EOF > /etc/nixos/guest-agent.nix
|
||||||
|
{...}:
|
||||||
|
{
|
||||||
|
virtualisation.vmware.guest = {
|
||||||
|
enable = true;
|
||||||
|
headless = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chown vagrant:vagrant /etc/nixos/guest-agent.nix
|
||||||
|
nixos-rebuild switch
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
23.05:
|
23.05: &supp
|
||||||
- arch: amd64
|
- arch: amd64
|
||||||
provider: qemu
|
provider: qemu
|
||||||
- arch: amd64
|
- arch: amd64
|
||||||
provider: virtualbox-iso
|
provider: virtualbox-iso
|
||||||
- arch: amd64
|
- arch: amd64
|
||||||
provider: vmware-iso
|
provider: vmware-iso
|
||||||
|
23.11: *supp
|
||||||
|
|||||||
Reference in New Issue
Block a user