Giter Club home page Giter Club logo

nixbox's Introduction

NixOS boxes for Vagrant

NixOS is a linux distribution based on a purely functional package manager. This project builds vagrant .box images.

Status

stable

Usage

vagrant init nixos/nixos-18.09-i686
# or
vagrant init nixos/nixos-18.09-x86_64

Also have a look at the accompanying nixos vagrant plugin: https://github.com/nix-community/vagrant-nixos-plugin

Auto Vars File

iso_checksums

The nixos.auto.pkvars.hcl file contains two defined variables that are required to build a box. The packer template will dereference the iso checksum from the iso_checksums variable. If a checksum does not exist for the version and architecture you are trying to build, the packer build will fail. Be sure to add the proper checksum for the ISO you would like to use to the iso_checksums map, if it does not already exist, before building.

version

Use the version variable to set the version of NixOS you want to build. By convention, this is usually set to the latest stable version of NixOS.

Building the images

First install packer and virtualbox.

Four packer builders are currently supported:

  • Virtualbox (BUILDER=virtualbox-iso.virtualbox)
  • qemu / libvirt (BUILDER=qemu.qemu)
  • VMware (BUILDER=vmware-iso.vmware)
  • Hyper-V (BUILDER=hyperv-iso.hyperv)

Have a look at the different make build target to build your image.

make build-all # Build latest version for all architectures
make VERSION=22.05 build # Build specific version for x86_64 architecture
make VERSION=22.05 ARCH=i686 build # Build specific version for specific architecture

make vagrant-add
make vagrant-push

If you build on a host that does not support Makefile, here are some examples:

packer build --only=virtualbox-iso.virtualbox -var version=22.05 nixos.pkr.hcl
packer build --only=qemu.qemu -var version=22.05 nixos.pkr.hcl
packer build --only=vmware-iso.vmware -var version=22.05 nixos.pkr.hcl
packer build -var-file="nixos.auto.pkvars.hcl" --only=hyperv-iso.hyperv nixos.pkr.hcl

The vagrant .box image is now ready to go and you can use it in vagrant:

vagrant box add nixbox32 nixos-22.05-libvirt-i686.box
# or
vagrant box add nixbox64 nixos-22.05-virtualbox-x86_64.box

Troubleshooting

  • If you build on a Windows OS, please make sure you keep the unix file encoding of the generated configuration files (see issue#30

  • Timeouts are a common issue for build failures. These can be a bit tough to figure out. increase the boot_wait value in nixos.auto.pkvars.hcl if you think timeouts may be the cause of your build failures.

Sample Vagrantfile

Vagrant.configure("2") do |config|

  # Disable shared virtualbox mount path (not vboxsf installed on guest)
  config.vm.synced_folder '.', '/vagrant', disabled: true

  # Use a suitable NixOS base. VM built with nixbox are tested to work with
  # this plugin.
  config.vm.box = "nixos-22.05"

  # Add the htop package
  config.vm.provision :nixos,
    run: 'always',
    expression: {
      environment: {
        systemPackages: [ :htop ]
      }
    }

end

License

Copyright 2022 under the MIT Copyright 2015 under the MIT

nixbox's People

Contributors

zimbatm avatar pierrer avatar cdituri avatar ifurther avatar pradermecker avatar badele avatar dasj avatar manojkarthick avatar dysinger avatar nickryand avatar keblek avatar jeffbr13 avatar billwanjohi avatar davejagoda avatar ethnt avatar cambid avatar mic92 avatar luckynum7 avatar supersandro2000 avatar stefandeml avatar tboerger avatar chronicc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.