diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2016-01-19 09:55:31 +0100 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2016-01-19 09:55:31 +0100 |
commit | 716aac2519a7571e7f5fd984a886d579a4a051c5 (patch) | |
tree | 53cf89cf764d787f4dc8f08474479892b9733177 /nixos/modules/system | |
parent | f8472457a440de3c44f6f604142d678b6ae2a762 (diff) | |
parent | 53b389327e34de319dc0dbda2b6bcab1a69db69d (diff) | |
download | nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar.gz nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar.bz2 nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar.lz nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar.xz nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.tar.zst nixlib-716aac2519a7571e7f5fd984a886d579a4a051c5.zip |
Merge branch 'staging' into closure-size
Diffstat (limited to 'nixos/modules/system')
-rw-r--r-- | nixos/modules/system/activation/top-level.nix | 8 | ||||
-rw-r--r-- | nixos/modules/system/boot/kernel.nix | 7 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh | 4 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/grub/grub.nix | 3 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 4 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/grub/ipxe.nix | 2 | ||||
-rw-r--r-- | nixos/modules/system/boot/luksroot.nix | 2 | ||||
-rw-r--r-- | nixos/modules/system/boot/stage-1-init.sh | 1 | ||||
-rw-r--r-- | nixos/modules/system/boot/stage-1.nix | 11 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd.nix | 6 | ||||
-rw-r--r-- | nixos/modules/system/etc/etc.nix | 5 | ||||
-rw-r--r-- | nixos/modules/system/upstart/upstart.nix | 290 |
12 files changed, 34 insertions, 309 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 81088a56fb12..d66580b7b9be 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -67,7 +67,7 @@ let echo -n "$configurationName" > $out/configuration-name echo -n "systemd ${toString config.systemd.package.interfaceVersion}" > $out/init-interface-version - echo -n "$nixosVersion" > $out/nixos-version + echo -n "$nixosLabel" > $out/nixos-version echo -n "$system" > $out/system mkdir $out/fine-tune @@ -101,7 +101,7 @@ let if [] == failed then pkgs.stdenv.mkDerivation { name = let hn = config.networking.hostName; nn = if (hn != "") then hn else "unnamed"; - in "nixos-system-${nn}-${config.system.nixosVersion}"; + in "nixos-system-${nn}-${config.system.nixosLabel}"; preferLocalBuild = true; allowSubstitutes = false; buildCommand = systemBuilder; @@ -115,7 +115,7 @@ let config.system.build.installBootLoader or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; activationScript = config.system.activationScripts.script; - nixosVersion = config.system.nixosVersion; + nixosLabel = config.system.nixosLabel; configurationName = config.boot.loader.grub.configurationName; @@ -205,7 +205,7 @@ in system.replaceRuntimeDependencies = mkOption { default = []; - example = lib.literalExample "[ ({ original = pkgs.openssl; replacement = pkgs.callPackage /path/to/openssl { ... }; }) ]"; + example = lib.literalExample "[ ({ original = pkgs.openssl; replacement = pkgs.callPackage /path/to/openssl { }; }) ]"; type = types.listOf (types.submodule ( { options, ... }: { options.original = mkOption { diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix index ac40e8a49acf..6bc046d02611 100644 --- a/nixos/modules/system/boot/kernel.nix +++ b/nixos/modules/system/boot/kernel.nix @@ -63,7 +63,7 @@ in }; boot.extraModulePackages = mkOption { - type = types.listOf types.path; + type = types.listOf types.package; default = []; example = literalExample "[ pkgs.linuxPackages.nvidia_x11 ]"; description = "A list of additional packages supplying kernel modules."; @@ -158,7 +158,7 @@ in boot.kernel.sysctl."kernel.printk" = config.boot.consoleLogLevel; - boot.kernelModules = [ "loop" "configs" "atkbd" ]; + boot.kernelModules = [ "loop" "atkbd" ]; boot.initrd.availableKernelModules = [ # Note: most of these (especially the SATA/PATA modules) @@ -197,9 +197,6 @@ in "hid_generic" "hid_lenovo" "hid_apple" "hid_logitech_dj" "hid_lenovo_tpkbd" "hid_roccat" - # Unix domain sockets (needed by udev). - "unix" - # Misc. stuff. "pcips2" "atkbd" diff --git a/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh b/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh index b9a42b2a196d..78a8e8fd658c 100644 --- a/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh +++ b/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh @@ -83,7 +83,7 @@ addEntry() { timestampEpoch=$(stat -L -c '%Z' $path) timestamp=$(date "+%Y-%m-%d %H:%M" -d @$timestampEpoch) - nixosVersion="$(cat $path/nixos-version)" + nixosLabel="$(cat $path/nixos-version)" extraParams="$(cat $path/kernel-params)" echo @@ -91,7 +91,7 @@ addEntry() { if [ "$tag" = "default" ]; then echo " MENU LABEL NixOS - Default" else - echo " MENU LABEL NixOS - Configuration $tag ($timestamp - $nixosVersion)" + echo " MENU LABEL NixOS - Configuration $tag ($timestamp - $nixosLabel)" fi echo " LINUX ../nixos/$(basename $kernel)" echo " INITRD ../nixos/$(basename $initrd)" diff --git a/nixos/modules/system/boot/loader/grub/grub.nix b/nixos/modules/system/boot/loader/grub/grub.nix index 47605e3685ca..d9f6f51f13a2 100644 --- a/nixos/modules/system/boot/loader/grub/grub.nix +++ b/nixos/modules/system/boot/loader/grub/grub.nix @@ -56,7 +56,7 @@ let extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout default fsIdentifier efiSupport gfxmodeEfi gfxmodeBios; path = (makeSearchPath "bin" ([ - pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfsProgs + pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfs-progs pkgs.utillinux ] ++ (if cfg.efiSupport && (cfg.version == 2) then [pkgs.efibootmgr ] else []) )) + ":" + (makeSearchPath "sbin" [ pkgs.mdadm pkgs.utillinux @@ -251,6 +251,7 @@ in }; extraFiles = mkOption { + type = types.attrsOf types.path; default = {}; example = literalExample '' { "memtest.bin" = "''${pkgs.memtest86plus}/memtest.bin"; } diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index af39e50ff72d..b8ef02da4bc2 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -387,6 +387,10 @@ sub addProfile { my $curEntry = 0; foreach my $link (@links) { last if $curEntry++ >= $configurationLimit; + if (! -e "$link/nixos-version") { + warn "skipping corrupt system profile entry ‘$link’\n"; + next; + } my $date = strftime("%F", localtime(lstat($link)->mtime)); my $version = -e "$link/nixos-version" diff --git a/nixos/modules/system/boot/loader/grub/ipxe.nix b/nixos/modules/system/boot/loader/grub/ipxe.nix index 9b5097a4cfd9..249c2761934d 100644 --- a/nixos/modules/system/boot/loader/grub/ipxe.nix +++ b/nixos/modules/system/boot/loader/grub/ipxe.nix @@ -39,7 +39,7 @@ in dhcp chain http://boot.ipxe.org/demo/boot.php '''; - }; + } ''; }; }; diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix index 763703205630..59bff5472e84 100644 --- a/nixos/modules/system/boot/luksroot.nix +++ b/nixos/modules/system/boot/luksroot.nix @@ -229,7 +229,7 @@ in boot.initrd.luks.devices = mkOption { default = [ ]; - example = [ { name = "luksroot"; device = "/dev/sda3"; preLVM = true; } ]; + example = literalExample ''[ { name = "luksroot"; device = "/dev/sda3"; preLVM = true; } ]''; description = '' The list of devices that should be decrypted using LUKS before trying to mount the root partition. This works for both LVM-over-LUKS and LUKS-over-LVM setups. diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh index 2b5d547353f8..7fb368e8c44f 100644 --- a/nixos/modules/system/boot/stage-1-init.sh +++ b/nixos/modules/system/boot/stage-1-init.sh @@ -140,6 +140,7 @@ done # Create device nodes in /dev. +@preDeviceCommands@ echo "running udev..." mkdir -p /etc/udev ln -sfn @udevRules@ /etc/udev/rules.d diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 0bd5387a7c0f..81418bdf1c15 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -203,7 +203,7 @@ let inherit (config.boot) resumeDevice devSize runSize; inherit (config.boot.initrd) checkJournalingFS - postEarlyDeviceCommands preLVMCommands postDeviceCommands postMountCommands kernelModules; + preLVMCommands preDeviceCommands postEarlyDeviceCommands postDeviceCommands postMountCommands kernelModules; resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}") (filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices); @@ -303,6 +303,15 @@ in ''; }; + boot.initrd.preDeviceCommands = mkOption { + default = ""; + type = types.lines; + description = '' + Shell commands to be executed before udev is started to create + device nodes. + ''; + }; + boot.initrd.postDeviceCommands = mkOption { default = ""; type = types.lines; diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 826368e711ad..211e0423216e 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -179,8 +179,9 @@ let ]; makeJobScript = name: text: - let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${shellEscape name}"; inherit text; }; - in "${x}/bin/${shellEscape name}"; + let mkScriptName = s: (replaceChars [ "\\" ] [ "-" ] (shellEscape s) ); + x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${mkScriptName name}"; inherit text; }; + in "${x}/bin/${mkScriptName name}"; unitConfig = { name, config, ... }: { config = { @@ -373,6 +374,7 @@ in systemd.package = mkOption { default = pkgs.systemd; + defaultText = "pkgs.systemd"; type = types.package; description = "The systemd package."; }; diff --git a/nixos/modules/system/etc/etc.nix b/nixos/modules/system/etc/etc.nix index 300ae0acda53..9d5b3db472c3 100644 --- a/nixos/modules/system/etc/etc.nix +++ b/nixos/modules/system/etc/etc.nix @@ -112,8 +112,9 @@ in config = { target = mkDefault name; - source = mkIf (config.text != null) - (mkDefault (pkgs.writeText "etc-file" config.text)); + source = mkIf (config.text != null) ( + let name' = "etc-" + baseNameOf name; + in mkDefault (pkgs.writeText name' config.text)); }; }); diff --git a/nixos/modules/system/upstart/upstart.nix b/nixos/modules/system/upstart/upstart.nix deleted file mode 100644 index 5c0461304072..000000000000 --- a/nixos/modules/system/upstart/upstart.nix +++ /dev/null @@ -1,290 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -with import ../boot/systemd-unit-options.nix { inherit config lib; }; - -let - - userExists = u: - (u == "") || any (uu: uu.name == u) (attrValues config.users.extraUsers); - - groupExists = g: - (g == "") || any (gg: gg.name == g) (attrValues config.users.extraGroups); - - makeJobScript = name: content: "${pkgs.writeScriptBin name content}/bin/${name}"; - - # From a job description, generate an systemd unit file. - makeUnit = job: - - let - hasMain = job.script != "" || job.exec != ""; - - env = job.environment; - - preStartScript = makeJobScript "${job.name}-pre-start" - '' - #! ${pkgs.stdenv.shell} -e - ${job.preStart} - ''; - - startScript = makeJobScript "${job.name}-start" - '' - #! ${pkgs.stdenv.shell} -e - ${if job.script != "" then job.script else '' - exec ${job.exec} - ''} - ''; - - postStartScript = makeJobScript "${job.name}-post-start" - '' - #! ${pkgs.stdenv.shell} -e - ${job.postStart} - ''; - - preStopScript = makeJobScript "${job.name}-pre-stop" - '' - #! ${pkgs.stdenv.shell} -e - ${job.preStop} - ''; - - postStopScript = makeJobScript "${job.name}-post-stop" - '' - #! ${pkgs.stdenv.shell} -e - ${job.postStop} - ''; - in { - - inherit (job) description requires before partOf environment path restartIfChanged unitConfig; - - after = - (if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else - if job.startOn == "started udev" then [ "systemd-udev.service" ] else - if job.startOn == "started network-interfaces" then [ "network-interfaces.target" ] else - if job.startOn == "started networking" then [ "network.target" ] else - if job.startOn == "ip-up" then [] else - if job.startOn == "" || job.startOn == "startup" then [] else - builtins.trace "Warning: job ‘${job.name}’ has unknown startOn value ‘${job.startOn}’." [] - ) ++ job.after; - - wants = - (if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else [] - ) ++ job.wants; - - wantedBy = - (if job.startOn == "" then [] else - if job.startOn == "ip-up" then [ "ip-up.target" ] else - [ "multi-user.target" ]) ++ job.wantedBy; - - serviceConfig = - job.serviceConfig - // optionalAttrs (job.preStart != "" && (job.script != "" || job.exec != "")) - { ExecStartPre = preStartScript; } - // optionalAttrs (job.preStart != "" && job.script == "" && job.exec == "") - { ExecStart = preStartScript; } - // optionalAttrs (job.script != "" || job.exec != "") - { ExecStart = startScript; } - // optionalAttrs (job.postStart != "") - { ExecStartPost = postStartScript; } - // optionalAttrs (job.preStop != "") - { ExecStop = preStopScript; } - // optionalAttrs (job.postStop != "") - { ExecStopPost = postStopScript; } - // (if job.script == "" && job.exec == "" then { Type = "oneshot"; RemainAfterExit = true; } else - if job.daemonType == "fork" || job.daemonType == "daemon" then { Type = "forking"; GuessMainPID = true; } else - if job.daemonType == "none" then { } else - throw "invalid daemon type `${job.daemonType}'") - // optionalAttrs (!job.task && !(job.script == "" && job.exec == "") && job.respawn) - { Restart = "always"; } - // optionalAttrs job.task - { Type = "oneshot"; RemainAfterExit = false; }; - }; - - - jobOptions = serviceOptions // { - - name = mkOption { - # !!! The type should ensure that this could be a filename. - type = types.str; - example = "sshd"; - description = '' - Name of the job, mapped to the systemd unit - <literal><replaceable>name</replaceable>.service</literal>. - ''; - }; - - startOn = mkOption { - #type = types.str; - default = ""; - description = '' - The Upstart event that triggers this job to be started. Some - are mapped to systemd dependencies; otherwise you will get a - warning. If empty, the job will not start automatically. - ''; - }; - - stopOn = mkOption { - type = types.str; - default = "starting shutdown"; - description = '' - Ignored; this was the Upstart event that triggers this job to be stopped. - ''; - }; - - postStart = mkOption { - type = types.lines; - default = ""; - description = '' - Shell commands executed after the job is started (i.e. after - the job's main process is started), but before the job is - considered “running”. - ''; - }; - - preStop = mkOption { - type = types.lines; - default = ""; - description = '' - Shell commands executed before the job is stopped - (i.e. before systemd kills the job's main process). This can - be used to cleanly shut down a daemon. - ''; - }; - - postStop = mkOption { - type = types.lines; - default = ""; - description = '' - Shell commands executed after the job has stopped - (i.e. after the job's main process has terminated). - ''; - }; - - exec = mkOption { - type = types.str; - default = ""; - description = '' - Command to start the job's main process. If empty, the - job has no main process, but can still have pre/post-start - and pre/post-stop scripts, and is considered “running” - until it is stopped. - ''; - }; - - respawn = mkOption { - type = types.bool; - default = true; - description = '' - Whether to restart the job automatically if its process - ends unexpectedly. - ''; - }; - - task = mkOption { - type = types.bool; - default = false; - description = '' - Whether this job is a task rather than a service. Tasks - are executed only once, while services are restarted when - they exit. - ''; - }; - - daemonType = mkOption { - type = types.str; - default = "none"; - description = '' - Determines how systemd detects when a daemon should be - considered “running”. The value <literal>none</literal> means - that the daemon is considered ready immediately. The value - <literal>fork</literal> means that the daemon will fork once. - The value <literal>daemon</literal> means that the daemon will - fork twice. The value <literal>stop</literal> means that the - daemon will raise the SIGSTOP signal to indicate readiness. - ''; - }; - - setuid = mkOption { - type = types.addCheck types.str userExists; - default = ""; - description = '' - Run the daemon as a different user. - ''; - }; - - setgid = mkOption { - type = types.addCheck types.str groupExists; - default = ""; - description = '' - Run the daemon as a different group. - ''; - }; - - path = mkOption { - default = []; - description = '' - Packages added to the job's <envar>PATH</envar> environment variable. - Both the <filename>bin</filename> and <filename>sbin</filename> - subdirectories of each package are added. - ''; - }; - - }; - - - upstartJob = { name, config, ... }: { - - options = { - - unit = mkOption { - default = makeUnit config; - description = "Generated definition of the systemd unit corresponding to this job."; - }; - - }; - - config = { - - # The default name is the name extracted from the attribute path. - name = mkDefault name; - - }; - - }; - -in - -{ - - ###### interface - - options = { - - jobs = mkOption { - default = {}; - description = '' - This option is a legacy method to define system services, - dating from the era where NixOS used Upstart instead of - systemd. You should use <option>systemd.services</option> - instead. Services defined using <option>jobs</option> are - mapped automatically to <option>systemd.services</option>, but - may not work perfectly; in particular, most - <option>startOn</option> conditions are not supported. - ''; - type = types.loaOf types.optionSet; - options = [ jobOptions upstartJob ]; - }; - - }; - - - ###### implementation - - config = { - - systemd.services = - flip mapAttrs' config.jobs (name: job: - nameValuePair job.name job.unit); - - }; - -} |