Skip to content

Instantly share code, notes, and snippets.

@infinisil
Created July 28, 2017 16:40
Show Gist options
  • Save infinisil/f43ae5c17ba2b21e52c39bdd205c1bbd to your computer and use it in GitHub Desktop.
Save infinisil/f43ae5c17ba2b21e52c39bdd205c1bbd to your computer and use it in GitHub Desktop.
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot = {
loader = {
efi = {
canTouchEfiVariables = true;
};
grub = {
device = "/dev/sdc";
efiSupport = true;
enable = true;
zfsSupport = true;
};
};
supportedFilesystems = [ "zfs" ];
};
nixpkgs.config.allowUnfree = true;
networking.hostName = "stick";
networking.hostId = "a7634783";
i18n.consoleUseXkbConfig = true;
services.xserver = {
layout = "us";
xkbVariant = "dvp";
};
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "17.09";
}
with import <nixpkgs> {};
{ pool ? "main"
, disk
, altroot ? "/mnt"
}:
let
createFilesystem = ''
set -x
sudo sgdisk -Z -n 1::+200M -t 1:ef00 -n 2:: -g ${disk}
zpool create -f -o ashift=12 -m legacy ${pool} ${disk}2
mkdir -p ${altroot}
mount -t zfs ${pool} ${altroot}
cd ${altroot}
mkdir boot home root var
mkdir nix
mkfs.vfat ${disk}1
mount -t vfat ${disk}1 boot
sudo zfs create -o compress=on ${pool}/nix
mount -t zfs ${pool}/nix nix
sudo zfs create -o compress=on -o snapdir=visible ${pool}/home
mount -t zfs ${pool}/home home
sudo zfs create -o compress=on -o snapdir=visible ${pool}/root
mount -t zfs ${pool}/root root
sudo zfs create -o snapdir=visible ${pool}/var
mount -t zfs ${pool}/var var
mkdir -p etc/nixos
'';
in writeScript "setup" ''
${createFilesystem}
cp ${./configuration.nix} etc/nixos/configuration.nix
nixos-generate-config --root ${altroot}
nixos-install
''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment