aboutsummaryrefslogblamecommitdiff
path: root/default.nix
blob: c601e0d3ce100a9b66eb00ce49003148b45075f0 (plain) (tree)
1
2
3
4
5
6
7
   



                                                           
                                                          
 





                               
 


                                   
        
            




              
                                                                
    
        
                                       








                                            
    









                                            
    
                        

                                     
                  
                                         

                                                         
       
    










                                                                                             
 
let
  niv-sources = import ./nix/sources.nix;
  pkgs = import niv-sources.nixpkgs { };
  src = pkgs.nix-gitignore.gitignoreSource [ "!.git" ] ./.;
  utils-i18n = pkgs.callPackage ./utils-i18n.nix { };
  pkgs-next = pkgs.callPackage ./nix/nixpkgs-next.nix { };

  jekyllEnv = pkgs.bundlerEnv {
    name = "jekyll-env";
    gemfile = ./Gemfile;
    lockfile = ./Gemfile.lock;
    gemset = ./gemset.nix;
  };

  projectBuildInputs = with pkgs; [
    jekyllEnv

    perl
    graphviz
    nixfmt
    git
    shellcheck
    jq
    niv
    (hunspellWithDicts (with utils-i18n.dicts; [ en pt fr eo ]))
  ];
in rec {
  inherit (pkgs-next) mdpo pymd4c md4c;
  site = pkgs.stdenv.mkDerivation {
    inherit src;
    name = "website-site";
    phases = [ "unpackPhase" "buildPhase" ];
    buildInputs = [ jekyllEnv ];
    buildPhase = ''
      patchShebangs .
      jekyll build -d $out
    '';
  };
  test = pkgs.stdenv.mkDerivation {
    inherit src;
    name = "website-test";
    phases = [ "unpackPhase" "buildPhase" ];
    buildInputs = projectBuildInputs;
    buildPhase = ''
      patchShebangs .
      ./tests.sh
      touch $out
    '';
  };
  shell = pkgs.mkShell {
    name = "website-shell";
    buildInputs = projectBuildInputs;
    shellHook = ''
      echo 'Starting a live server with:'
      echo '  jekyll serve --future --livereload --trace'
      jekyll serve --future --livereload --trace
    '';
  };
  publishScript = pkgs.writeShellScriptBin "publish.sh" ''
    set -euo pipefail
    SERVER_URL='root@euandre.org'
    REMOTE_PATH='/home/user-data/www/default/'
    OUT_DOCS='${site}'
    ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no "$SERVER_URL" rm -rf "$REMOTE_PATH/*"
    ${pkgs.rsync}/bin/rsync -avzP                                   \
                            --rsh="ssh -o StrictHostKeyChecking=no" \
                            "$OUT_DOCS/"                            \
                            "$SERVER_URL:$REMOTE_PATH"
  '';
}