Commit graph

303 commits

Author SHA1 Message Date
Naïm Favier c0b2241e53
nixos/top-level: pass lib to specialisations 2021-07-03 13:05:55 +02:00
Pacman99 87c659ab94 nixos/top-level: specialArgs to specialisations 2021-05-06 16:04:08 -07:00
rnhmjoj 61b7cab481
treewide: use perl.withPackages when possible
Since 03eaa48 added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.

Unfortunately there are a few exceptions that I've found:

  1. Scripts that are calling perl with the -T switch. This makes perl
  ignore PERL5LIB, which is what perl.withPackages is using to inform
  the interpreter of the library paths.

  2. Perl packages that depends on libraries in their own path. This
  is not possible because perl.withPackages works at build time. The
  workaround is to add `-I $out/${perl.libPrefix}` to the shebang.

In all other cases I propose to switch to perl.withPackages.

[1]: https://lwn.net/Articles/779997/
2021-03-31 21:35:37 +02:00
Jean-Baptiste Giraudeau 77b7d29bf8
nixos/switch-to-configuration: don't try restart deleted sockets 2021-03-11 11:34:16 +01:00
Chuck df25ca8520 nixos/activation-script: Run userActivationScripts at login
Fixes https://github.com/NixOS/nixpkgs/issues/113240
2021-02-16 10:10:45 -08:00
Fritz Otlinghaus 56c42142ed Revert "nixos/top-level: add specialisation.<name>.configuration type"
This reverts commit 05fbc82771.
2021-02-05 17:49:06 +01:00
Fritz Otlinghaus 05fbc82771 nixos/top-level: add specialisation.<name>.configuration type 2021-02-03 16:27:22 -08:00
Ben Siraphob 1c2a2b0a08 treewide: fold -> foldr 2021-01-26 10:57:07 +07:00
John Ericson 9c213398b3 lib: Clean up how linux and gcc config is specified
Second attempt of 8929989614589ee3acd070a6409b2b9700c92d65; see that
commit for details.

This reverts commit 0bc275e634.
2021-01-23 10:01:28 -05:00
Jonathan Ringer 0bc275e634
Revert "lib: Clean up how linux and gcc config is specified"
This is a stdenv-rebuild, and should not be merged
into master

This reverts commit 8929989614.
2021-01-22 14:07:06 -08:00
John Ericson 8929989614 lib: Clean up how linux and gcc config is specified
The `platform` field is pointless nesting: it's just stuff that happens
to be defined together, and that should be an implementation detail.

This instead makes `linux-kernel` and `gcc` top level fields in platform
configs. They join `rustc` there [all are optional], which was put there
and not in `platform` in anticipation of a change like this.

`linux-kernel.arch` in particular also becomes `linuxArch`, to match the
other `*Arch`es.

The next step after is this to combine the *specific* machines from
`lib.systems.platforms` with `lib.systems.examples`, keeping just the
"multiplatform" ones for defaulting.
2021-01-21 22:44:09 -05:00
Silvan Mosberger 9e6737710c Revert "Module-builtin assertions, disabling assertions and submodule assertions" 2020-12-18 16:44:37 +01:00
Silvan Mosberger 9523df7eb6
nixos/assertions: Use module-builtin assertion implementation 2020-11-30 23:51:22 +01:00
Graham Christensen bc49a0815a
utillinux: rename to util-linux 2020-11-24 12:42:06 -05:00
rnhmjoj bc35565463 nixos/activation-script: make scripts well-typed 2020-10-26 13:33:12 +01:00
Jan Tojnar e6ce041cae
nixos/doc: Improve code listings
By adding prompts and replaceables and removing unnecessary indentation.
2020-09-23 01:25:25 +02:00
Bas van Dijk d06de760f8 nixos/modules/system/activation/top-level.nix: allow overriding system.name
The toplevel derivations of systems that have `networking.hostName`
set to `""` (because they want their hostname to be set by DHCP) used
to be all named
`nixos-system-unnamed-${config.system.nixos.label}`.
This makes them hard to distinguish.

A similar problem existed in NixOS tests where `vmName` is used in the
`testScript` to refer to the VM. It defaulted to the
`networking.hostName` which when set to `""` won't allow you to refer
to the machine from the `testScript`.

This commit makes the `system.name` configurable. It still defaults to:

```
if config.networking.hostName == ""
then "unnamed"
else config.networking.hostName;
```

but in case `networking.hostName` needs to be to `""` the
`system.name` can be set to a distinguishable name.
2020-07-20 13:44:18 +02:00
Graham Christensen ec2d28e323
specialisation: replace nesting with named configurations
Co-authored-by: worldofpeace <worldofpeace@protonmail.ch>
2020-04-12 08:12:50 -04:00
volth 4d57e56b71
$toplevel/system: use kernel's architecture
`$toplevel/system` of a system closure with `x86_64` kernel and `i686` userland should contain "x86_64-linux".

If `$toplevel/system` contains "i686-linux", the closure will be run using `qemu-system-i386`, which is able to run `x86_64` kernel on most Intel CPU, but fails on AMD.

So this fix is for a rare case of `x86_64` kernel + `i686` userland + AMD CPU
2020-03-20 16:55:44 +00:00
Michele Guerini Rocco 7b15d6cee4
Merge pull request #81241 from thefloweringash/nesting-system
nixos/activation: propagate system to nested configurations
2020-03-13 09:58:10 +01:00
adisbladis db6c94304f
switch-to-configuration: Add new option X-OnlyManualStart
This is to facilitate units that should _only_ be manually started and
not activated when a configuration is switched to.

More specifically this is to be used by the new Nixops deploy-*
targets created in https://github.com/NixOS/nixops/pull/1245 that are
triggered by Nixops before/after switch-to-configuration is called.
2020-03-09 11:28:07 +00:00
Andrew Childs ce416779bb nixos/activation: use eval-config's system argument for nesting
This avoids a possible surprise if the user is using `nixpkgs.system`
and `nesting.children`. `nesting.children` is expected to ignore all
parent configuration so we shouldn't propagate the user-facing option
`nixpkgs.system`. To avoid doing so, we introduce a new internal
option for holding the value passed to eval-config.nix, and use that
when recursing for nesting.
2020-03-05 20:28:31 +09:00
Andrew Childs b83164a049 nixos/activation: propagate system to nested configurations
The current behavior lets `system` default to
`builtins.currentSystem`. The system value specified to
`eval-config.nix` has very low precedence, so this should compose
properly.

Fixes #80806
2020-02-27 23:57:44 +09:00
Eelco Dolstra 26aba55951
Revert "add config.environment.ld-linux"
This reverts commit af665d822a, see
https://github.com/NixOS/nixpkgs/pull/78798#issuecomment-580059834 for
the reasons in a similar PR.
2020-02-02 15:29:49 +01:00
Eelco Dolstra 5495cb91eb
Revert "rmdir: avoid failing when directory did not exist"
This reverts commit 45db499d2d.
2020-02-02 15:29:40 +01:00
Matthew Bauer 3a7fe07e3c
Merge pull request #69057 from volth/ld-linux
add config.environment.ld-linux
2020-01-27 20:08:12 -05:00
Domen Kožar 0f799bd8a4
Revert "nixos/switch-to-configuration: restart changed socket units"
This reverts commit 89806e9536.

See #74626
2019-11-30 13:46:57 +01:00
Franz Pletz 89806e9536 nixos/switch-to-configuration: restart changed socket units
Previously, socket units wouldn't be restarted if they were
changed. To restart the socket, the service the socket is attached
to needs to be stopped first before the socket can be restarted.
2019-11-25 14:43:49 +01:00
Vladimír Čunát f760f0ef48
Revert "Merge #67232: machinectl compliant NixOS installation"
This reverts commit 66967ec752, reversing
changes made to fb6595eafd.
Fixes #70442; discussion: https://github.com/NixOS/nixpkgs/pull/70027
2019-10-07 20:56:59 +02:00
Franz Pletz 66967ec752
Merge pull request #67232 from ck3d/container-useHostResolvConf
machinectl compliant NixOS installation
2019-09-25 09:34:17 +00:00
volth 45db499d2d
rmdir: avoid failing when directory did not exist
I bet nobody has `environment.usrbinenv = null`, it would fail on the second activation trying to `rmdir` inexisting `/usr/bin`
2019-09-19 00:32:35 +00:00
volth af665d822a add config.environment.ld-linux
Add option to install symlink to ld-linux(8) system-wide to allow running unmodified ELF binaries.
It might be useful to run games or executables distributed inside jar files as discussed
https://discourse.nixos.org/t/runtime-alternative-to-patchelf-set-interpreter/3539
https://discourse.nixos.org/t/running-binaries-without-fhs-and-patchelf/1828

It is the third concession to FHS after `/bin/sh` and `/usr/bin/env` but it is disabled by default unlike those two
2019-09-18 22:41:52 +00:00
Eelco Dolstra b20a0e49c8
Revert systemd interface version to 2
The new systemd in 19.09 gives an "Access Denied" error when doing
"systemctl daemon-reexec" on an 19.03 system. The fix is to use the
previous systemctl to signal the daemon to re-exec itself. This
ensures that users don't have to reboot when upgrading from NixOS
19.03 to 19.09.
2019-09-16 16:51:19 +02:00
Eelco Dolstra b9ed9c7fed
Typo 2019-09-16 16:50:39 +02:00
Christian Kögler db9b5f5525
nixos: deactivate immutablity for /var/empty in container 2019-09-13 17:33:38 +02:00
Kai Wohlfahrt dd0a951279 nixos/hardware.deviceTree: new module
Add support for custom device-tree files, and applying overlays to them.
This is useful for supporting non-discoverable hardware, such as sensors
attached to GPIO pins on a Raspberry Pi.
2019-08-07 13:51:22 +01:00
Michael Weiss 698388bc61 Revert "nixos/switch-to-configuration: Never stop system.slice"
This change was only a temporary workaround and isn't required anymore,
since /etc/systemd/system/system.slice should not be present on any
recent NixOS system (which makes this change a no-op).

This reverts commit 7098b0fcdf.
2019-04-28 07:21:34 +02:00
Jan Malakhovski 570aed4b46 lib: add showWarnings 2019-03-08 11:19:18 +02:00
Will Dietz 8c717a5701 activation-script: add libc to path to provide nscd when needed 2018-10-31 07:03:17 -05:00
Will Dietz 9de0b2883a nixos: use pkgs.getent and stdenv.cc.libc
(cherry picked from commit 52eba9753aeba4f02c8ce0de50f10bd98de1ef1e)
2018-10-30 19:49:43 -05:00
Peter Hoeg c81d370bb9
Merge branch 'master' into f/activation 2018-10-05 10:08:56 +08:00
Peter Hoeg 8118d6eb2e switch-to-configuration.pl: activate the nixos-activation.service user service 2018-10-05 10:06:40 +08:00
Peter Hoeg 1353ba2678 system-activation: support script fragments to run in a user context 2018-10-05 10:06:40 +08:00
Maximilian Bosch 7297cc5501 nixos/activation: fix systemd-user daemon-reload in auto-upgrade service (#47695)
The autoupgrade service defined in `system.autoUpgrade`
(`nixos/modules/installer/tools/auto-upgrade.nix`) doesn't have `su` in
its path and thus yields a warning during the `daemon-reload`.

Specifying the absolute path fixes the issue.

Fixes #47648
2018-10-03 12:31:08 +02:00
Jamey Sharp b63f65aea0 nixos/pam: create wtmp/lastlog iff using pam_lastlog
I think pam_lastlog is the only thing that writes to these files in
practice on a modern Linux system, so in a configuration that doesn't
use that module, we don't need to create these files.

I used tmpfiles.d instead of activation snippets to create the logs.
It's good enough for upstream and other distros; it's probably good
enough for us.
2018-09-30 11:08:12 -07:00
Jamey Sharp dab5c632bd nixos/activation: don't create /run/nix
Nix 2.0 no longer uses these directories.

/run/nix/current-load was moved to /nix/var/nix/current-load in 2017
(Nix commit d7653dfc6dea076ecbe00520c6137977e0fced35). Anyway,
src/build-remote/build-remote.cc will create the current-load directory
if it doesn't exist already.

/run/nix/remote-stores seems to have been deprecated since 2014 (Nix
commit b1af336132cfe8a6e4c54912cc512f8c28d4ebf3) when the documentation
for $NIX_OTHER_STORES was removed, and support for it was dropped
entirely in 2016 (Nix commit 4494000e04122f24558e1436e66d20d89028b4bd).
2018-09-30 11:08:12 -07:00
Jan Malakhovski 563d5b1c87 nixos: top-level: indent 2018-09-24 19:45:16 +00:00
Jan Malakhovski fece91537b nixos: top-level: evaluate assertions before warnings
or else at least the following config will fail with an evaluation error
instead of an assert

```
{
  services.nixosManual.enable = false;
  services.nixosManual.showManual = true;
}
```
2018-09-24 19:45:15 +00:00
Elis Hirwing 5664e64a01 nixos/activation: Switch from bash to sh to avoid reading users bash config (#46851)
This fixes #46750. This should also work with non-POSIX shells like in #46042.
2018-09-18 21:47:14 +02:00
Maximilian Bosch df05618f2a nixos/activation: fix activation script for non-POSIX shells (#46042)
This fixes an issue with shells like fish that are not fully POSIX
compliant. The syntax `ENV=val cmd' doesn't work properly in there.

This issue has been addressed in #45932 and #45945, however it has been
recommended to use a single shell (`stdenv.shell' which is either
`bash' or `sh') to significantly reduce the maintenance overload in the
future.

See https://github.com/NixOS/nixpkgs/issues/45897#issuecomment-417923464

Fixes #45897

/cc @FRidh @xaverdh @etu
2018-09-05 22:48:47 +02:00
Graham Christensen f14b6cb6ec
Merge pull request #44526 from samueldr/feature/actiavation-failure-identification
nixos/activation: Identifies the snippet that failed
2018-09-02 14:28:10 -04:00
Venkateswara Rao Mandela cb1ca42009 nixos/doc: add instructions for installation behind a proxy (#45854)
The instructions to install nixos behind a proxy were not clear. While
one could guess that setting http_proxy variables can get the install
rolling, one could end up with an installed system where the proxy
settings for the nix-daemon are not configured.

This commit updates the documentation with

1. steps to install behind a proxy

2. configure the global proxy settings so that nix-daemon can access
internet.

3. Pointers to use nesting.clone in case one has to use different proxy
settings on different networks.
2018-09-01 16:12:35 +02:00
Jörg Thalheim a6ced42c60
Merge pull request #44990 from Ma27/reload-user-units-during-activation
nixos/switch-to-configuration: reload user units
2018-08-27 11:12:42 +01:00
John Ericson f0d6e22b7f
Merge pull request #45397 from volth/patch-233
$toplevel/system: buildPlatform.system -> hostPlatform.system
2018-08-20 14:36:13 -04:00
volth 72f5078beb
top-level.nix: stdenv.platform -> stdenv.hostPlatform.platform
because stdenv.platform is stdenv.buildPlatform.platform
2018-08-20 18:20:57 +00:00
volth 6efaa88fcc
$toplevel/system: buildPlatform.system -> hostPlatform.system 2018-08-20 18:12:13 +00:00
Maximilian Bosch fc2bde6d7a
nixos/switch-to-configuration: reload user units
When rebuilding you have to manually run `systemctl --user
daemon-reload`. It gathers all authenticated users using
`loginctl list-user` and runs `daemon-reload` for each of them.

This is a first step towards a `nixos-rebuild` which is able to reload
user units from systemd. The entire task is fairly hard, however I
consider this patch usable as it allows to restart units without running
`daemon-reload` for each authenticated user.
2018-08-14 13:38:18 +02:00
Samuel Dionne-Riel 6a25a35e70 nixos/activation: Identifies the snippet that failed
This allows a developer to better identify in which snippet the
failure happened. Furthermore, users seeking help will have more
information available about the failure.
2018-08-05 19:27:23 -04:00
Michael Weiss 01cfa808ff
Merge pull request #43682 from primeos/never-stop-system.slice
nixos/switch-to-configuration: Never stop system.slice
2018-07-28 20:42:22 +02:00
volth 2e979e8ceb [bot] nixos/*: remove unused arguments in lambdas 2018-07-20 20:56:59 +00:00
Michael Weiss 7098b0fcdf nixos/switch-to-configuration: Never stop system.slice
Problem: Restarting (stopping) system.slice would not only stop X11 but
also most system units/services. We obviously don't want this happening
to users when they switch from 18.03 to 18.09 or nixos-unstable.

Reason: The following change in systemd:
d8e5a93382

The commit adds system.slice to the perpetual units, which means
removing the unit file and adding it to the source code. This is done so
that system.slice can't be stopped anymore but in our case it ironically
would cause this script to stop system.slice because the unit file was
removed (and an older systemd version is still running).

Related issue: https://github.com/NixOS/nixpkgs/issues/39791
2018-07-17 19:37:36 +02:00
edef 54a13b07d5 switch-to-configuration: use Net::DBus to retrieve the list of units
This resolves the FIXME, and opens up the possibility of using more of
the systemd DBus interface to make things more robust.
2018-05-03 20:19:23 +02:00
Matthew Bauer ca30c5e061 Revert "Merge pull request #28206 from edef1c/net-dbus-list-units"
This reverts commit e508f0eec1, reversing
changes made to bead42df5d.
2018-05-02 15:02:29 -05:00
Matthew Justin Bauer e508f0eec1
Merge pull request #28206 from edef1c/net-dbus-list-units
switch-to-configuration: use Net::DBus to retrieve the list of units
2018-05-02 12:49:37 -05:00
Jan Malakhovski 7079e744d4 Merge branch 'master' into staging
Resolved the following conflicts (by carefully applying patches from the both
branches since the fork point):

   pkgs/development/libraries/epoxy/default.nix
   pkgs/development/libraries/gtk+/3.x.nix
   pkgs/development/python-modules/asgiref/default.nix
   pkgs/development/python-modules/daphne/default.nix
   pkgs/os-specific/linux/systemd/default.nix
2018-03-10 20:38:13 +00:00
edef 2fa1165e89 switch-to-configuration: use Net::DBus to retrieve the list of units
This resolves the FIXME, and opens up the possibility of using more of
the systemd DBus interface to make things more robust.
2018-03-05 12:05:01 -05:00
Shea Levy fec543436d
nixos: Move uses of stdenv.shell to runtimeShell. 2018-03-01 14:38:53 -05:00
Eelco Dolstra d12c9911df
Merge remote-tracking branch 'origin/master' into nix-2.0 2018-02-22 17:28:51 +01:00
Jan Malakhovski 2e6b796761 nixos: rename config.system.nixos* -> config.system.nixos.* 2018-02-18 12:56:30 +00:00
Jan Malakhovski e1782e342f nixos: add system.boot.loader.initrdFile option and use it where appropriate 2018-02-18 12:56:29 +00:00
Eelco Dolstra 16bdaf3d03
Remove creation of /dev/{fd,stdin,stdout,stderr}
This is already provided by devtmpfs.
2018-02-07 17:58:21 +01:00
Gleb Peregud 2f6148c743 nixos/system: make switch-to-configuration script pure.
Fixes #28443

Fixed few invocations to `systemctl` to have an absolute path. Additionally add
LOCALE_ARCHIVE so that perl stops spewing warning messages.
2017-11-19 19:42:54 +01:00
danbst 65ff0d5f9d switch-to-configuration: fix detection of changes between rebuilds for template instances
This makes declarative containers truly reloadable. Current code already declares it:

56904d7c42/nixos/modules/virtualisation/containers.nix (L488)

```
  restartIfChanged = false;
```

56904d7c42/nixos/modules/virtualisation/containers.nix (L540)

```
  reloadIfChanged = true;
```

Original author: @chrisfarms in 6e36619b27
Most of stuff from that commit has already been ported.
2017-08-22 15:04:18 +03:00
Robin Gloster 485a8fef73
modules: specify some types 2017-08-04 02:20:31 +02:00
Shea Levy 59c0977300 Add facility to append secrets to the initrd 2017-04-02 16:33:37 -04:00
Eelco Dolstra 136f77b7b9
nixos-rebuild: Sync /nix/store only
We only care about /nix/store because its contents might be out of
sync with /nix/var/nix/db. Syncing other filesystems might cause
unnecessary delays or hangs (e.g. I encountered a case where an NFS
mount was taking a very long time to sync).
2017-03-03 16:50:25 +01:00
Robin Gloster 4e4161c212
systemd: setup tmpfiles on switching configuration
This fixes systemd.tmpfiles.rules on switching configuration so that
does not only get applied on a fresh boot. This e.g. fixes kubernetes.
2017-02-18 15:04:52 +01:00
Nikolay Amiantov 213356c927 activation-script service: add utillinux to path 2017-02-17 21:54:58 +03:00
Tuomas Tynkkynen 9e04b57dde nixos top-level: Add 'dtbs' symlink when kernel uses device trees
Currently e.g. extlinux-conf-builder.sh uses
`readlink -m "$toplevel/kernel/../dtbs"` to figure out the directory.
That is obscenely ugly.
2017-02-12 15:47:49 +02:00
Nathan Bijnens 4ed85933db Fix #19382 set ownership of /var/empty to root:root 2016-10-09 12:01:47 +02:00
Tuomas Tynkkynen 19225bf5cc Merge remote-tracking branch 'upstream/master' into staging 2016-10-02 10:36:47 +03:00
Nikolay Amiantov d37458ad06 switch-to-configuration: fix restart of socket activated services
This fixes two bugs:

* When socket activation is detected, the service itself is added to stop-start list instead of its sockets.
* When service is marked to restart instead of stop (`StopIfChanged = no`) we don't need to restart sockets.
2016-09-30 17:49:31 +03:00
Eelco Dolstra 0cb16a6955 Add stdenvNoCC
This is a standard environment that doesn't contain a C/C++
compiler. This is mostly to prevent trivial builders like runCommand
and substituteAll from pulling in gcc for simple configuration changes
on NixOS.
2016-09-29 13:06:41 +02:00
aszlig cb2f84e4d7
nixos/activation: Rename "tmpfs" to "specialfs"
Using "tmpfs" as a script part for system.activationScripts is a bit
misleading since 6efcfe03ae.

We no longer solely mount tmpfs within this script, so using "specialfs"
fits more nicely in terms of naming.

Tested against the "simple" NixOS installer test.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2016-09-26 02:04:54 +02:00
aszlig f94ea04805
nixos/activation: Avoid remounting non-existing FS
Regression introduced by 79d4636d50.

The mentioned commit moves /run/keys from stage 2 to
boot.specialFileSystems, the latter being remounted during system
activation.

Unfortunately, the specialMount function in the activation script does
this unconditionally and thus will fail if it can't be remounted because
the mount point simply doesn't exist.

We now check the mount point for existance and only remount if it exists
but mkdir + mount it if it doesn't.

Tested against the "simple" NixOS installer test.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2016-09-26 02:04:54 +02:00
Domen Kožar 80437576f9 /var/empty: silently ignore errors (if on tmpfs) #18781 2016-09-21 10:29:14 +02:00
Domen Kožar 8f95e6f6aa hardcode e2fsprogs, idempotent chmod, remove care condition 2016-09-07 10:49:27 +02:00
Domen Kožar 3877ec5b2f Make /var/empty immutable
Fixes #14910 and #18358

Deployed to an existing server, restarted sshd and polkit to verify
they don't fail.
2016-09-06 20:13:33 +02:00
Nikolay Amiantov 6efcfe03ae nixos filesystems: unify early filesystems handling
A new internal config option `fileSystems.<name>.early` is added to indicate
that the filesystem needs to be loaded very early (i.e. in initrd). They are
transformed to a shell script in `system.build.earlyMountScript` with calls to
an undefined `specialMount` function, which is expected to be caller-specific.
This option is used by stage-1, stage-2 and activation script to set up and
remount those filesystems.  Options for them are updated according to systemd
defaults.
2016-08-27 13:38:20 +03:00
Bjørn Forsman 9050077cff switch-to-configuration: use absolute path to systemd-escape
Fixes issue when upgrading from very old NixOS systems that don't have
systemd-escape in $PATH:

  $ sudo nixos-rebuild switch
  ...
  building the system configuration...
  updating GRUB 2 menu...
  Can't exec "systemd-escape": No such file or directory at /nix/var/nix/profiles/system/bin/switch-to-configuration line 264.
  Unable to escape /!
2016-07-01 08:35:38 +02:00
Nikolay Amiantov 5ff40ddedf add get* helper functions and mass-replace manual outputs search with them 2016-04-25 13:24:39 +03:00
Vladimír Čunát 09af15654f Merge master into closure-size
The kde-5 stuff still didn't merge well.
I hand-fixed what I saw, but there may be more problems.
2016-03-08 09:58:19 +01:00
Vladimír Čunát f8516a0717 nixos copySystemConfiguration: fix when chrooted
Fixes #7974. Also makes the description more informative.
2016-02-28 10:08:42 +01:00
Leroy Hopson 392ca77d4c nixos/activation-script: fix formatting of example 2016-02-27 22:25:40 +13:00
zimbatm b73c5ae291 Merge pull request #10546 from aszlig/nixops-issue-350
Fixes for NixOps issue #350
2016-02-26 00:33:49 +00:00
Vladimír Čunát d039c87984 Merge branch 'master' into closure-size 2016-02-14 08:33:51 +01:00
Vladimír Čunát ae74c356d9 Merge recent 'staging' into closure-size
Let's get rid of those merge conflicts.
2016-02-03 16:57:19 +01:00
Eelco Dolstra 42709fb4e9 switch-to-configuration: Handle failure to read /proc/1/exe
It's not entirely clear why this happens, but sometimes /proc/1/exe
returns a bogus value, like
/ar3a3j6b9livhy5fcfv69izslhgk4gcz-systemd-217/lib/systemd/systemd. In
any case, we can just conservatively assume that we need to restart
systemd when this happens.

Fixes #10261.
2016-02-03 15:01:18 +01:00
Nathan Zadoks df82096af0 activation-script module: add environment.usrbinenv option 2016-01-19 23:29:48 +01:00
Vladimír Čunát 716aac2519 Merge branch 'staging' into closure-size 2016-01-19 09:55:31 +01:00
Thomas Strobel a04a7272aa Add missing 'type', 'defaultText' and 'literalExample' in module definitions
- add missing types in module definitions
- add missing 'defaultText' in module definitions
- wrap example with 'literalExample' where necessary in module definitions
2016-01-17 19:41:23 +01:00
Jan Malakhovski 119c8f91e7 nixos: introduce system.nixosLabel option and use it where appropriate
Setting nixosVersion to something custom is useful for meaningful GRUB
menus and /nix/store paths, but actuallly changing it rebulids the
whole system path (because of `nixos-version` script and manual
pages). Also, changing it is not a particularly good idea because you
can then be differentitated from other NixOS users by a lot of
programs that read /etc/os-release.

This patch introduces an alternative option that does all you want
from nixosVersion, but rebuilds only the very top system level and
/etc while using your label in the names of system /nix/store paths,
GRUB and other boot loaders' menus, getty greetings and so on.
2016-01-08 22:26:15 +00:00
aszlig 26963cfc2d
switch-to-configuration: Fix unit name quoting.
Clearly it would be the best if we'd directly generate mount units
instead of converting /etc/fstab. But in order to do that we need to
test it throughly so this approach is for the next stable release.

This fix however is intended for inclusion into release-14.12 and
release-15.09.

Using a simple regular expression unfortunately isn't sufficient for
proper mount unit name quoting/escaping and there is a utility in
systemd called systemd-escape which does nothing less than that.

Of course, using an external program to escape the unit name is way more
expensive and causes us to fork for each mount point.

But given that we already do quite a lot of forks just for unit starting
and stopping, I think it doesn't matter that much. Well, except if you
have a whole bunch of mount points.

However, if the latter is the case and you have thousands of mount
points, you probably have stumbled over this already if your mount point
contains a dash.

As for my motivation to fix this: I've stumbled on this while trying to
fix the "none" backend test for NixOps (see NixOS/nixops#350), where the
target machines use /nix/.ro-store and /nix/.rw-store as mount points.

The implementation we had so far did improperly escape it so those mount
points got the following unit files:

 * nix-.ro-store.mount
 * nix-.rw-store.mount

The correct names for these units are however:

 * nix-.ro\x2dstore.mount
 * nix-.rw\x2dstore.mount

So using systemd-escape now properly generates these names.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2015-10-22 19:40:00 +02:00
Vladimír Čunát 5227fb1dd5 Merge commit staging+systemd into closure-size
Many non-conflict problems weren't (fully) resolved in this commit yet.
2015-10-03 13:33:37 +02:00
Jan Malakhovski a153de28bb nixos: rename some outputs for better discoverability in /nix/store 2015-09-18 19:00:20 +00:00
Eelco Dolstra 9c61317002 Put all firmware in $out/lib/firmware
This way, hardware.firmware can be a list of packages.
2015-08-25 00:40:34 +02:00
Eelco Dolstra 80d9b42663 Allow units to specify that they shouldn't be stopped when removed 2015-08-07 05:37:23 +02:00
Tuomas Tynkkynen 5d02c02a9b systemd: Use upstream tmpfiles.d rules
This fixes a failing assert in systemd-timesyncd (issue #5913) as it
expects the directory /run/systemd/netif/links/ to exist, and nothing in
NixOS currently creates it.

Also we get a net reduction in our code as rules for /run/utmp and
/var/log/journal are also provided by the same upstream file.

(cherry picked from commit a278a9224a)
2015-07-22 12:27:05 +02:00
Eelco Dolstra dc62669335 Set ‘allowSubstitutes = false’ on various derivations
This reduces the number of binary cache requests. See
b64988bb35.
2015-07-09 15:10:37 +02:00
Eelco Dolstra 7318ff0e38 Add option ‘system.extraDependencies’ for including stuff in the system closure
Mostly useful for installer tests that don't have network access. This
generalizes virtualisation.pathsInNixDB and isoImage.storeContents.
2015-06-04 11:06:44 +02:00
Vladimír Čunát d449020d87 nixos: try to fix, choosing correct binary outputs 2015-05-05 11:56:31 +02:00
Eelco Dolstra 4466707ddf switch-to-configuration: Better error checking 2015-04-13 12:28:12 +02:00
Eelco Dolstra 1c39a47ac8 Reload, don't restart, dbus.service
Many bus clients get hopelessly confused when dbus-daemon is
restarted. So let's not do that.

Of course, this is not ideal either, because we end up stuck with a
possibly outdated dbus-daemon. But that issue will become irrelevant
in the glorious kdbus-based future.

Hopefully this also gets rid of systemd getting stuck after
dbus-daemon is restarted:

Apr 01 15:37:50 mandark systemd[1]: Failed to register match for Disconnected message: Connection timed out
Apr 01 15:37:50 mandark systemd[1]: Looping too fast. Throttling execution a little.
Apr 01 15:37:51 mandark systemd[1]: Looping too fast. Throttling execution a little.
...
2015-04-01 16:57:16 +02:00
Eelco Dolstra 475df1a350 switch-to-configuration: Don't print already active target units
Since we restart all active target units (of which there are many),
it's hard to see the units that actually matter. So don't print that
we're starting target units that are already active.
2015-03-09 16:51:06 +01:00
Eelco Dolstra a574065a81 nixos-rebuild: Add ‘dry-activate’ command
‘nixos-rebuild dry-activate’ builds the new configuration and then
prints what systemd services would be stopped, restarted etc. if the
configuration were actually activated. This could be extended later to
show other activation actions (like uids being deleted).

To prevent confusion, ‘nixos-rebuild dry-run’ has been renamed to
‘nixos-rebuild dry-build’.
2015-03-09 16:50:59 +01:00
Luca Bruno 2beb43174f nixos-rebuild: use reload-or-restart for dbus. Closes #5767
Now that dbus reload has been moved before restarting units,
the reload may fail if dbus has been stopped before.
The reload-or-restart will reload dbus if it's active,
otherwise start it.
2015-01-14 16:08:47 +01:00
Eelco Dolstra c812e45292 switch-to-configuration: Ignore slice units 2014-12-18 01:47:36 +01:00
Eelco Dolstra 88412c865d Fix ANSI escape in warning messages
Seems to have been broken by accident in 7d1ddae58e.
2014-12-15 16:19:35 +01:00
Rene Donner 8bd2f6bfc1 some typos 2014-11-14 13:05:55 +01:00
Luca Bruno 510fba95e8 nixos-rebuild: reload dbus before starting other units. Closes #4546 2014-11-08 19:40:28 +01:00
Eelco Dolstra 785ed2b528 Don't silently ignore errors from the activation script 2014-08-15 02:14:34 +02:00
Luca Bruno 66ddb1c322 Add system.replaceRuntimeDependencies to quickly replace system dependencies 2014-06-06 21:17:31 +02:00
Eelco Dolstra d4ccfe3f6b Don't create /media
It's obsolete - udisks2 uses /run/media/<username>.
2014-05-21 15:55:49 +02:00
Eelco Dolstra c06786759c /var/run -> /run 2014-05-09 00:52:02 +02:00
Eelco Dolstra bac68f9747 switch-to-configuration: Honour RefuseManualStop
This prevents spurious errors about systemd-tmpfiles-setup.service.

Backport: 14.04
2014-05-05 16:46:58 +02:00
Eelco Dolstra 56b4b841ae switch-to-configuration: Use old systemctl to stop units
Otherwise, when switching from systemd 203 to 212, you get errors like:

  Failed to stop remote-fs.target: Bad message
  Failed to stop systemd-udevd-control.socket: Bad message
  ...
2014-04-28 08:28:44 +02:00
Eelco Dolstra 37e6e08cde switch-to-configuration: Use systemctl's --no-legend flag 2014-04-25 17:42:09 +02:00
Shea Levy 7d1ddae58e nixos: evaluate assertions at toplevel, not at systemPackages
Fixes #2340
2014-04-22 14:09:02 -04:00
Shea Levy 2a4282c811 Revert "Merge branch 'dbus-switch-to-configuration'"
This seems to have combined badly with the systemd upgrade, we'll revert
for now and revisit after the 14.04 branch.

This reverts commit ad80532881, reversing
changes made to 1c5d3c7883.
2014-04-21 18:30:05 -04:00
Oliver Charles 42ae633445 Merge branch 'master' into dbus-switch-to-configuration
Conflicts:
	nixos/modules/system/activation/switch-to-configuration.pl
2014-04-20 19:17:05 +01:00
Eelco Dolstra 82535e0f8f switch-to-configuration: Check overrides.conf for X-* options 2014-04-19 14:28:33 +02:00
Eelco Dolstra b03a2f9e90 Set personality when running a 32-bit container on a 64-bit host 2014-04-19 13:14:51 +02:00
Eelco Dolstra 313c38d5f1 switch-to-configuration: Handle systemctl output change 2014-04-18 19:04:45 +02:00
Eelco Dolstra 179acfb664 Allow upstream systemd units to be extended
If you define a unit, and either systemd or a package in
systemd.packages already provides that unit, then we now generate a
file /etc/systemd/system/<unit>.d/overrides.conf. This makes it
possible to use upstream units, while allowing them to be customised
from the NixOS configuration. For instance, the module nix-daemon.nix
now uses the units provided by the Nix package. And all unit
definitions that duplicated upstream systemd units are finally gone.

This makes the baseUnit option unnecessary, so I've removed it.
2014-04-17 18:52:31 +02:00
Eelco Dolstra 29027fd1e1 Rewrite ‘with pkgs.lib’ -> ‘with lib’
Using pkgs.lib on the spine of module evaluation is problematic
because the pkgs argument depends on the result of module
evaluation. To prevent an infinite recursion, pkgs and some of the
modules are evaluated twice, which is inefficient. Using ‘with lib’
prevents this problem.
2014-04-14 16:26:48 +02:00
Eelco Dolstra 511b86d22d Add an option to reload rather than restart changed units 2014-03-17 15:02:53 +01:00
Eelco Dolstra f9e2af1e8b switch-to-configuration: Don't require /etc/NIXOS
Check /etc/os-release if /etc/NIXOS doesn't exist.
2014-03-17 14:16:10 +01:00
Eelco Dolstra f13bd41384 switch-to-configuration: Restart sockets.target 2014-03-17 14:10:48 +01:00
Eelco Dolstra 09c14cd8aa switch-to-configuration: Don't try to start masked units 2014-03-12 18:52:11 +01:00
Oliver Charles 0d18d39e98 switch-to-configuration.pl: Handle successful auto-restarts
switch-to-configuration.pl is currently hard-coded to assume that if a
unit is in the "auto-restart" state that something has gone wrong, but
this is not strictly true. For example, I run offlineimap as a oneshot
service restarting itself every minute (on success). NixOS currently
thinks that offlineimap has failed to start as it enters the
auto-restart state, because it doesn't consider why the unit failed.

This commit changes switch-to-configuration.pl to inspect the full
status of a unit in auto-restart state, and now only considers it failed
if the ExecMainStatus is non-zero.
2014-02-02 15:56:22 +01:00
Oliver Charles 41775167ac switch-to-configuration.pl: Interact via DBus
Currently switch-to-configuration.pl uses system() calls to interact
with DBus. This can be error prone, especially when we are parsing
output that could change. In this commit, almost all calls to the
systemctl binary have been replaced with equivalent operations via DBus.
2014-02-02 14:41:26 +00:00
Eelco Dolstra 09dd7f9afc Fix passing of kernel parameters
Broken in 9ee30cd9b5.  Reported by Arvin
Moezzi.
2013-12-02 11:56:58 -05:00
Eelco Dolstra 9ee30cd9b5 Add support for lightweight NixOS containers
You can now say:

  systemd.containers.foo.config =
    { services.openssh.enable = true;
      services.openssh.ports = [ 2022 ];
      users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-dss ..." ];
    };

which defines a NixOS instance with the given configuration running
inside a lightweight container.

You can also manage the configuration of the container independently
from the host:

  systemd.containers.foo.path = "/nix/var/nix/profiles/containers/foo";

where "path" is a NixOS system profile.  It can be created/updated by
doing:

  $ nix-env --set -p /nix/var/nix/profiles/containers/foo \
      -f '<nixos>' -A system -I nixos-config=foo.nix

The container configuration (foo.nix) should define

  boot.isContainer = true;

to optimise away the building of a kernel and initrd.  This is done
automatically when using the "config" route.

On the host, a lightweight container appears as the service
"container-<name>.service".  The container is like a regular NixOS
(virtual) machine, except that it doesn't have its own kernel.  It has
its own root file system (by default /var/lib/containers/<name>), but
shares the Nix store of the host (as a read-only bind mount).  It also
has access to the network devices of the host.

Currently, if the configuration of the container changes, running
"nixos-rebuild switch" on the host will cause the container to be
rebooted.  In the future we may want to send some message to the
container so that it can activate the new container configuration
without rebooting.

Containers are not perfectly isolated yet.  In particular, the host's
/sys/fs/cgroup is mounted (writable!) in the guest.
2013-11-27 17:14:10 +01:00
Eelco Dolstra 785eaf2cea Add some primops to lib 2013-11-12 13:48:30 +01:00
Eelco Dolstra c1159edc65 Remove remaining references to Upstart 2013-10-31 13:26:06 +01:00
Eelco Dolstra 408b8b5725 Add lots of missing option types 2013-10-30 18:47:43 +01:00
Eelco Dolstra 862e3dd977 Substitute "types.uniq types.string" -> "types.str" 2013-10-30 14:57:42 +01:00
Eelco Dolstra 30a36f9a80 Remove remaining uses of mkOverrideTemplate 2013-10-28 22:45:58 +01:00
Eelco Dolstra d5047faede Remove uses of the "merge" option attribute
It's redundant because you can (and should) specify an option type, or
an apply function.
2013-10-28 22:45:56 +01:00
Eelco Dolstra 0e333688ce Big cleanup of the NixOS module system
The major changes are:

* The evaluation is now driven by the declared options.  In
  particular, this fixes the long-standing problem with lack of
  laziness of disabled option definitions.  Thus, a configuration like

    config = mkIf false {
      environment.systemPackages = throw "bla";
    };

  will now evaluate without throwing an error.  This also improves
  performance since we're not evaluating unused option definitions.

* The implementation of properties is greatly simplified.

* There is a new type constructor "submodule" that replaces
  "optionSet".  Unlike "optionSet", "submodule" gets its option
  declarations as an argument, making it more like "listOf" and other
  type constructors.  A typical use is:

    foo = mkOption {
      type = type.attrsOf (type.submodule (
        { config, ... }:
        { bar = mkOption { ... };
          xyzzy = mkOption { ... };
        }));
    };

  Existing uses of "optionSet" are automatically mapped to
  "submodule".

* Modules are now checked for unsupported attributes: you get an error
  if a module contains an attribute other than "config", "options" or
  "imports".

* The new implementation is faster and uses much less memory.
2013-10-28 22:45:55 +01:00
Eelco Dolstra 29014a47fb Allow options to be marked as "internal"
This means they're not for end users.  Currently they're filtered from
the manual, but we could include them in a separate section.
2013-10-23 20:08:21 +02:00
Eelco Dolstra e29b51bfb1 Improve option description 2013-10-23 20:08:21 +02:00
Eelco Dolstra 5c1f8cbc70 Move all of NixOS to nixos/ in preparation of the repository merge 2013-10-10 13:28:20 +02:00