From 65e569cc37a52dd6476469df1e53e669acfaf508 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 12 Apr 2015 23:50:20 +0200 Subject: [PATCH 1/4] nixos: Add all of root's channels to NIX_PATH. This is very useful if you want to distribute channels (and thus expressions as well) in a similar fashion to Debians APT sources (or PPAs or whatnot). So, for example if you have a channel with some additional functions or packages, you simply add that channel with: sudo nix-channel --add https://example.com/my-nifty-channel foo And you can access that channel using , for example in your configuration.nix: { imports = [ ]; environment.systemPackages = with import {}; [ bar blah ]; services.udev.extraRules = import { kernel = "eth*"; attr.address = "00:1D:60:B9:6D:4F"; name = "my_fast_network_card"; }; } Within nixpkgs, we shouldn't have used anywhere anymore, so we shouldn't get into conflicts. Signed-off-by: aszlig --- nixos/modules/programs/environment.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/programs/environment.nix b/nixos/modules/programs/environment.nix index e0379a2c02a..1a211b8c84f 100644 --- a/nixos/modules/programs/environment.nix +++ b/nixos/modules/programs/environment.nix @@ -25,7 +25,8 @@ in environment.sessionVariables = { NIX_PATH = - [ "/nix/var/nix/profiles/per-user/root/channels/nixos" + [ "/nix/var/nix/profiles/per-user/root/channels" + "/nix/var/nix/profiles/per-user/root/channels/nixos" "nixpkgs=/etc/nixos/nixpkgs" "nixos-config=/etc/nixos/configuration.nix" ]; From 3a4fd0bfc6fb34a496708ee95891acb1648eedde Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 13 Apr 2015 00:09:00 +0200 Subject: [PATCH 2/4] nixos-rebuild: Update all channels of user root. Should make it even easier to use custom channels, because whenever the user does a "nixos-rebuild --upgrade", it will also upgrade possibly used ("used" as in referenced in configuration.nix) channels besides "nixos". And if you also ship a channel tied to a particular version of nixpkgs or even remove the "nixos" channels, you won't run into unexpected situations where the system is not updating your custom channels. Signed-off-by: aszlig --- nixos/modules/installer/tools/nixos-rebuild.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 1d6df8cb3f7..61b1508abdf 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -93,9 +93,9 @@ if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then fi -# If ‘--upgrade’ is given, run ‘nix-channel --update nixos’. +# If ‘--upgrade’ is given, run ‘nix-channel --update’. if [ -n "$upgrade" -a -z "$_NIXOS_REBUILD_REEXEC" ]; then - nix-channel --update nixos + nix-channel --update fi # Make sure that we use the Nix package we depend on, not something From 5075cbe6967324123e7a9fc38fcd35371f2b91df Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 13 Apr 2015 12:20:58 +0200 Subject: [PATCH 3/4] nixos: Put root's channels to the end of NIX_PATH. My original reason to put it at the beginning of NIX_PATH was to allow shipping a particular version with a channel. But in order to do that, we can still let the channel expression ship with a custom version of nixpkgs by something like and the builder of the channel could also rewrite self-references. So the inconvenience is now shifted towards the maintainer of the channel rather than the user (which isn't nice, but better err on the side of the developer rather than on the user), because as @edolstra pointed out: Having the channels of root at the beginning of NIX_PATH could have unintended side-effects if there a channel called nixpkgs. Signed-off-by: aszlig --- nixos/modules/programs/environment.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/programs/environment.nix b/nixos/modules/programs/environment.nix index 1a211b8c84f..dce757ceb62 100644 --- a/nixos/modules/programs/environment.nix +++ b/nixos/modules/programs/environment.nix @@ -25,10 +25,10 @@ in environment.sessionVariables = { NIX_PATH = - [ "/nix/var/nix/profiles/per-user/root/channels" - "/nix/var/nix/profiles/per-user/root/channels/nixos" + [ "/nix/var/nix/profiles/per-user/root/channels/nixos" "nixpkgs=/etc/nixos/nixpkgs" "nixos-config=/etc/nixos/configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" ]; }; From df31a338dcfbbc1561905eb02224912c82a92fc7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 13 Apr 2015 12:41:31 +0200 Subject: [PATCH 4/4] nixos-rebuild: Conditionally update channels. This partially reverts commit 3a4fd0bfc6fb34a496708ee95891acb1648eedde. Addresses another concern by @edolstra that users might not want to update *all* channels. We're now reverting to the old behaviour but after updating the "nixos" channel, we just check whether the channel ships with a file called ".update-on-nixos-rebuild" and if it exists, we update that channel as well. Other channels than these are not touched anymore. Signed-off-by: aszlig --- nixos/modules/installer/tools/nixos-rebuild.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh index 61b1508abdf..ccafa30856c 100644 --- a/nixos/modules/installer/tools/nixos-rebuild.sh +++ b/nixos/modules/installer/tools/nixos-rebuild.sh @@ -93,9 +93,17 @@ if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then fi -# If ‘--upgrade’ is given, run ‘nix-channel --update’. +# If ‘--upgrade’ is given, run ‘nix-channel --update nixos’. if [ -n "$upgrade" -a -z "$_NIXOS_REBUILD_REEXEC" ]; then - nix-channel --update + nix-channel --update nixos + + # If there are other channels that contain a file called + # ".update-on-nixos-rebuild", update them as well. + for channelpath in /nix/var/nix/profiles/per-user/root/channels/*; do + if [ -e "$channelpath/.update-on-nixos-rebuild" ]; then + nix-channel --update "$(basename "$channelpath")" + fi + done fi # Make sure that we use the Nix package we depend on, not something