at 16.09-beta 1.5 kB view raw
1# Provide an initial copy of the NixOS channel so that the user 2# doesn't need to run "nix-channel --update" first. 3 4{ config, lib, pkgs, ... }: 5 6with lib; 7 8let 9 10 # We need a copy of the Nix expressions for Nixpkgs and NixOS on the 11 # CD. These are installed into the "nixos" channel of the root 12 # user, as expected by nixos-rebuild/nixos-install. FIXME: merge 13 # with make-channel.nix. 14 channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}" 15 { } 16 '' 17 mkdir -p $out 18 cp -prd ${pkgs.path} $out/nixos 19 chmod -R u+w $out/nixos 20 if [ ! -e $out/nixos/nixpkgs ]; then 21 ln -s . $out/nixos/nixpkgs 22 fi 23 rm -rf $out/nixos/.git 24 echo -n ${config.system.nixosVersionSuffix} > $out/nixos/.version-suffix 25 ''; 26 27in 28 29{ 30 # Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required 31 # for nixos-install. 32 boot.postBootCommands = mkAfter 33 '' 34 if ! [ -e /var/lib/nixos/did-channel-init ]; then 35 echo "unpacking the NixOS/Nixpkgs sources..." 36 mkdir -p /nix/var/nix/profiles/per-user/root 37 ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels \ 38 -i ${channelSources} --quiet --option build-use-substitutes false 39 mkdir -m 0700 -p /root/.nix-defexpr 40 ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels 41 mkdir -m 0755 -p /var/lib/nixos 42 touch /var/lib/nixos/did-channel-init 43 fi 44 ''; 45}