2006-11-12 18:48:47 +00:00
|
|
|
{ system ? __currentSystem
|
|
|
|
, autoDetectRootDevice ? false
|
|
|
|
, rootDevice ? ""
|
|
|
|
, rootLabel ? ""
|
2006-11-13 11:41:27 +00:00
|
|
|
, stage2Init
|
|
|
|
, readOnlyRoot
|
2006-11-12 18:48:47 +00:00
|
|
|
}:
|
2006-11-04 12:00:05 +00:00
|
|
|
|
2006-11-02 17:56:50 +00:00
|
|
|
rec {
|
|
|
|
|
2006-11-04 12:00:05 +00:00
|
|
|
pkgs = import ./pkgs/top-level/all-packages.nix {inherit system;};
|
2006-11-02 17:56:50 +00:00
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
pkgsDiet = import ./pkgs/top-level/all-packages.nix {
|
2006-11-04 12:00:05 +00:00
|
|
|
inherit system;
|
2006-11-02 22:48:01 +00:00
|
|
|
bootStdenv = pkgs.useDietLibC pkgs.stdenv;
|
|
|
|
};
|
|
|
|
|
2006-11-03 13:35:02 +00:00
|
|
|
pkgsStatic = import ./pkgs/top-level/all-packages.nix {
|
2006-11-04 12:00:05 +00:00
|
|
|
inherit system;
|
2006-11-03 13:35:02 +00:00
|
|
|
bootStdenv = pkgs.makeStaticBinaries pkgs.stdenv;
|
|
|
|
};
|
|
|
|
|
2006-11-02 17:56:50 +00:00
|
|
|
stdenvLinuxStuff = import ./pkgs/stdenv/linux {
|
|
|
|
system = pkgs.stdenv.system;
|
|
|
|
allPackages = import ./pkgs/top-level/all-packages.nix;
|
|
|
|
};
|
|
|
|
|
2006-11-17 16:38:24 +00:00
|
|
|
nix = pkgs.nixUnstable; # we need the exportReferencesGraph feature
|
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
|
2006-11-03 00:36:08 +00:00
|
|
|
# Determine the set of modules that we need to mount the root FS.
|
|
|
|
modulesClosure = import ./modules-closure.nix {
|
2006-11-03 11:47:40 +00:00
|
|
|
inherit (pkgs) stdenv kernel module_init_tools;
|
|
|
|
rootModules = ["ide-cd" "ide-disk" "ide-generic"];
|
2006-11-03 00:36:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-03 13:35:02 +00:00
|
|
|
# Some additional utilities needed in stage 1, notably mount. We
|
|
|
|
# don't want to bring in all of util-linux, so we just copy what we
|
|
|
|
# need.
|
|
|
|
extraUtils = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "extra-utils";
|
|
|
|
builder = builtins.toFile "builder.sh"
|
2006-11-06 22:21:50 +00:00
|
|
|
"source $stdenv/setup; ensureDir $out/bin; cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin; nuke-refs $out/bin/*";
|
2006-11-03 13:35:02 +00:00
|
|
|
buildInputs = [pkgs.nukeReferences];
|
|
|
|
inherit (pkgsStatic) utillinux;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
# The init script of boot stage 1 (loading kernel modules for
|
|
|
|
# mounting the root FS).
|
|
|
|
bootStage1 = import ./boot-stage-1.nix {
|
2006-11-03 13:35:02 +00:00
|
|
|
inherit (pkgs) genericSubstituter;
|
2006-11-03 11:47:40 +00:00
|
|
|
inherit (pkgsDiet) module_init_tools;
|
2006-11-03 13:35:02 +00:00
|
|
|
inherit extraUtils;
|
2006-11-12 18:48:47 +00:00
|
|
|
inherit autoDetectRootDevice rootDevice rootLabel;
|
2006-11-13 11:41:27 +00:00
|
|
|
inherit stage2Init;
|
2006-11-03 11:47:40 +00:00
|
|
|
modules = modulesClosure;
|
2006-11-02 22:48:01 +00:00
|
|
|
shell = stdenvLinuxStuff.bootstrapTools.bash;
|
|
|
|
staticTools = stdenvLinuxStuff.staticTools;
|
|
|
|
};
|
2006-11-02 17:56:50 +00:00
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
|
|
|
|
# The closure of the init script of boot stage 1 is what we put in
|
|
|
|
# the initial RAM disk.
|
2006-11-02 17:56:50 +00:00
|
|
|
initialRamdisk = import ./make-initrd.nix {
|
2006-11-17 14:13:21 +00:00
|
|
|
inherit (pkgs) stdenv cpio;
|
2006-11-02 22:48:01 +00:00
|
|
|
init = bootStage1;
|
2006-11-02 17:56:50 +00:00
|
|
|
};
|
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
|
2006-11-08 09:31:45 +00:00
|
|
|
# The installer.
|
|
|
|
nixosInstaller = import ./installer.nix {
|
2006-11-17 14:13:21 +00:00
|
|
|
inherit (pkgs) stdenv genericSubstituter;
|
2006-11-17 16:38:24 +00:00
|
|
|
inherit nix;
|
2006-11-08 09:31:45 +00:00
|
|
|
shell = pkgs.bash + "/bin/sh";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-19 20:07:45 +00:00
|
|
|
# The services (Upstart) configuration for the system.
|
|
|
|
upstartJobs = import ./upstart-jobs/gather.nix {
|
|
|
|
inherit (pkgs) stdenv;
|
|
|
|
|
2006-11-19 21:03:22 +00:00
|
|
|
jobs = map makeJob [
|
2006-11-19 20:07:45 +00:00
|
|
|
# Syslogd.
|
|
|
|
(import ./upstart-jobs/syslogd.nix {
|
2006-11-19 21:03:22 +00:00
|
|
|
inherit (pkgs) sysklogd;
|
2006-11-19 20:07:45 +00:00
|
|
|
})
|
2006-11-19 22:05:49 +00:00
|
|
|
|
2006-11-20 17:28:08 +00:00
|
|
|
# Hardware scan; loads modules for PCI devices.
|
|
|
|
(import ./upstart-jobs/hardware-scan.nix {
|
|
|
|
inherit (pkgs) kernel module_init_tools;
|
|
|
|
})
|
|
|
|
|
2006-11-20 17:06:44 +00:00
|
|
|
# Network interfaces.
|
|
|
|
(import ./upstart-jobs/network-interfaces.nix {
|
2006-11-20 17:28:08 +00:00
|
|
|
inherit (pkgs) nettools kernel module_init_tools;
|
2006-11-20 17:06:44 +00:00
|
|
|
})
|
|
|
|
|
2006-11-19 22:05:49 +00:00
|
|
|
# DHCP client.
|
|
|
|
(import ./upstart-jobs/dhclient.nix {
|
|
|
|
dhcp = pkgs.dhcpWrapper;
|
|
|
|
})
|
2006-11-20 20:50:52 +00:00
|
|
|
|
|
|
|
# Handles the maintenance/stalled event (single-user shell).
|
|
|
|
(import ./upstart-jobs/maintenance-shell.nix {
|
|
|
|
inherit (pkgs) bash;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Handles the reboot/halt events.
|
|
|
|
(import ./upstart-jobs/halt.nix {
|
|
|
|
inherit (pkgs) bash;
|
|
|
|
})
|
2006-11-19 21:03:22 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# The terminals on ttyX.
|
|
|
|
++ (map
|
|
|
|
(ttyNumber: makeJob (import ./upstart-jobs/mingetty.nix {
|
|
|
|
mingetty = pkgs.mingettyWrapper;
|
|
|
|
inherit ttyNumber;
|
|
|
|
}))
|
|
|
|
[1 2 3 4 5 6]
|
|
|
|
)
|
|
|
|
|
|
|
|
# For the builtin logd job.
|
|
|
|
++ [pkgs.upstart];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
makeJob = import ./upstart-jobs/make-job.nix {
|
|
|
|
inherit (pkgs) stdenv;
|
2006-11-19 20:07:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-04 00:01:13 +00:00
|
|
|
# The init script of boot stage 2, which is supposed to do
|
|
|
|
# everything else to bring up the system.
|
|
|
|
bootStage2 = import ./boot-stage-2.nix {
|
2006-11-07 22:05:27 +00:00
|
|
|
inherit (pkgs) genericSubstituter coreutils findutils
|
2006-11-20 17:28:08 +00:00
|
|
|
utillinux kernel udev
|
2006-11-20 17:06:44 +00:00
|
|
|
upstart;
|
2006-11-19 20:07:45 +00:00
|
|
|
inherit upstartJobs;
|
2006-11-04 00:01:13 +00:00
|
|
|
shell = pkgs.bash + "/bin/sh";
|
2006-11-04 13:25:10 +00:00
|
|
|
|
|
|
|
# Additional stuff; add whatever you want here.
|
|
|
|
path = [
|
|
|
|
pkgs.bash
|
|
|
|
pkgs.bzip2
|
|
|
|
pkgs.cpio
|
|
|
|
pkgs.curl
|
|
|
|
pkgs.e2fsprogs
|
|
|
|
pkgs.gnugrep
|
|
|
|
pkgs.gnused
|
|
|
|
pkgs.gnutar
|
|
|
|
pkgs.grub
|
|
|
|
pkgs.gzip
|
|
|
|
pkgs.iputils
|
|
|
|
pkgs.less
|
2006-11-20 17:28:08 +00:00
|
|
|
pkgs.module_init_tools
|
2006-11-04 13:25:10 +00:00
|
|
|
pkgs.nano
|
|
|
|
pkgs.netcat
|
2006-11-20 17:06:44 +00:00
|
|
|
pkgs.nettools
|
2006-11-17 15:27:31 +00:00
|
|
|
pkgs.perl
|
2006-11-06 22:21:50 +00:00
|
|
|
pkgs.procps
|
2006-11-17 15:27:31 +00:00
|
|
|
pkgs.rsync
|
2006-11-06 22:21:50 +00:00
|
|
|
pkgs.shadowutils
|
2006-11-17 15:27:31 +00:00
|
|
|
pkgs.strace
|
2006-11-06 22:21:50 +00:00
|
|
|
pkgs.sysklogd
|
2006-11-19 18:16:29 +00:00
|
|
|
# pkgs.sysvinit
|
2006-11-17 15:27:31 +00:00
|
|
|
# pkgs.vim
|
2006-11-17 16:38:24 +00:00
|
|
|
nix
|
2006-11-08 09:31:45 +00:00
|
|
|
nixosInstaller
|
2006-11-04 13:25:10 +00:00
|
|
|
];
|
2006-11-06 22:21:50 +00:00
|
|
|
|
2006-11-13 11:41:27 +00:00
|
|
|
inherit readOnlyRoot;
|
2006-11-04 00:01:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-02 17:56:50 +00:00
|
|
|
}
|