Start moving the "activate configuration" script to be extensible.
svn path=/nixos/branches/fix-style/; revision=13675
This commit is contained in:
parent
c787cb1a0a
commit
e7e45dbd2c
|
@ -0,0 +1,43 @@
|
|||
# generate the script used to activate the configuration.
|
||||
{pkgs, config, ...}:
|
||||
|
||||
let
|
||||
inherit (pkgs.stringsWithDeps) textClosureOverridable;
|
||||
inherit (pkgs.lib) mkOption mergeTypedOption mergeAttrs mapRecordFlatten id;
|
||||
|
||||
textClosure = steps:
|
||||
textClosureOverridable steps
|
||||
(["#!/bin/sh"] ++ (mapRecordFlatten (a: v: v) steps));
|
||||
|
||||
aggregateScripts = name: steps:
|
||||
pkgs.writeScript name (textClosure steps);
|
||||
in
|
||||
|
||||
{
|
||||
system = {
|
||||
activationScripts = mkOption {
|
||||
default = [];
|
||||
example = {
|
||||
stdio = {
|
||||
text = "
|
||||
# Needed by some programs.
|
||||
ln -sfn /proc/self/fd /dev/fd
|
||||
ln -sfn /proc/self/fd/0 /dev/stdin
|
||||
ln -sfn /proc/self/fd/1 /dev/stdout
|
||||
ln -sfn /proc/self/fd/2 /dev/stderr
|
||||
";
|
||||
deps = [];
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Activate the new configuration (i.e., update /etc, make accounts,
|
||||
and so on).
|
||||
'';
|
||||
merge = mergeTypedOption "script" builtins.isAttrs mergeAttrs;
|
||||
apply = lib: {
|
||||
inherit lib; # used to fetch dependencies.
|
||||
script = aggregateScripts "activationScript" lib;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,20 +1,6 @@
|
|||
#! @shell@
|
||||
|
||||
systemConfig="$1"
|
||||
if test -z "$systemConfig"; then
|
||||
systemConfig="/system" # for the installation CD
|
||||
fi
|
||||
|
||||
export PATH=/empty
|
||||
for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done
|
||||
|
||||
|
||||
# Needed by some programs.
|
||||
ln -sfn /proc/self/fd /dev/fd
|
||||
ln -sfn /proc/self/fd/0 /dev/stdin
|
||||
ln -sfn /proc/self/fd/1 /dev/stdout
|
||||
ln -sfn /proc/self/fd/2 /dev/stderr
|
||||
|
||||
source @newActivationScript@
|
||||
|
||||
# Set up the statically computed bits of /etc.
|
||||
staticEtc=/etc/static
|
||||
|
|
|
@ -2912,6 +2912,8 @@ root ALL=(ALL) SETENV: ALL
|
|||
|
||||
require = [
|
||||
# system
|
||||
(import ../system/system-options.nix)
|
||||
(import ../system/activate-configuration.nix)
|
||||
(import ../upstart-jobs/default.nix)
|
||||
|
||||
# newtworking
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# this file contains all extendable options originally defined in system.nix
|
||||
{pkgs, config, ...}:
|
||||
|
||||
let
|
||||
inherit (pkgs.stringsWithDeps) noDepEntry FullDepEntry PackEntry;
|
||||
|
||||
activateLib = config.system.activationScripts.lib;
|
||||
in
|
||||
|
||||
{
|
||||
require = [
|
||||
# config.system.activationScripts
|
||||
(import ../system/activate-configuration.nix)
|
||||
];
|
||||
|
||||
system = {
|
||||
activationScripts = {
|
||||
systemConfig = noDepEntry ''
|
||||
systemConfig="$1"
|
||||
if test -z "$systemConfig"; then
|
||||
systemConfig="/system" # for the installation CD
|
||||
fi
|
||||
'';
|
||||
|
||||
defaultPath =
|
||||
let path = [
|
||||
pkgs.coreutils pkgs.gnugrep pkgs.findutils
|
||||
pkgs.glibc # needed for getent
|
||||
pkgs.pwdutils
|
||||
]; in noDepEntry ''
|
||||
export PATH=/empty
|
||||
for i in ${toString path}; do
|
||||
PATH=$PATH:$i/bin:$i/sbin;
|
||||
done
|
||||
'';
|
||||
|
||||
stdio = FullDepEntry ''
|
||||
# Needed by some programs.
|
||||
ln -sfn /proc/self/fd /dev/fd
|
||||
ln -sfn /proc/self/fd/0 /dev/stdin
|
||||
ln -sfn /proc/self/fd/1 /dev/stdout
|
||||
ln -sfn /proc/self/fd/2 /dev/stderr
|
||||
'' [
|
||||
activateLib.defaultPath # path to ln
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -196,10 +196,13 @@ rec {
|
|||
# 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').
|
||||
# DO NOT EXTEND THIS. You should use the option system-option.nix
|
||||
activateConfiguration = pkgs.substituteAll rec {
|
||||
src = ./activate-configuration.sh;
|
||||
isExecutable = true;
|
||||
|
||||
newActivationScript = config.system.activationScripts.script;
|
||||
|
||||
inherit etc wrapperDir systemPath modprobe defaultShell kernel;
|
||||
hostName = config.networking.hostName;
|
||||
setuidPrograms =
|
||||
|
@ -212,12 +215,6 @@ rec {
|
|||
|
||||
inherit (usersGroups) createUsersGroups usersList groupsList;
|
||||
|
||||
path = [
|
||||
pkgs.coreutils pkgs.gnugrep pkgs.findutils
|
||||
pkgs.glibc # needed for getent
|
||||
pkgs.pwdutils
|
||||
];
|
||||
|
||||
bash = pkgs.bashInteractive;
|
||||
|
||||
adjustSetuidOwner = pkgs.lib.concatStrings (map
|
||||
|
|
Loading…
Reference in New Issue