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


                              
                                                     
                         
    





                               
                  









                                                                             








                                                                
                                                     
                                      
                                  
                     
                       
                            

         
    
                     

                           








                   
                          
                          
                 
    
                            

                           
               
                                                                   

      



                                                  
 
let pkgs = import <nixpkgs> { };
in rec {
  utils = import ./utils.nix {
    pkgs = pkgs;
    src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
    baseName = "website";
  };
  jekyllEnv = pkgs.bundlerEnv {
    name = "jekyll-env";
    gemfile = ./Gemfile;
    lockfile = ./Gemfile.lock;
    gemset = ./gemset.nix;
  };
  subtasks = rec {
    hunspellCheck = utils.baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-hunspell";
      buildInputs = baseAttrs.buildInputs
        ++ [ (pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ])) ];
      buildPhase = ''
        patchShebangs .
        ./spelling/check-spelling.sh "${subtasks.docs}"
        touch $out
      '';
    });
    assertContent = utils.baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-assert-content";
      buildInputs = baseAttrs.buildInputs ++ [ pkgs.jq ];
      buildPhase = ''
        patchShebangs .
        ./scripts/assert-content.sh "${subtasks.docs}/site.json"
        touch $out
      '';
    });
    docs = utils.baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-docs";
      buildInputs = [ jekyllEnv ];
      buildPhase = ''
        patchShebangs .
        jekyll build -d $out
      '';
    });
  };
  test = utils.test [
    utils.formatNix
    (utils.shellcheck null)
    (utils.fixme [
      "utils.nix"
      "TODOs.org"
      "_pastebins/"
      "_posts/"
      "_tils/"
      "drafts/"
      "templates/"
    ])
    subtasks.hunspellCheck
    subtasks.assertContent
    subtasks.docs
  ];
  shell = pkgs.mkShell rec {
    name = "website-shell";
    buildInputs = [
      jekyllEnv
      (pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ]))
    ];
  };
  publishScript = utils.overwritingPublishScript {
    docsDerivation = subtasks.docs;
    overwrite = false;
  };
}