2006-12-11 17:36:57 +00:00
|
|
|
{ platform ? __currentSystem
|
2006-12-11 16:10:23 +00:00
|
|
|
, configuration
|
2008-06-05 16:33:17 +01:00
|
|
|
, nixpkgsPath ? ../../nixpkgs
|
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 {
|
2008-08-08 20:07:07 +01:00
|
|
|
|
2008-08-06 18:39:05 +01:00
|
|
|
configComponents = [
|
|
|
|
configuration
|
2008-08-08 19:56:58 +01:00
|
|
|
(import ./options.nix)
|
2008-08-06 18:39:05 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
noOption = name: values:
|
|
|
|
abort "${name}: Used without option declaration.";
|
2006-11-02 17:56:50 +00:00
|
|
|
|
2006-12-11 15:47:30 +00:00
|
|
|
# Make a configuration object from which we can retrieve option
|
|
|
|
# values.
|
2008-08-06 18:39:05 +01:00
|
|
|
config =
|
2008-11-09 16:44:31 +00:00
|
|
|
pkgs.lib.fixOptionSets
|
2008-08-06 18:39:05 +01:00
|
|
|
(pkgs.lib.mergeOptionSets noOption)
|
|
|
|
pkgs configComponents;
|
2007-11-09 18:49:45 +00:00
|
|
|
|
2008-08-06 18:39:05 +01:00
|
|
|
optionDeclarations =
|
2008-11-09 16:44:31 +00:00
|
|
|
pkgs.lib.fixOptionSetsFun
|
2008-08-06 19:43:53 +01:00
|
|
|
pkgs.lib.filterOptionSets
|
|
|
|
pkgs configComponents
|
|
|
|
config;
|
2006-12-11 15:47:30 +00:00
|
|
|
|
2008-06-05 16:33:17 +01:00
|
|
|
pkgs = import "${nixpkgsPath}/pkgs/top-level/all-packages.nix" {system = platform;};
|
2006-11-02 17:56:50 +00:00
|
|
|
|
2007-11-09 18:49:45 +00:00
|
|
|
manifests = config.installer.manifests; # exported here because nixos-rebuild uses it
|
2007-08-15 13:01:20 +01:00
|
|
|
|
2008-08-08 19:57:07 +01:00
|
|
|
nix = config.environment.nix;
|
2006-11-17 16:38:24 +00:00
|
|
|
|
2008-08-08 19:57:07 +01:00
|
|
|
kernelPackages = config.boot.kernelPackages;
|
2008-05-22 12:59:46 +01:00
|
|
|
|
|
|
|
kernel = kernelPackages.kernel;
|
2006-11-02 22:48:01 +00:00
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
modulesTree = config.system.modulesTree;
|
2008-05-08 16:36:56 +01:00
|
|
|
|
2006-11-03 00:36:08 +00:00
|
|
|
|
2008-08-08 18:34:30 +01:00
|
|
|
# The initial ramdisk.
|
|
|
|
initialRamdiskStuff = import ../boot/boot-stage-1.nix {
|
2008-11-23 01:29:20 +00:00
|
|
|
inherit pkgs config;
|
2006-11-02 17:56:50 +00:00
|
|
|
};
|
|
|
|
|
2008-08-08 18:34:30 +01:00
|
|
|
initialRamdisk = initialRamdiskStuff.initialRamdisk;
|
|
|
|
|
2006-11-02 22:48:01 +00:00
|
|
|
|
2008-02-08 15:59:15 +00:00
|
|
|
# NixOS installation/updating tools.
|
|
|
|
nixosTools = import ../installer {
|
2008-11-23 01:29:20 +00:00
|
|
|
inherit pkgs config;
|
2007-02-06 13:09:25 +00:00
|
|
|
};
|
|
|
|
|
2006-11-08 09:31:45 +00:00
|
|
|
|
2007-01-15 17:19:41 +00:00
|
|
|
# NSS modules. Hacky!
|
2008-11-18 18:00:09 +00:00
|
|
|
nssModules = config.system.nssModules.list;
|
2007-01-15 17:19:41 +00:00
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
nssModulesPath = config.system.nssModules.path;
|
2007-01-15 17:19:41 +00:00
|
|
|
|
|
|
|
|
2007-03-04 01:16:24 +00:00
|
|
|
# Wrapper around modprobe to set the path to the modules.
|
2008-11-18 18:00:09 +00:00
|
|
|
modprobe = config.system.sbin.modprobe;
|
2007-03-04 01:16:24 +00:00
|
|
|
|
|
|
|
|
2007-11-15 17:16:16 +00:00
|
|
|
# Environment variables for running Nix.
|
2008-11-18 18:00:09 +00:00
|
|
|
nixEnvVars = config.nix.envVars;
|
2007-11-15 17:16:16 +00:00
|
|
|
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
# The static parts of /etc.
|
2007-03-30 13:59:43 +01:00
|
|
|
etc = import ../etc/default.nix {
|
2008-11-18 18:00:09 +00:00
|
|
|
inherit config pkgs systemPath wrapperDir
|
2008-11-23 01:29:20 +00:00
|
|
|
defaultShell;
|
2006-12-09 02:51:42 +00:00
|
|
|
};
|
|
|
|
|
2008-08-08 20:07:07 +01:00
|
|
|
|
2007-10-05 08:25:13 +01:00
|
|
|
# Font aggregation
|
2007-11-15 17:16:16 +00:00
|
|
|
fontDir = import ./fontdir.nix {
|
2008-07-23 15:13:27 +01:00
|
|
|
inherit config pkgs;
|
2008-03-02 18:46:57 +00:00
|
|
|
inherit (pkgs) builderDefs ttmkfdir;
|
2007-11-15 17:16:16 +00:00
|
|
|
inherit (pkgs.xorg) mkfontdir mkfontscale fontalias;
|
|
|
|
};
|
2006-12-11 15:47:30 +00:00
|
|
|
|
2008-08-08 20:07:07 +01:00
|
|
|
|
2006-12-11 15:47:30 +00:00
|
|
|
# The wrapper setuid programs (since we can't have setuid programs
|
2007-01-15 14:43:56 +00:00
|
|
|
# in the Nix store).
|
|
|
|
wrapperDir = "/var/setuid-wrappers";
|
|
|
|
|
2006-11-28 17:34:27 +00:00
|
|
|
setuidWrapper = import ../helpers/setuid {
|
|
|
|
inherit (pkgs) stdenv;
|
2007-01-15 14:43:56 +00:00
|
|
|
inherit wrapperDir;
|
2006-11-28 17:34:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-06 16:48:12 +01:00
|
|
|
# A patched `mount' command that looks in a directory in the Nix
|
|
|
|
# store instead of in /sbin for mount helpers (like mount.ntfs-3g or
|
|
|
|
# mount.cifs).
|
2008-11-18 18:00:09 +00:00
|
|
|
mount = config.system.sbin.mount;
|
2008-08-06 16:48:12 +01:00
|
|
|
|
|
|
|
|
2006-12-09 19:25:23 +00:00
|
|
|
# The packages you want in the boot environment.
|
2008-02-08 15:59:15 +00:00
|
|
|
systemPathList = [
|
2008-01-22 17:55:57 +00:00
|
|
|
# Better leave them here - they are small, needed,
|
|
|
|
# and hard to refer from anywhere outside.
|
2008-02-08 15:59:15 +00:00
|
|
|
modprobe # must take precedence over module_init_tools
|
2008-08-06 16:48:12 +01:00
|
|
|
mount # must take precedence over util-linux
|
2008-01-22 17:55:57 +00:00
|
|
|
nix
|
2008-02-08 15:59:15 +00:00
|
|
|
nixosTools.nixosInstall
|
|
|
|
nixosTools.nixosRebuild
|
|
|
|
nixosTools.nixosCheckout
|
|
|
|
nixosTools.nixosHardwareScan
|
2008-03-03 23:30:49 +00:00
|
|
|
nixosTools.nixosGenSeccureKeys
|
2008-01-22 17:55:57 +00:00
|
|
|
setuidWrapper
|
|
|
|
]
|
2008-02-08 15:59:15 +00:00
|
|
|
++ pkgs.lib.optionals (!config.environment.cleanStart) [
|
2007-03-20 10:40:45 +00:00
|
|
|
pkgs.bashInteractive # bash with ncurses support
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.bzip2
|
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.cpio
|
|
|
|
pkgs.curl
|
|
|
|
pkgs.e2fsprogs
|
|
|
|
pkgs.findutils
|
2006-12-23 22:43:39 +00:00
|
|
|
pkgs.glibc # for ldd, getent
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.gnugrep
|
|
|
|
pkgs.gnused
|
|
|
|
pkgs.gnutar
|
|
|
|
pkgs.grub
|
|
|
|
pkgs.gzip
|
|
|
|
pkgs.iputils
|
|
|
|
pkgs.less
|
2006-12-24 01:07:28 +00:00
|
|
|
pkgs.lvm2
|
2008-02-07 14:39:32 +00:00
|
|
|
pkgs.man
|
2007-01-11 00:06:46 +00:00
|
|
|
pkgs.mdadm
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.module_init_tools
|
|
|
|
pkgs.nano
|
2008-04-10 08:43:49 +01:00
|
|
|
pkgs.ncurses
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.netcat
|
|
|
|
pkgs.nettools
|
2006-12-23 22:43:39 +00:00
|
|
|
pkgs.ntp
|
2007-02-19 22:33:44 +00:00
|
|
|
pkgs.openssh
|
|
|
|
pkgs.pciutils
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.perl
|
|
|
|
pkgs.procps
|
2006-12-11 01:03:26 +00:00
|
|
|
pkgs.pwdutils
|
2007-11-07 22:00:05 +00:00
|
|
|
pkgs.reiserfsprogs
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.rsync
|
2008-03-03 23:30:49 +00:00
|
|
|
pkgs.seccureUser
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.strace
|
2007-01-11 15:32:48 +00:00
|
|
|
pkgs.su
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.sysklogd
|
2007-05-23 15:29:34 +01:00
|
|
|
pkgs.sysvtools
|
2007-04-20 09:51:41 +01:00
|
|
|
pkgs.time
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.udev
|
|
|
|
pkgs.upstart
|
2008-01-18 15:18:32 +00:00
|
|
|
pkgs.usbutils
|
2006-12-09 19:25:23 +00:00
|
|
|
pkgs.utillinux
|
2007-03-28 22:15:23 +01:00
|
|
|
pkgs.wirelesstools
|
2008-02-08 15:59:15 +00:00
|
|
|
]
|
|
|
|
++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo
|
2008-04-01 11:16:35 +01:00
|
|
|
++ pkgs.lib.optional config.services.atd.enable pkgs.at
|
2008-02-20 22:46:53 +00:00
|
|
|
++ pkgs.lib.optional config.services.bitlbee.enable pkgs.bitlbee
|
2008-02-08 15:59:15 +00:00
|
|
|
++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp
|
2008-08-08 19:57:07 +01:00
|
|
|
++ config.environment.extraPackages
|
2008-03-26 16:23:52 +00:00
|
|
|
++ pkgs.lib.optional config.fonts.enableFontDir fontDir
|
2008-06-20 19:17:51 +01:00
|
|
|
++ pkgs.lib.optional config.hardware.enableGo7007 kernelPackages.wis_go7007
|
2006-12-09 19:25:23 +00:00
|
|
|
|
2008-03-26 16:23:52 +00:00
|
|
|
# NSS modules need to be in `systemPath' so that (i) the builder
|
|
|
|
# chroot gets to seem them, and (ii) applications can benefit from
|
|
|
|
# changes in the list of NSS modules at run-time, without requiring
|
|
|
|
# a reboot.
|
|
|
|
++ nssModules;
|
2006-12-09 19:25:23 +00:00
|
|
|
|
2008-08-08 20:07:07 +01:00
|
|
|
|
2007-01-15 14:43:56 +00:00
|
|
|
# We don't want to put all of `startPath' and `path' in $PATH, since
|
|
|
|
# then we get an embarrassingly long $PATH. So use the user
|
|
|
|
# environment builder to make a directory with symlinks to those
|
|
|
|
# packages.
|
|
|
|
systemPath = pkgs.buildEnv {
|
|
|
|
name = "system-path";
|
|
|
|
paths = systemPathList;
|
2008-03-26 16:23:52 +00:00
|
|
|
|
|
|
|
# Note: We need `/lib' to be among `pathsToLink' for NSS modules
|
|
|
|
# to work.
|
2007-12-01 20:44:27 +00:00
|
|
|
inherit (config.environment) pathsToLink;
|
2008-03-26 16:23:52 +00:00
|
|
|
|
2007-01-15 14:43:56 +00:00
|
|
|
ignoreCollisions = true;
|
|
|
|
};
|
|
|
|
|
2007-03-20 13:30:14 +00:00
|
|
|
|
2008-11-18 18:00:09 +00:00
|
|
|
usersGroups = import ./users-groups.nix { inherit pkgs config defaultShell; };
|
2007-06-08 16:41:12 +01:00
|
|
|
|
|
|
|
|
2007-03-20 13:30:14 +00:00
|
|
|
defaultShell = "/var/run/current-system/sw/bin/bash";
|
|
|
|
|
2007-01-15 14:43:56 +00:00
|
|
|
|
2006-12-09 19:25:23 +00:00
|
|
|
# The script that activates the configuration, i.e., it sets up
|
|
|
|
# /etc, accounts, etc. It doesn't do anything that can only be done
|
|
|
|
# at boot time (such as start `init').
|
2008-03-17 10:31:40 +00:00
|
|
|
activateConfiguration = pkgs.substituteAll rec {
|
2006-12-09 19:25:23 +00:00
|
|
|
src = ./activate-configuration.sh;
|
|
|
|
isExecutable = true;
|
|
|
|
|
2007-09-18 16:06:24 +01:00
|
|
|
inherit etc wrapperDir systemPath modprobe defaultShell kernel;
|
2007-11-09 18:49:45 +00:00
|
|
|
hostName = config.networking.hostName;
|
2007-04-07 22:44:26 +01:00
|
|
|
setuidPrograms =
|
2007-11-09 18:49:45 +00:00
|
|
|
config.security.setuidPrograms ++
|
|
|
|
config.security.extraSetuidPrograms ++
|
2008-06-20 14:32:39 +01:00
|
|
|
pkgs.lib.optional config.security.sudo.enable "sudo" ++
|
|
|
|
pkgs.lib.optionals config.services.atd.enable ["at" "atq" "atrm"] ++
|
2008-08-16 01:59:23 +01:00
|
|
|
pkgs.lib.optional (config.services.xserver.sessionType == "kde") "kcheckpass" ++
|
|
|
|
map ( x : x.program ) config.security.setuidOwners;
|
2006-12-09 19:25:23 +00:00
|
|
|
|
2007-06-08 16:41:12 +01:00
|
|
|
inherit (usersGroups) createUsersGroups usersList groupsList;
|
|
|
|
|
2006-12-16 21:48:12 +00:00
|
|
|
path = [
|
2008-03-17 10:31:40 +00:00
|
|
|
pkgs.coreutils pkgs.gnugrep pkgs.findutils
|
|
|
|
pkgs.glibc # needed for getent
|
|
|
|
pkgs.pwdutils
|
2008-03-19 12:34:39 +00:00
|
|
|
];
|
2007-03-20 10:40:45 +00:00
|
|
|
|
|
|
|
bash = pkgs.bashInteractive;
|
2008-06-30 16:13:02 +01:00
|
|
|
|
|
|
|
adjustSetuidOwner = pkgs.lib.concatStrings (map
|
2008-07-23 15:13:27 +01:00
|
|
|
(_entry: let entry = {
|
2008-06-30 16:13:02 +01:00
|
|
|
owner = "nobody";
|
2008-07-23 15:13:27 +01:00
|
|
|
group = "nogroup";
|
|
|
|
setuid = false;
|
|
|
|
setgid = false;
|
2008-06-30 16:13:02 +01:00
|
|
|
} //_entry; in
|
|
|
|
''
|
|
|
|
chown ${entry.owner}.${entry.group} $wrapperDir/${entry.program}
|
2008-07-23 15:13:27 +01:00
|
|
|
chmod u${if entry.setuid then "+" else "-"}s $wrapperDir/${entry.program}
|
|
|
|
chmod g${if entry.setgid then "+" else "-"}s $wrapperDir/${entry.program}
|
2008-06-30 16:13:02 +01:00
|
|
|
'')
|
|
|
|
config.security.setuidOwners);
|
2006-12-09 19:25:23 +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.
|
2006-11-28 10:45:21 +00:00
|
|
|
bootStage2 = import ../boot/boot-stage-2.nix {
|
2007-03-06 00:45:33 +00:00
|
|
|
inherit (pkgs) substituteAll writeText coreutils
|
2007-06-23 16:48:09 +01:00
|
|
|
utillinux udev upstart;
|
2007-09-18 16:06:24 +01:00
|
|
|
inherit kernel activateConfiguration;
|
2008-01-24 16:56:09 +00:00
|
|
|
inherit (config.boot) isLiveCD;
|
2006-12-10 22:29:44 +00:00
|
|
|
upstartPath = [
|
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.findutils
|
|
|
|
pkgs.gnugrep
|
|
|
|
pkgs.gnused
|
2006-12-11 00:52:36 +00:00
|
|
|
pkgs.upstart
|
2006-12-10 22:29:44 +00:00
|
|
|
];
|
2007-11-09 18:49:45 +00:00
|
|
|
bootLocal = config.boot.localCommands;
|
2006-11-27 16:26:51 +00:00
|
|
|
};
|
|
|
|
|
2006-12-11 17:36:57 +00:00
|
|
|
|
|
|
|
# Script to build the Grub menu containing the current and previous
|
|
|
|
# system configurations.
|
|
|
|
grubMenuBuilder = pkgs.substituteAll {
|
|
|
|
src = ../installer/grub-menu-builder.sh;
|
|
|
|
isExecutable = true;
|
|
|
|
inherit (pkgs) bash;
|
|
|
|
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
|
2008-07-05 01:16:39 +01:00
|
|
|
inherit (config.boot) copyKernels extraGrubEntries extraGrubEntriesBeforeNixos
|
2008-01-10 04:43:19 +00:00
|
|
|
grubSplashImage bootMount configurationLimit;
|
2006-12-11 17:36:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# Putting it all together. This builds a store object containing
|
|
|
|
# symlinks to the various parts of the built configuration (the
|
|
|
|
# kernel, the Upstart services, the init scripts, etc.) as well as a
|
|
|
|
# script `switch-to-configuration' that activates the configuration
|
|
|
|
# and makes it bootable.
|
2007-09-25 20:00:20 +01:00
|
|
|
system = pkgs.checker (pkgs.stdenv.mkDerivation {
|
2006-12-11 17:36:57 +00:00
|
|
|
name = "system";
|
|
|
|
builder = ./system.sh;
|
|
|
|
switchToConfiguration = ./switch-to-configuration.sh;
|
2007-09-27 13:24:05 +01:00
|
|
|
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils upstart;
|
2007-11-09 18:49:45 +00:00
|
|
|
grubDevice = config.boot.grubDevice;
|
2006-12-11 17:36:57 +00:00
|
|
|
kernelParams =
|
2008-01-24 16:56:09 +00:00
|
|
|
config.boot.kernelParams ++ config.boot.extraKernelParams;
|
2006-12-11 17:36:57 +00:00
|
|
|
inherit bootStage2;
|
|
|
|
inherit activateConfiguration;
|
|
|
|
inherit grubMenuBuilder;
|
|
|
|
inherit etc;
|
2007-03-20 13:01:53 +00:00
|
|
|
inherit systemPath;
|
2007-09-18 16:06:24 +01:00
|
|
|
kernel = kernel + "/vmlinuz";
|
2006-12-11 17:36:57 +00:00
|
|
|
initrd = initialRamdisk + "/initrd";
|
|
|
|
# Most of these are needed by grub-install.
|
2006-12-18 16:27:56 +00:00
|
|
|
path = [
|
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.gnused
|
|
|
|
pkgs.gnugrep
|
|
|
|
pkgs.findutils
|
|
|
|
pkgs.diffutils
|
|
|
|
pkgs.upstart # for initctl
|
|
|
|
];
|
2008-08-08 16:49:57 +01:00
|
|
|
# !!! wtf does this do???
|
2007-12-20 11:36:30 +00:00
|
|
|
children = map (x: ((import ./system.nix)
|
2008-08-08 16:49:57 +01:00
|
|
|
{ inherit platform;
|
2007-12-31 08:52:59 +00:00
|
|
|
configuration = x//{boot=((x.boot)//{grubDevice = "";});};}).system)
|
2007-12-20 11:36:30 +00:00
|
|
|
config.nesting.children;
|
2007-11-09 18:49:45 +00:00
|
|
|
configurationName = config.boot.configurationName;
|
2008-08-06 18:39:05 +01:00
|
|
|
}) config.environment.checkConfigurationOptions
|
|
|
|
optionDeclarations config;
|
2008-08-08 20:07:07 +01:00
|
|
|
|
2006-11-02 17:56:50 +00:00
|
|
|
}
|