at 21.11-pre 1.8 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.nixos.version}" 16 { preferLocalBuild = true; } 17 '' 18 mkdir -p $out 19 cp -prd ${nixpkgs.outPath} $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 ${optionalString (config.system.nixos.revision != null) '' 25 echo -n ${config.system.nixos.revision} > $out/nixos/.git-revision 26 ''} 27 echo -n ${config.system.nixos.versionSuffix} > $out/nixos/.version-suffix 28 echo ${config.system.nixos.versionSuffix} | sed -e s/pre// > $out/nixos/svn-revision 29 ''; 30 31in 32 33{ 34 # Provide the NixOS/Nixpkgs sources in /etc/nixos. This is required 35 # for nixos-install. 36 boot.postBootCommands = mkAfter 37 '' 38 if ! [ -e /var/lib/nixos/did-channel-init ]; then 39 echo "unpacking the NixOS/Nixpkgs sources..." 40 mkdir -p /nix/var/nix/profiles/per-user/root 41 ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels \ 42 -i ${channelSources} --quiet --option build-use-substitutes false 43 mkdir -m 0700 -p /root/.nix-defexpr 44 ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels 45 mkdir -m 0755 -p /var/lib/nixos 46 touch /var/lib/nixos/did-channel-init 47 fi 48 ''; 49}