mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
* Add a top-level default.nix for NixOS which has attributes useful
for building parts of the system. E.g. $ nix-build /etc/nixos/nixos -A upstartJobs.xserver to build the Upstart job for the X server, or $ nix-build /etc/nixos/nixos -A kernel to build the NixOS kernel. * /etc/profile.sh: if ~/.nix-defexpr doesn't exist yet, create it as a directory and add links to root's channels, /etc/nixos/nixos and /etc/nixos/install-source.nix (as "nixpkgs_sys"). * boot.useKernel -> boot.kernel. svn path=/nixos/trunk/; revision=9334
This commit is contained in:
parent
0d1aa83fea
commit
f2780fdc62
40
default.nix
Normal file
40
default.nix
Normal file
@ -0,0 +1,40 @@
|
||||
let
|
||||
|
||||
configFileName =
|
||||
let env = builtins.getEnv "NIXOS_CONFIG"; in
|
||||
if env == "" then /etc/nixos/configuration.nix else env;
|
||||
|
||||
system = import system/system.nix {configuration = import configFileName;};
|
||||
|
||||
in
|
||||
|
||||
{ inherit (system)
|
||||
activateConfiguration
|
||||
bootStage1
|
||||
bootStage2
|
||||
etc
|
||||
extraUtils
|
||||
grubMenuBuilder
|
||||
initialRamdisk
|
||||
kernel
|
||||
nix
|
||||
nixosCheckout
|
||||
nixosInstall
|
||||
nixosRebuild
|
||||
system
|
||||
systemPath
|
||||
config
|
||||
;
|
||||
|
||||
manifests = system.config.get ["installer" "manifests"]; # exported here because nixos-rebuild uses it
|
||||
|
||||
upstartJobsCombined = system.upstartJobs;
|
||||
|
||||
# Make it easier to build individual Upstart jobs (e.g., "nix-build
|
||||
# /etc/nixos/nixos -A upstartJobs.xserver").
|
||||
upstartJobs = { recurseForDerivations = true; } //
|
||||
builtins.listToAttrs (map (job:
|
||||
{ attr = if job ? jobName then job.jobName else job.name; value = job; }
|
||||
) system.upstartJobs.jobs);
|
||||
|
||||
}
|
@ -62,9 +62,15 @@ fi
|
||||
|
||||
|
||||
# Set up a default Nix expression from which to install stuff.
|
||||
if ! test -L $HOME/.nix-defexpr; then
|
||||
if test ! -e $HOME/.nix-defexpr -o -L $HOME/.nix-defexpr; then
|
||||
echo "creating $HOME/.nix-defexpr" >&2
|
||||
ln -s /etc/nixos/install-source.nix $HOME/.nix-defexpr
|
||||
rm -f $HOME/.nix-defexpr
|
||||
mkdir $HOME/.nix-defexpr
|
||||
ln -s /etc/nixos/install-source.nix $HOME/.nix-defexpr/nixpkgs_sys
|
||||
ln -s /etc/nixos/nixos $HOME/.nix-defexpr/nixos
|
||||
if test "$USER" != root; then
|
||||
ln -s /nix/var/nix/gcroots/per-user/root/channels $HOME/.nix-defexpr/channels_root
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
@ -31,10 +31,7 @@ if test -z "$NIXOS_CONFIG"; then NIXOS_CONFIG=/etc/nixos/configuration.nix; fi
|
||||
# Pull the manifests defined in the configuration (the "manifests"
|
||||
# attribute). Wonderfully hacky.
|
||||
if test -z "$NIXOS_NO_PULL"; then
|
||||
manifests=$(nix-instantiate --eval-only --xml --strict \
|
||||
$NIXOS/system/system.nix \
|
||||
--arg configuration "import $NIXOS_CONFIG" \
|
||||
-A manifests \
|
||||
manifests=$(nix-instantiate --eval-only --xml --strict $NIXOS -A manifests \
|
||||
| grep '<string' | sed 's^.*"\(.*\)".*^\1^g')
|
||||
|
||||
for i in $manifests; do
|
||||
@ -47,14 +44,10 @@ fi
|
||||
# or "boot"), or just build it and create a symlink "result" in the
|
||||
# current directory (for "build" and "test").
|
||||
if test "$action" = "switch" -o "$action" = "boot"; then
|
||||
nix-env -p /nix/var/nix/profiles/system -f $NIXOS/system/system.nix \
|
||||
--arg configuration "import $NIXOS_CONFIG" \
|
||||
--set -A system
|
||||
nix-env -p /nix/var/nix/profiles/system -f $NIXOS --set -A system
|
||||
pathToConfig=/nix/var/nix/profiles/system
|
||||
elif test "$action" = "test" -o "$action" = "build"; then
|
||||
nix-build $NIXOS/system/system.nix \
|
||||
--arg configuration "import $NIXOS_CONFIG" \
|
||||
-A system -K -k
|
||||
nix-build $NIXOS -A system -K -k
|
||||
pathToConfig=./result
|
||||
else
|
||||
showSyntax
|
||||
|
@ -56,8 +56,8 @@
|
||||
}
|
||||
|
||||
{
|
||||
name = ["boot" "useKernel"];
|
||||
default = pkgs :(pkgs.kernel);
|
||||
name = ["boot" "kernel"];
|
||||
default = pkgs: pkgs.kernel;
|
||||
description = "
|
||||
Function that takes package collection and returns kernel
|
||||
package. Do not collect old generations after changing it
|
||||
|
@ -31,7 +31,7 @@ rec {
|
||||
|
||||
nix = pkgs.nixUnstable; # we need the exportReferencesGraph feature
|
||||
|
||||
useKernel = (config.get ["boot" "useKernel"]) pkgs;
|
||||
kernel = (config.get ["boot" "kernel"]) pkgs;
|
||||
|
||||
rootModules =
|
||||
(config.get ["boot" "initrd" "extraKernelModules"]) ++
|
||||
@ -41,8 +41,7 @@ rec {
|
||||
# Determine the set of modules that we need to mount the root FS.
|
||||
modulesClosure = import ../helpers/modules-closure.nix {
|
||||
inherit (pkgs) stdenv module_init_tools;
|
||||
kernel = useKernel;
|
||||
inherit rootModules;
|
||||
inherit kernel rootModules;
|
||||
};
|
||||
|
||||
|
||||
@ -147,7 +146,7 @@ rec {
|
||||
src = ./modprobe;
|
||||
isExecutable = true;
|
||||
inherit (pkgs) module_init_tools;
|
||||
kernel = useKernel;
|
||||
inherit kernel;
|
||||
};
|
||||
|
||||
|
||||
@ -253,8 +252,7 @@ rec {
|
||||
src = ./activate-configuration.sh;
|
||||
isExecutable = true;
|
||||
|
||||
inherit etc wrapperDir systemPath modprobe defaultShell;
|
||||
kernel = useKernel;
|
||||
inherit etc wrapperDir systemPath modprobe defaultShell kernel;
|
||||
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
|
||||
hostName = config.get ["networking" "hostName"];
|
||||
setuidPrograms =
|
||||
@ -281,8 +279,7 @@ rec {
|
||||
bootStage2 = import ../boot/boot-stage-2.nix {
|
||||
inherit (pkgs) substituteAll writeText coreutils
|
||||
utillinux udev upstart;
|
||||
kernel = useKernel;
|
||||
inherit activateConfiguration;
|
||||
inherit kernel activateConfiguration;
|
||||
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
|
||||
upstartPath = [
|
||||
pkgs.coreutils
|
||||
@ -326,7 +323,7 @@ rec {
|
||||
inherit grubMenuBuilder;
|
||||
inherit etc;
|
||||
inherit systemPath;
|
||||
kernel = useKernel + "/vmlinuz";
|
||||
kernel = kernel + "/vmlinuz";
|
||||
initrd = initialRamdisk + "/initrd";
|
||||
# Most of these are needed by grub-install.
|
||||
path = [
|
||||
|
@ -5,8 +5,8 @@
|
||||
job.jobDrv
|
||||
else
|
||||
(
|
||||
runCommand job.name {inherit (job) job;}
|
||||
"ensureDir $out/etc/event.d; echo \"$job\" > $out/etc/event.d/$name"
|
||||
runCommand ("upstart-" + job.name) {inherit (job) job; jobName = job.name;}
|
||||
"ensureDir $out/etc/event.d; echo \"$job\" > $out/etc/event.d/$jobName"
|
||||
)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user