summaryrefslogtreecommitdiffstats
path: root/install.nix
blob: 3217cb53bea1f1e2ce48cf13d9c671f16394b8cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ config, lib, pkgs, ... }:

{
  imports = [
    <nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix>
    <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
    <stockholm/krebs/5pkgs>
    ./base.nix
  ];

  environment.systemPackages = [
    (pkgs.writeDashBin "ni-format" ''
      set -efux
      ${pkgs.parted}/bin/parted ${config.ni-disk} mktable msdos
      ${pkgs.parted}/bin/parted ${config.ni-disk} mkpart primary 1MiB 100%
      ${pkgs.parted}/bin/parted ${config.ni-disk} print
      ${pkgs.btrfs-progs}/bin/mkfs.btrfs ${config.ni-disk}-part1
    '')

    (pkgs.writeDashBin "ni-mount" ''
      set -efux
      if ! ${pkgs.utillinux}/bin/mountpoint /mnt; then
        ${pkgs.coreutils}/bin/install -m 0000 -d /mnt
        ${pkgs.utillinux}/bin/mount ${config.ni-disk}-part1 /mnt
      fi
      if ! ${pkgs.utillinux}/bin/mountpoint ${config.ni-path}; then
        ${pkgs.coreutils}/bin/install -m 0700 -d /mnt${config.ni-path}
        ${pkgs.coreutils}/bin/install -m 0000 -d ${config.ni-path}
        ${pkgs.utillinux}/bin/mount --bind /mnt${config.ni-path} ${config.ni-path}
        ${pkgs.coreutils}/bin/touch /mnt/${config.ni-path}/.populate
      fi
    '')

    # TODO ni-upload-iso
  ];

  isoImage.isoName = "ni-install.iso";
  isoImage.volumeID = "NI_INSTALL_ISO";
  networking.hostName = "ni-install";
}