at 17.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 nixpkgs = lib.cleanSource pkgs.path; 10 11 # We need a copy of the Nix expressions for Nixpkgs and NixOS on the 12 # CD. These are installed into the "nixos" channel of the root 13 # user, as expected by nixos-rebuild/nixos-install. FIXME: merge 14 # with make-channel.nix. 15 channelSources = pkgs.runCommand "nixos-${config.system.nixosVersion}" 16 { } 17 '' 18 mkdir -p $out 19 cp -prd ${nixpkgs} $out/nixos 20 chmod -R u+w $out/nixos 21 if [ ! -e $out/nixos/nixpkgs ]; then 22 ln -s . $out/nixos/nixpkgs 23 fi 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}