Created
          April 17, 2014 10:44 
        
      - 
      
 - 
        
Save rejuvyesh/10973013 to your computer and use it in GitHub Desktop.  
    automate habs a little
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env zsh | |
| # Created by rejuvyesh <[email protected]> | |
| usage="Usage: ./cabal2pkgbuild <HACKAGE_PACKAGES_FILE>" | |
| if [[ -z $1 ]]; then | |
| echo $usage | |
| exit 1 | |
| fi | |
| if [[ ! -f $1 ]]; then | |
| echo "\`$1' does not exist or is not a regular file" | |
| exit 1 | |
| fi | |
| hackage_url="http://hackage.haskell.org" | |
| hackage_packages_file=($(<$1)) | |
| # Add packages from Hackage | |
| for hp in $hackage_packages_file; do | |
| # Grab latest version of package | |
| cabal_file=$(curl -s $hackage_url/package/$hp | grep -ioE "Cabal source package[)<>/lia href=\"]+\/package\/.+\.cabal" | grep -ioE "\/package.+") | |
| command="cblrepo add --patchdir patches --cbl-url $hackage_url$cabal_file" | |
| echo $command | |
| eval $command | |
| done | |
| i=1 | |
| for hp in ${hackage_packages_file}; do | |
| command="cblrepo pkgbuild --ghc-version 7.8.2 --patchdir patches $hp" | |
| echo "($i/${#hackage_packages_file}) $command" | |
| eval $command | |
| (( i+=1 )) | |
| done | |
| for pkg in ${hackage_packages_file}; do | |
| hpkg=haskell-$pkg | |
| command1="./makeahpkg $hpkg" | |
| command2="./makeahpkg -a i686 $hpkg" | |
| eval $command1 | |
| eval $command2 | |
| done | 
A few comments/suggestions:
- Making use of 
cblrepo syncremoves the need to download Cabal files from hackage. - Check out the 
versionscommand. - The 
--patchdir patchesis unnecessary, that's the default value. 
My own usage goes something like this:
% cblrepo sync
% cblrepo versions -l <list of packages> > pkgs-to-add
% cblrepo add $(cat pkgs-to-add)
% cblrepo build $(sed -e 's/,.*//' pkgs-to-add) > build-order
% cblrepo pkgbuild --ghc-version 7.8.2 $(cat build-order)
% ./makeahpkg -- $(cat build-order)
% ./makeahpkg -a i686 -- $(cat build-order)
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
I really like the idea of
nixos. I'll probably even switch, once I've the time to properly look into it. If you find the time, do write about your experience withnixos.