2009-05-29 14:24:48 +02:00
|
|
|
# This module generates the nixos-checkout script, which replaces the
|
|
|
|
# NixOS and Nixpkgs source trees in /etc/nixos/{nixos,nixpkgs} with
|
2012-06-04 17:39:07 +02:00
|
|
|
# Git checkouts.
|
2009-05-29 14:24:48 +02:00
|
|
|
|
|
|
|
{config, pkgs, ...}:
|
2009-05-24 20:28:30 +02:00
|
|
|
|
|
|
|
with pkgs.lib;
|
2008-08-26 21:45:06 +02:00
|
|
|
|
2009-05-29 14:24:48 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
nixosCheckout = pkgs.substituteAll {
|
2008-08-26 21:45:06 +02:00
|
|
|
name = "nixos-checkout";
|
2009-05-29 14:24:48 +02:00
|
|
|
dir = "bin";
|
|
|
|
isExecutable = true;
|
2011-04-27 17:34:33 +02:00
|
|
|
src = pkgs.writeScript "nixos-checkout"
|
|
|
|
''
|
2012-05-14 06:12:43 +02:00
|
|
|
#! ${pkgs.stdenv.shell} -e
|
2013-08-06 17:56:10 +02:00
|
|
|
|
2013-08-06 18:04:21 +02:00
|
|
|
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
|
|
|
echo "Usage: `basename $0` [PREFIX]. See NixOS Manual for more info."
|
2013-08-06 17:56:10 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-05-14 06:12:43 +02:00
|
|
|
prefix="$1"
|
|
|
|
if [ -z "$prefix" ]; then prefix=/etc/nixos; fi
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
cd "$prefix"
|
2011-04-27 17:34:33 +02:00
|
|
|
|
2012-06-04 17:39:07 +02:00
|
|
|
if [ -z "$(type -P git)" ]; then
|
|
|
|
echo "installing Git..."
|
|
|
|
nix-env -iA nixos.pkgs.git || nix-env -i git
|
|
|
|
fi
|
|
|
|
|
2011-04-27 17:34:33 +02:00
|
|
|
# Move any old nixos or nixpkgs directories out of the way.
|
|
|
|
backupTimestamp=$(date "+%Y%m%d%H%M%S")
|
|
|
|
|
2012-06-04 17:57:32 +02:00
|
|
|
if [ -e nixos -a ! -e nixos/.git ]; then
|
2011-04-27 17:34:33 +02:00
|
|
|
mv nixos nixos-$backupTimestamp
|
|
|
|
fi
|
|
|
|
|
2012-06-04 17:57:32 +02:00
|
|
|
if [ -e nixpkgs -a ! -e nixpkgs/.git ]; then
|
2011-04-27 17:34:33 +02:00
|
|
|
mv nixpkgs nixpkgs-$backupTimestamp
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check out the NixOS and Nixpkgs sources.
|
2012-06-04 17:39:07 +02:00
|
|
|
git clone git://github.com/NixOS/nixos.git nixos
|
|
|
|
git clone git://github.com/NixOS/nixpkgs.git nixpkgs
|
2011-04-27 17:34:33 +02:00
|
|
|
'';
|
2008-08-26 21:45:06 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-05-29 14:24:48 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2012-06-04 17:39:07 +02:00
|
|
|
environment.systemPackages = [ nixosCheckout ];
|
2008-08-26 21:45:06 +02:00
|
|
|
}
|