mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-10-03 23:17:50 +03:00
Cleanup (#17)
* rename eval-format.nix to nixos-generate.nix Make it clear that it's meant to be used by the nixos-generate script * rename config.nix to configuration.nix Bring the name closer to /etc/nixos/configuration.nix * fix the NIXOS_CONFIG this is the env name that nixos-rebuild uses * use -I to load the configuration and format This has a nice side-effect of allowing URLs as configuration * add Travis CI * cleanSource * gitignore nix result files * use modulesPath everywhere this makes sure that the passed pkgs in nixos-generate.nix is the same one we use to load these other modules * use toString to avoid evaluation error
This commit is contained in:
parent
65ca979a13
commit
0cce7924f1
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
*.qcow2
|
||||
result
|
||||
result-*
|
||||
|
6
.travis.yml
Normal file
6
.travis.yml
Normal file
@ -0,0 +1,6 @@
|
||||
language: nix
|
||||
|
||||
sudo: false
|
||||
|
||||
script:
|
||||
- nix-build
|
2
Makefile
2
Makefile
@ -10,4 +10,4 @@ install:
|
||||
-e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \
|
||||
nixos-generate > $(PREFIX)/bin/nixos-generate
|
||||
chmod 755 $(PREFIX)/bin/nixos-generate
|
||||
cp -r formats config.nix eval-format.nix $(SHARE)
|
||||
cp -r formats configuration.nix nixos-generate.nix $(SHARE)
|
||||
|
@ -3,7 +3,7 @@
|
||||
The nixos-generators project allows to take the same NixOS configuration, and
|
||||
generate outputs for different target formats.
|
||||
|
||||
Just put your stuff into the config.nix and then call one of the image builders.
|
||||
Just put your stuff into the configuration.nix and then call one of the image builders.
|
||||
|
||||
for example:
|
||||
```
|
||||
|
@ -3,7 +3,7 @@
|
||||
with pkgs;
|
||||
stdenv.mkDerivation {
|
||||
name = "nixos-generators";
|
||||
src = ./.;
|
||||
src = lib.cleanSource ./.;
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
installFlags = [ "PREFIX=$(out)" ];
|
||||
postFixup = ''
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ config, lib , ... }:
|
||||
{ config, lib, modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix>
|
||||
"${toString modulesPath}/installer/cd-dvd/installation-cd-base.nix"
|
||||
];
|
||||
|
||||
# for installer
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ config, ... }:
|
||||
{ config, modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix>
|
||||
"${toString modulesPath}/installer/cd-dvd/iso-image.nix"
|
||||
];
|
||||
|
||||
# EFI booting
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ config, pkgs, lib, ... }: let
|
||||
{ config, pkgs, lib, modulesPath, ... }: let
|
||||
|
||||
clever-tests = builtins.fetchGit {
|
||||
url = https://github.com/cleverca22/nix-tests;
|
||||
@ -6,14 +6,14 @@
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/installer/netboot/netboot-minimal.nix>
|
||||
"${toString modulesPath}/installer/netboot/netboot-minimal.nix"
|
||||
"${clever-tests}/kexec/autoreboot.nix"
|
||||
"${clever-tests}/kexec/kexec.nix"
|
||||
"${clever-tests}/kexec/justdoit.nix"
|
||||
];
|
||||
|
||||
system.build = rec {
|
||||
kexec_tarball = pkgs.callPackage <nixpkgs/nixos/lib/make-system-tarball.nix> {
|
||||
kexec_tarball = pkgs.callPackage "${toString modulesPath}/../lib/make-system-tarball.nix" {
|
||||
storeContents = [
|
||||
{ object = config.system.build.kexec_script; symlink = "/kexec_nixos"; }
|
||||
];
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ ... }:
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/maintainers/scripts/openstack/nova-image.nix>
|
||||
"${toString modulesPath}/../maintainers/scripts/openstack/nova-image.nix"
|
||||
];
|
||||
|
||||
formatAttr = "novaImage";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
{
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
@ -11,7 +11,7 @@
|
||||
boot.loader.timeout = 0;
|
||||
|
||||
|
||||
system.build.qcow = import <nixpkgs/nixos/lib/make-disk-image.nix> {
|
||||
system.build.qcow = import "${toString modulesPath}/../lib/make-disk-image.nix" {
|
||||
inherit lib config pkgs;
|
||||
diskSize = 8192;
|
||||
format = "qcow2";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
{
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
@ -11,7 +11,7 @@
|
||||
boot.loader.timeout = 0;
|
||||
|
||||
|
||||
system.build.raw = import <nixpkgs/nixos/lib/make-disk-image.nix> {
|
||||
system.build.raw = import "${toString modulesPath}/../lib/make-disk-image.nix" {
|
||||
inherit lib config pkgs;
|
||||
diskSize = 2048;
|
||||
format = "raw";
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ ... }:
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/virtualisation/virtualbox-image.nix>
|
||||
"${toString modulesPath}/virtualisation/virtualbox-image.nix"
|
||||
];
|
||||
|
||||
formatAttr = "virtualBoxOVA";
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ ... }:
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||
"${toString modulesPath}/virtualisation/qemu-vm.nix"
|
||||
];
|
||||
|
||||
virtualisation.qemu.networkingOptions = [
|
||||
|
@ -5,9 +5,9 @@ set -euo pipefail
|
||||
## Configuration
|
||||
|
||||
libexec_dir="${0%/*}"
|
||||
configuration_path=${NIX_CONFIG:-$libexec_dir/config.nix}
|
||||
configuration=${NIXOS_CONFIG:-$libexec_dir/configuration.nix}
|
||||
format=
|
||||
format_dir=$libexec_dir/formats
|
||||
format_path=
|
||||
target_system=
|
||||
run=
|
||||
|
||||
@ -21,7 +21,7 @@ Options:
|
||||
|
||||
* --help: shows this help
|
||||
* -c, --configuration PATH:
|
||||
select the nixos configuration to build. Default: $configuration_path
|
||||
select the nixos configuration to build. Default: $configuration
|
||||
* -f, --format NAME: select one of the pre-determined formats
|
||||
* --format-path PATH: pass a custom format
|
||||
* --list: list the available built-in formats
|
||||
@ -47,15 +47,15 @@ abort() {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-c | --configuration)
|
||||
configuration_path=$2
|
||||
configuration=$2
|
||||
shift
|
||||
;;
|
||||
-f | --format)
|
||||
format_path=$format_dir/$2.nix
|
||||
format=$format_dir/$2.nix
|
||||
shift
|
||||
;;
|
||||
--format-path)
|
||||
format_path=$2
|
||||
format=$2
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
@ -69,8 +69,8 @@ while [[ $# -gt 0 ]]; do
|
||||
--run)
|
||||
run=1
|
||||
# default to the VM format
|
||||
if [[ -z $format_path ]]; then
|
||||
format_path=$format_dir/vm.nix
|
||||
if [[ -z $format ]]; then
|
||||
format=$format_dir/vm.nix
|
||||
fi
|
||||
;;
|
||||
--system)
|
||||
@ -84,21 +84,14 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $format_path ]]; then
|
||||
if [[ -z $format ]]; then
|
||||
abort "missing format. use --help for more details"
|
||||
fi
|
||||
|
||||
if [[ ! -e $format_path ]]; then
|
||||
abort "format '$format_path' not found"
|
||||
fi
|
||||
|
||||
configuration_path=$(realpath "$configuration_path")
|
||||
format_path=$(realpath "$format_path")
|
||||
|
||||
args=(
|
||||
"$libexec_dir/eval-format.nix"
|
||||
--arg configuration "$configuration_path"
|
||||
--arg formatConfig "$format_path"
|
||||
"$libexec_dir/nixos-generate.nix"
|
||||
-I "nixos-config=$configuration"
|
||||
-I "format-config=$format"
|
||||
)
|
||||
|
||||
if [[ -n $target_system ]]; then
|
||||
|
@ -1,7 +1,6 @@
|
||||
{ nixpkgs ? <nixpkgs>
|
||||
, configuration ?
|
||||
import "${toString nixpkgs}/nixos/lib/from-env.nix" "NIXOS_CONFIG" <nixos-config>
|
||||
, formatConfig
|
||||
, configuration ? <nixos-config>
|
||||
, format-config ? <format-config>
|
||||
, system ? builtins.currentSystem
|
||||
}:
|
||||
let
|
||||
@ -18,7 +17,7 @@ import "${toString nixpkgs}/nixos/lib/eval-config.nix" {
|
||||
inherit system;
|
||||
modules = [
|
||||
module
|
||||
formatConfig
|
||||
format-config
|
||||
configuration
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue
Block a user