nixpkgs-suyu/modules/installer/tools/nixos-checkout.nix
Eelco Dolstra a0cc181117 * nixos-checkout: get the NixOS/Nixpkgs sources from GitHub.
svn path=/nixos/trunk/; revision=34347
2012-06-04 15:39:07 +00:00

50 lines
1.2 KiB
Nix

# This module generates the nixos-checkout script, which replaces the
# NixOS and Nixpkgs source trees in /etc/nixos/{nixos,nixpkgs} with
# Git checkouts.
{config, pkgs, ...}:
with pkgs.lib;
let
nixosCheckout = pkgs.substituteAll {
name = "nixos-checkout";
dir = "bin";
isExecutable = true;
src = pkgs.writeScript "nixos-checkout"
''
#! ${pkgs.stdenv.shell} -e
prefix="$1"
if [ -z "$prefix" ]; then prefix=/etc/nixos; fi
mkdir -p "$prefix"
cd "$prefix"
if [ -z "$(type -P git)" ]; then
echo "installing Git..."
nix-env -iA nixos.pkgs.git || nix-env -i git
fi
# Move any old nixos or nixpkgs directories out of the way.
backupTimestamp=$(date "+%Y%m%d%H%M%S")
if test -e nixos -a ! -e nixos/.svn; then
mv nixos nixos-$backupTimestamp
fi
if test -e nixpkgs -a ! -e nixpkgs/.svn; then
mv nixpkgs nixpkgs-$backupTimestamp
fi
# Check out the NixOS and Nixpkgs sources.
git clone git://github.com/NixOS/nixos.git nixos
git clone git://github.com/NixOS/nixpkgs.git nixpkgs
'';
};
in
{
environment.systemPackages = [ nixosCheckout ];
}