Skip to content
Snippets Groups Projects
Select Git revision
  • 26c63f85c65a2959af7cb3d03636d9c6c637db38
  • master default protected
  • 0.5.9
  • 0.5.8
  • 0.5.7
  • 0.5.6
  • 0.5.5
  • 0.5.4
  • 0.5.3
  • 0.5.2
  • 0.5.1
  • 0.5.0
  • 0.4.17
  • 0.4.16
  • 0.4.15
  • 0.4.14
  • 0.4.13
  • 0.4.12
  • 0.4.11
  • 0.4.10
  • 0.4.9
  • 0.4.8
22 results

update-hashes.nix

Blame
  • update-hashes.nix 1.54 KiB
    {
      pkgs,
      buildRoot,
      projectDefinition,
      workingDirectory,
      ...
    }: let
      serviceSourcePath = "${buildRoot}/";
      common = import ./common.nix {inherit pkgs;};
    in ''
      #!${pkgs.bash}/bin/bash
    
      ${common}
      
      defaultHash="${pkgs.lib.fakeHash}"
    
      echo_step "Reset vendorHash to default value: $defaultHash"
      ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*null|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix
      ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*\"[^\"]\"|vendorHash = \"$defaultHash\"|g" ${workingDirectory}/project.nix
      
      RESULT=$(${pkgs.nix}/bin/nix build .#goPkg 2>&1)
      if [[ $? -ne 0 ]]; then
    
        ## check if  RESULT contain vendorHash = null; then set to null and rebuild
        if [[ "$RESULT" == *"vendorHash = null"* ]]; then
            ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*\".*\"|vendorHash = null|g" ${workingDirectory}/project.nix
            RESULT=$(${pkgs.nix}/bin/nix build .#goPkg 2>&1)
    
            if [[ $? -ne 0 ]]; then
                echo_fail "Could not get the hash"
                exit 1
            fi
    
            echo_ok "No dependencies found and vendorHash is set to null."
            exit 0
    
        fi
    
      fi
    
      HASH=$(echo "$RESULT" | grep 'got:'  | awk '{print $2}')
      if [[ -z "$HASH" ]]; then
        echo_fail "Could not get the hash"
        ${pkgs.gnused}/bin/sed -i 's|vendorHash\s*=\s*".*"|vendorHash = null|g' ${workingDirectory}/project.nix
        exit 1
      fi
    
      ${pkgs.gnused}/bin/sed -i "s|vendorHash\s*=\s*\".*\"|vendorHash = \"''${HASH}\"|g" ${workingDirectory}/project.nix
      echo_ok "Hash updated, new hash is ''${HASH}'"
    
    
    ''