2015-05-20 13:51:57 +02:00
|
|
|
# This module generates the nixos-checkout script, which performs a
|
|
|
|
# checkout of the Nixpkgs Git repository.
|
2009-05-29 14:24:48 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-05-24 20:28:30 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with 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
|
2013-10-01 16:02:08 +02:00
|
|
|
fi
|
2013-08-06 17:56:10 +02:00
|
|
|
|
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..."
|
2015-08-05 17:29:08 +02:00
|
|
|
nix-env -iA nixos.git
|
2012-06-04 17:39:07 +02:00
|
|
|
fi
|
|
|
|
|
2013-10-01 16:02:08 +02:00
|
|
|
# Move any old nixpkgs directories out of the way.
|
2011-04-27 17:34:33 +02:00
|
|
|
backupTimestamp=$(date "+%Y%m%d%H%M%S")
|
|
|
|
|
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
|
|
|
|
|
2015-05-20 13:51:57 +02:00
|
|
|
# Check out the Nixpkgs sources.
|
|
|
|
if ! [ -e nixpkgs/.git ]; then
|
|
|
|
echo "Creating repository in $prefix/nixpkgs..."
|
|
|
|
git init --quiet nixpkgs
|
|
|
|
else
|
|
|
|
echo "Updating repository in $prefix/nixpkgs..."
|
|
|
|
fi
|
|
|
|
cd nixpkgs
|
|
|
|
git remote add origin git://github.com/NixOS/nixpkgs.git || true
|
|
|
|
git remote add channels git://github.com/NixOS/nixpkgs-channels.git || true
|
|
|
|
git remote set-url origin --push git@github.com:NixOS/nixpkgs.git
|
|
|
|
git remote update
|
|
|
|
git checkout master
|
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
|
|
|
}
|